This file is indexed.

/usr/share/doc/sludge/SLUDGEDevKitHelp/Using_Audio_in_SLUDGE.html is in sludge-doc 2.1.2-3build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<TITLE>Using Audio in SLUDGE</TITLE>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<BODY>
<HR>
<div align="center"><img id="headerGraphic" src="images/sludge300.png" alt="SLUDGE"/></div>
<h2>Using Audio in SLUDGE</h2>
<HR>


<P>
SLUDGE can play various audio files, split into two overall types... track-based music formats (such as .MOD and .XM files) and sampled sound formats (.WAV and .OGG).
</P>

<H3>Sampled sounds:</H3>

<P>
Sampled sounds can be used for speech, sound effects and music. SLUDGE supports .WAV and .OGG files of any frequency and depth (i.e. 8 or 16 bit).
</P>

<P>
You can play sampled sounds using the <a href="playSound.html">playSound</a> function - simply specify the <a href="File_Handling.html">file handle</a> of the sample file as the parameter. Alternatively, sounds can be looped using the <a href="loopSound.html">loopSound</a> function (instead of the sound playing once and stopping, it plays repeatedly). Sounds can be stopped by the <a href="stopSound.html">stopSound</a> function.
</P>

<P>
When sampled sounds are played using either of the above functions, they are played at the volume most recently specified by the <a href="setDefaultSoundVolume.html">setDefaultSoundVolume</a> function. If this function has not yet been called, the default sound volume is 255 - or, in other words, full.
</P>

<P>
After a sound has started playing, its volume can be changed using <a href="setSoundVolume.html">setSoundVolume</a> and the function <a href="setSoundLoopPoints.html">setSoundLoopPoints</a> can be used to change the start and end points at which a sample played using <a href="loopSound.html">loopSound</a> loops.
</P>

<H3>Preloading sounds before you need them:</H3>

<P>
You can use the <a href="cacheSound.html">cacheSound</a> function to load (and, if required, decompress) a sound file into memory without playing it. This means there's no pause when you actually come to play the sound, because it's already been loaded.
</P>

<P>
Using the <a href="freeSound.html">freeSound</a> function you can also remove sounds from the cache once you no longer need them, although this is only really worthwhile for huge sounds (music, for example). Sounds are also removed from the cache automatically once they become old - it can only hold 8 files at once. Call <a href="getSoundCache.html">getSoundCache</a> to determine the contents of the cache at any given moment.
</P>

<H3>Stopping one sound when starting another:</H3>

<P>
If one sound is to &quot;replace&quot; another (for example, a looping wind sound effect which should stop at the same time as a slamming door sound effect starts) it is wise to start the new sound effect before stopping the old one, rather than the other way around:
</P>

<P>
<pre>loopSound ('badweather.wav');
say (ego, 'I'm not going out there...');
addOverlay ('closeddoor.tga', 100, 100);
playSound ('slam.wav');
stopSound ('badweather.wav');
say (ego, 'That's better.');</pre>
</P>

<P>
This is because the <a href="playSound.html">playSound</a> function has to load the sound to be played from the data file before it can be started. For small sound files this is almost instantaneous, but for larger files this can create a slight pause while the sound is being loaded into memory. Using the order above, the old sound will still be playing during this period.
</P>

<H3>Track-based music:</H3>

<P>
Music support in SLUDGE works slightly differently... it is possible to play only 3 track-based music files at any one time on channels numbered 0 to 2. Therefore, when playing a music file you must also specify on which channel you wish to play it (this is all achieved using one call to the <a href="startMusic.html">startMusic</a> function). This makes sure that SLUDGE doesn't accidentally play it instead of another file which you wanted to keep playing too.
</P>

<P>
After starting a piece of music, any further music command (for example, the <a href="stopMusic.html">stopMusic</a> function, which stops a song playing) will use these channel numbers rather than the file handles. For example...
</P>

<P>
<pre>var t = pickOne ('slow.xm', 'fast.s3m', 'punkrock.mod', 'samba.mid');
startMusic (t, 2);
pause (100);
stopMusic (2);</pre>
</P>

<P>
This will play 100 frames-worth of a random tune and then stop, no matter which tune was picked. Should any music be playing on either channel 0 or channel 1 at the time, it will not be affected.
</P>

<P>
Like sampled sounds, SLUDGE can set the default volume at which songs will start playing (using the <a href="setDefaultMusicVolume.html">setDefaultMusicVolume</a> function) and also change the volume at which each channel is currently playing (using the <a href="setMusicVolume.html">setMusicVolume</a> function).
</P>

<H3>See also:</H3>

<P>
<a href="File_Formats_Used_by_SLUDGE.html">File Formats Used by SLUDGE</a>
</P>

<P>
<a href="playMovie.html">playMovie</a>
</P>

<P class="copyright-notice">SLUDGE and this SLUDGE documentation are <A HREF="Copyright.html">copyright</A> Hungry Software and contributors 2000-2011
</P>

<HR>
</BODY>
</html>