Audio Library

PreviousNext

Channels

Channels are very useful if you want to play more than one sound effect at the same time. With Channels you can play and stop them seperatly. You can change the volume, set panning or whatever you need.

For using channels you got different possibilties to work with. You can use EM_CHANNEL to access a channel directly or you can work with EM_CHANNELS, which helps you handle a lot of different channels. In EM_CHANNELS, you have the possibility to access all the channels together and for example stop them at the same time.

Playing Sounds

You can play sounds by using EM_CHANNEL or by accessing EM_CHANNELS directly. The sound has to be loaded before playing.

To play your sound file on a channel, use play, play_timed, fade_in or fade_in_timed. You may also pause, resume, stop and fade_out a playing soundfile. Another possibility comes with EM_CHANNELS. There one may find play_on_first_free_channel, play_timed_on_first_free_channel, fade_in_on_first_free_channel and fade_in_timed_on_first_free_channel. In these cases, your file will be played on the first unused channel found (if there is any).

All these play functions want you to pass a valid EM_SOUND file. Learn more about loading EM_SOUND files here.

Grouping

With EM_AUDIO_GROUPS you got the possibility to put the channels to a group. Whenever two channels are in the same group, theire settings are allways the same. When a new channel gets added to a group his settings change immediately to the current group ones.

Notes

You must initialize a channel with a number. The number is an id for the channel and has to be in the right order. If you use the feature set_number, keep attention you set the right number to a channel. Otherwise, system may get out of sync and may also crash. Never create EM_CHANNEL directly. Use EM_CHANNELS.extend instead.

You can also apply effects to a channel. Attention by using effects: they may boost your CPU. Do not use them when having a lot of other things to do (like drawing).

When using a fading function, keep attention that fading is non-blocking. You should block fading on your own. Otherwise, your application may hang or crash during this fading effect.

When using pause, keep attention on some special behaviour. This is caused by SDL, so keep an eye on updates.