geSound
From GriffinEngine
Contents
Usage
If the Play() command is called again before the sound stopped playing, you will be able to hear them both, mixed. The number of sounds played simultaneously is limited by mixChannels param of the Init() function.
Inheritance
Base classes
- geObject
- geResource
- geSound
- geResource
Reference
Constants
#define GE_PAN_LEFT 0.0
#define GE_PAN_CENTER 0.5
#define GE_PAN_RIGHT 1.0
Constructors
geSound( string filename );
- Supported formats: WAVE, OGG Vorbis, AIFF, RIFF, VOC
static void PlayMusic( string music ); // Loop background music.
- Supported formats: WAVE, OGG Vorbis, MP3, MOD, MIDI
static void PauseMusic(); // pause music (can be resumed later)
static void ResumeMusic(); // resume music
static void RewindMusic(); // rewind music (NOTE: does not support MIDI)
static void StopMusic(); // stop music (call PlayMusic() to start again)
static double getMusicVolume(); // set music volume (range: 0.0 - 1.0)
static void setMusicVolume( double musicVolume=0.5 ); // get current music volume
Methods
static void Init( int _mixChannels = 16, int frequency = 44100, int channels = 2, int chunkSize = 4096 ); // Initialize the sound subsystem
- This method must be called (once) before any geSound objects can be created.
Param | Explanation | Default |
---|---|---|
mixChannels | Maximum number of sounds that can be played simultaneously. | 16 |
frequency | Sampling frequency of the output mix.
Acceptable values are 44100 (44.1kHz), 22050 (22kHz), 11025 (11kHz). Switching to a lower frequency decreases CPU usage, but also decreases sound quality. |
44100 |
channels | Number of output channels. Acceptable values are 1 (mono) or 2 (stereo).
There is no performance benefit to either setting. |
2 |
chunkSize | The size in bytes of each mixed sample buffer.
The smaller the chunkSize, the more frequently the mixer hooks are called. Increase chunkSize to decrease CPU resources, if sound skips or if only playing music. Decrease chunkSize to decrease sound lag. |
4096 |
static void StopAll(); // Stop ALL sounds on all channels
static double getVolume(); // Get current volume (0...1 range)
static void setVolume( double _volume, bool reapply = false ); // Set global volume
- Optional "reapply" flag can also redo volume for all currently playing sounds (will cause an audible click).
void Play( double instanceVolume=1.0, double pan=GE_PAN_CENTER, int loop=1 ); // Play the sound.
- By default it plays once, but sound can be looped or repeated by setting the optional first param: 0 = loop, 1 = play once, 2+ = play n times.
void Stop(); // Stop a specific sound (if playing)
Resources |
---|
geResourceManager · geResource |
geAnimation · geBitmap · geFont · geMaterial · geMesh · GeSound · GeSprite · GeSpriteSheet |