SM2
A wrapper for Sound Manager 2
The title says it all. Sound Manager 2 is an audio system designed to provide javascript & HTML5 with the audio capabilities of Flash, from Schillmania. The main site, along with documentation for the main program, is here.
This extension is pure javascript/flash, so it is pretty much guaranteed to work cross-browser. Not only does it do the basics of what GM:HTML5's currently flaky audio system can do, it also provides additional functionality beyond GM's current capabilities:
Attributes
Basic:
- Plays '.ogg' and '.mp3'
- Loops sounds
- Very simple and intuitive
- Check to see if sound is playing
- Change volume of sound
- Change pan of sound
Advanced:
- The ability to pause a sound.
- The ability to mute a sound.
- The ability to change the pan/volume of a sound while it is playing.
- The ability to begin playing a sound from its middle.
- The ability to check the length of a sound.
Disadvantages:
- Inability to use sound effect (reverb, echo, etc.)
- Flashblockers will potentially render your game mute. This is a serious advantage that HTML5 has over Flash, because this is one extra 'issue' users could have with your program.
Functions
- sm2_init(Flash_Version): Initializes the sound system. Flash_Version tells SoundManager 2 which version of Flash to use and should equal 8 or 9. Version 9 of flash allows 'multi-shot' capabilities (multiple instances of the same sound playing at once).
- sm2_isready(): Returns an integer that tells whether the sound system has finished initializing. 0 = not ready, 1 = ready, -1 = error initializing. -1 is usually due to Flashblockers.
- sm2_isok(): The sound system is healthy. See main Sound Manager 2 website for more details.
- sm2_reboot(): Reboots the sound system. See main Sound Manager 2 website for more details.
- sm2_create_sound(str_name,str_url): Loads a sound into the system. str_name is the name you will use to access it, and str_url is the name of your sound file(s). str_url should not include the file extensions, and you should include two sound files (.mp3 and .ogg) of the same name with your game.
- sm2_delete_sound(str_name): Removes a sound from the system.
- sm2_play_sound(str_name): Plays a sound once.
- sm2_loop_sound(str_name): Loops a sound. (This is a hack on my part and not entirely perfect. For shorter sounds it will occasionally misstep but for long sounds like music you should be fine.)
- sm2_stop_sound(str_name): Stops a sound that is playing.
- sm2_pause_sound(str_name): Pauses a sound at it's current position.
- sm2_resume_sound(str_name): Resume a paused sound from it's current position.
- sm2_mute_sound(str_name): Mutes a sound. It is 'playing' in the background but cannot be heard.
- sm2_unmute_sound(str_name): Unmutes a sound.
- sm2_mute_sound(str_name): Mutes a sound. It is 'playing' in the background but cannot be heard.
- sm2_mute_all(): Mutes all sounds.
- sm2_unmute_all(): Unmutes all sounds.
- sm2_pause_all(): Pauses all sounds.
- sm2_resume_all(): Resumes all sounds.
- sm2_stop_all(): Stops all sounds.
- sm2_sound_isloaded(str_name): Returns whether a sound is loaded or not.
- sm2_sound_isplaying(str_name): Returns whether a sound is playing or not.
- sm2_sound_ismuted(str_name): Returns whether a sound is muted or not.
- sm2_sound_ispaused(str_name): Returns whether a sound is paused or not.
- sm2_sound_set_pan(str_name,int_pan): Sets the pan of a sound. int_pan must be between -100 (left) and 100 (right). 0 is default.
- sm2_sound_set_volume(str_name,int_volume): Sets the volume of a sound. int_volume must be between 0 (min) and 100 (max). 100 is default.
- sm2_sound_set_position(str_name,int_pos): Sets the position of a sound. This will determine where the sound will start playing from when next used. int_pos must be between 0 and the duration (in milliseconds) of the sound.
- sm2_sound_get_pan(str_name): Returns the pan of a sound.
- sm2_sound_get_volume(str_name): Returns the volume of a sound.
- sm2_sound_get_position(str_name): Returns the position of a sound (in milliseconds).
- sm2_sound_get_duration(str_name): Returns the duration of a sound (in milliseconds).
The download includes the .GEX extension file and a .GMZ example: Download Link.
Edited by Oracizan, 14 March 2013 - 01:48 AM.











