Difference between revisions of "Legacy:Functions/Sounds"

From Spherical
Jump to: navigation, search
(created)
 
(Changed API to Legacy)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
== Sounds ==
 
== Sounds ==
  
* Sphere [[API:Sound|Sound]] object: Holds a sound or piece of music that can be played.
+
* Sphere [[Legacy:Sound|Sound]] object: Holds a sound or piece of music that can be played.
* Sphere [[API:SoundEffect|SoundEffect]] object: Holds a sound that can be played. This powerful object is designed mainly for sound effects.
+
* Sphere [[Legacy:SoundEffect|SoundEffect]] object: Holds a sound that can be played. This powerful object is designed mainly for sound effects.
* [[API:LoadSound|LoadSound]](''filename'' [, ''streaming'']): Load a sound from ''filename'', ''streaming'' from disk optional.
+
* [[Legacy:LoadSound|LoadSound]](''filename'' [, ''streaming'']): Load a sound from ''filename'', ''streaming'' from disk optional.
  
 
=== Sound object ===
 
=== Sound object ===
  
* [[API:Sound/play|Sound.play]](''repeat''): Play the sound, loop if ''repeat'' is true.
+
* [[Legacy:Sound/play|Sound.play]](''repeat''): Play the sound, loop if ''repeat'' is true.
* [[API:Sound/pause|Sound.pause]](): Pause playback of the sound. Call [[API:Sound/play|Sound.play]]() to resume.
+
* [[Legacy:Sound/pause|Sound.pause]](): Pause playback of the sound. Call [[Legacy:Sound/play|Sound.play]]() to resume.
* [[API:Sound/stop|Sound.stop]](): Stop playback of the sound.
+
* [[Legacy:Sound/stop|Sound.stop]](): Stop playback of the sound.
  
* [[API:Sound/reset|Sound.reset]](): Resets playback. No effect on MIDIs.
+
* [[Legacy:Sound/reset|Sound.reset]](): Resets playback. No effect on MIDIs.
* [[API:Sound/setRepeat|Sound.setRepeat]](repeat): Sets if the sound should be repeated.
+
* [[Legacy:Sound/setRepeat|Sound.setRepeat]](repeat): Sets if the sound should be repeated.
* [[API:Sound/getRepeat|Sound.getRepeat]](): Returns true if sound is set to repeat, otherwise false.
+
* [[Legacy:Sound/getRepeat|Sound.getRepeat]](): Returns true if sound is set to repeat, otherwise false.
  
* [[API:Sound/isPlaying|Sound.isPlaying]](): Check if the sound is currently playing.
+
* [[Legacy:Sound/isPlaying|Sound.isPlaying]](): Check if the sound is currently playing.
* [[API:Sound/isSeekable|Sound.isSeekable]](): Returns true if the sound is seekable. Not all sound types are seekable, Ogg is.
+
* [[Legacy:Sound/isSeekable|Sound.isSeekable]](): Returns true if the sound is seekable. Not all sound types are seekable, Ogg is.
* [[API:Sound/getLength|Sound.getLength]](): Gets the length of the sound.
+
* [[Legacy:Sound/getLength|Sound.getLength]](): Gets the length of the sound.
* [[API:Sound/clone|Sound.clone]](): Returns a copy of the sound object.
+
* [[Legacy:Sound/clone|Sound.clone]](): Returns a copy of the sound object.
* [[API:Sound/getPosition|Sound.getPosition]](): Returns the position of the sound, zero if the sound isn't seekable.
+
* [[Legacy:Sound/getPosition|Sound.getPosition]](): Returns the position of the sound, zero if the sound isn't seekable.
* [[API:Sound/setPosition|Sound.setPosition]](''position''): Sets the position of the sound. Does nothing if the sound isn't seekable.
+
* [[Legacy:Sound/setPosition|Sound.setPosition]](''position''): Sets the position of the sound. Does nothing if the sound isn't seekable.
 
 
* [[API:Sound/getVolume|Sound.getVolume]](): Get the volume of the sound (0-255). No effect on MIDIs.
 
* [[API:Sound/setVolume|Sound.setVolume]](''volume''): Set the volume of the sound (0-255). No effect on MIDIs.
 
* [[API:Sound/setPan|Sound.setPan]](pan): Pan can be from -255 to 255.  -255 = left, 255 = right. No effect on MIDIs.
 
* [[API:Sound/getPan|Sound.getPan]](): Returns the current pan of the sound. No effect on MIDIs.
 
* [[API:Sound/setPitch|Sound.setPitch]](''pitch''): Sets the pitch for a sound. No effect on MIDIs.
 
* [[API:Sound/getPitch|Sound.getPitch]](): Returns the current pitch. No effect on MIDIs.
 
  
 +
* [[Legacy:Sound/getVolume|Sound.getVolume]](): Get the volume of the sound (0-255). No effect on MIDIs.
 +
* [[Legacy:Sound/setVolume|Sound.setVolume]](''volume''): Set the volume of the sound (0-255). No effect on MIDIs.
 +
* [[Legacy:Sound/setPan|Sound.setPan]](pan): Pan can be from -255 to 255.  -255 = left, 255 = right. No effect on MIDIs.
 +
* [[Legacy:Sound/getPan|Sound.getPan]](): Returns the current pan of the sound. No effect on MIDIs.
 +
* [[Legacy:Sound/setPitch|Sound.setPitch]](''pitch''): Sets the pitch for a sound. No effect on MIDIs.
 +
* [[Legacy:Sound/getPitch|Sound.getPitch]](): Returns the current pitch. No effect on MIDIs.
  
 
=== Sound Effect object ===
 
=== Sound Effect object ===
* Sphere [[API:SoundEffect|SoundEffect]] object
+
* Sphere [[Legacy:SoundEffect|SoundEffect]] object
* [[API:LoadSoundEffect|LoadSoundEffect]](filename [, type]): returns a [[API:SoundEffect|SoundEffect]] object from 'filename'. If Sphere is unable to open the file, the engine will give an error message and exit. There are two types of sound effects: SE_SINGLE and SE_MULTIPLE.
+
* [[Legacy:LoadSoundEffect|LoadSoundEffect]](filename [, type]): returns a [[Legacy:SoundEffect|SoundEffect]] object from 'filename'. If Sphere is unable to open the file, the engine will give an error message and exit. There are two types of sound effects: SE_SINGLE and SE_MULTIPLE.
 
** SE_SINGLE sound effects only allow the sound to be played once at a time.
 
** SE_SINGLE sound effects only allow the sound to be played once at a time.
 
** SE_MULTIPLE sound effects always open a new stream to the audio device for each time it is played (cleaning up or reusing old streams if possible).
 
** SE_MULTIPLE sound effects always open a new stream to the audio device for each time it is played (cleaning up or reusing old streams if possible).
* [[API:SoundEffect/play|SoundEffect.play]](): plays the sound effect.
+
* [[Legacy:SoundEffect/play|SoundEffect.play]](): plays the sound effect.
 
** If the sound effect is of type SE_SINGLE, this plays the sound if it isn't playing yet, and starts it again if it is.
 
** If the sound effect is of type SE_SINGLE, this plays the sound if it isn't playing yet, and starts it again if it is.
 
** If the sound effect is of type SE_MULTIPLE, play() simply starts playing the sound again.
 
** If the sound effect is of type SE_MULTIPLE, play() simply starts playing the sound again.
* [[API:SoundEffect/stop|SoundEffect.stop]](): stops playback
+
* [[Legacy:SoundEffect/stop|SoundEffect.stop]](): stops playback
 
** If the sound is of type SE_SINGLE, stop the sound.
 
** If the sound is of type SE_SINGLE, stop the sound.
 
** If it is of type SE_MULTIPLE, stop all playing instances of the sound.
 
** If it is of type SE_MULTIPLE, stop all playing instances of the sound.
* [[API:SoundEffect/setVolume|SoundEffect.setVolume]](volume): sets the volume for the sound effect (0-255)
+
* [[Legacy:SoundEffect/setVolume|SoundEffect.setVolume]](volume): sets the volume for the sound effect (0-255)
* [[API:SoundEffect/getVolume|SoundEffect.getVolume]](): returns the sound effect's volume (0-255)
+
* [[Legacy:SoundEffect/getVolume|SoundEffect.getVolume]](): returns the sound effect's volume (0-255)
* [[API:SoundEffect/setPan|SoundEffect.setPan]](pan): pan ranges from -255 to 255.  -255 = left, 255 = right. pan defaults to 0 (center).
+
* [[Legacy:SoundEffect/setPan|SoundEffect.setPan]](pan): pan ranges from -255 to 255.  -255 = left, 255 = right. pan defaults to 0 (center).
* [[API:SoundEffect/getPan|SoundEffect.getPan]](): returns the current pan of the sound effect
+
* [[Legacy:SoundEffect/getPan|SoundEffect.getPan]](): returns the current pan of the sound effect
* [[API:SoundEffect/setPitch|SoundEffect.setPitch]](pitch): pitch ranges from 0.5 to 2.0.  0.5 is an octave down (and half as fast) while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
+
* [[Legacy:SoundEffect/setPitch|SoundEffect.setPitch]](pitch): pitch ranges from 0.5 to 2.0.  0.5 is an octave down (and half as fast) while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
* [[API:SoundEffect/getPitch|SoundEffect.getPitch]](): returns the current pitch
+
* [[Legacy:SoundEffect/getPitch|SoundEffect.getPitch]](): returns the current pitch

Latest revision as of 09:11, 19 June 2017

Sounds

  • Sphere Sound object: Holds a sound or piece of music that can be played.
  • Sphere SoundEffect object: Holds a sound that can be played. This powerful object is designed mainly for sound effects.
  • LoadSound(filename [, streaming]): Load a sound from filename, streaming from disk optional.

Sound object

  • Sound.getVolume(): Get the volume of the sound (0-255). No effect on MIDIs.
  • Sound.setVolume(volume): Set the volume of the sound (0-255). No effect on MIDIs.
  • Sound.setPan(pan): Pan can be from -255 to 255. -255 = left, 255 = right. No effect on MIDIs.
  • Sound.getPan(): Returns the current pan of the sound. No effect on MIDIs.
  • Sound.setPitch(pitch): Sets the pitch for a sound. No effect on MIDIs.
  • Sound.getPitch(): Returns the current pitch. No effect on MIDIs.

Sound Effect object

  • Sphere SoundEffect object
  • LoadSoundEffect(filename [, type]): returns a SoundEffect object from 'filename'. If Sphere is unable to open the file, the engine will give an error message and exit. There are two types of sound effects: SE_SINGLE and SE_MULTIPLE.
    • SE_SINGLE sound effects only allow the sound to be played once at a time.
    • SE_MULTIPLE sound effects always open a new stream to the audio device for each time it is played (cleaning up or reusing old streams if possible).
  • SoundEffect.play(): plays the sound effect.
    • If the sound effect is of type SE_SINGLE, this plays the sound if it isn't playing yet, and starts it again if it is.
    • If the sound effect is of type SE_MULTIPLE, play() simply starts playing the sound again.
  • SoundEffect.stop(): stops playback
    • If the sound is of type SE_SINGLE, stop the sound.
    • If it is of type SE_MULTIPLE, stop all playing instances of the sound.
  • SoundEffect.setVolume(volume): sets the volume for the sound effect (0-255)
  • SoundEffect.getVolume(): returns the sound effect's volume (0-255)
  • SoundEffect.setPan(pan): pan ranges from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).
  • SoundEffect.getPan(): returns the current pan of the sound effect
  • SoundEffect.setPitch(pitch): pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast) while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
  • SoundEffect.getPitch(): returns the current pitch