Initialisation
Overview
The first thing an application should do when using audio is to enable the subsystem and open a mixer device.
Note: If you use one of the built-in players, you may let them initialize the subsystem for you.
Initialize subsystem
Initializing the subsystem is a very easy task. Simply inherit from EM_SHARED_SUBSYSTEMS and you'll get a new feature audio_subsystem.
This is the audio subsystem object in a singleton access. Simply call now audio_subsystem.enable to enable the subsystem.
Note: Always audio_subsystem.disable the subsystem before quitting. Otherwise your application may leave unfreed resources.
Open a mixer device
After enabling the subsystem, you have to open a mixer device where you set the audio output settings. These settings are described in the next part.
The audio subsystem already provides you with a mixer. You now have to open the device with the output settings you like.
As sampling frequency, it is recommended to use 22050 Hz when you have a lot of other tasks in parallel (like in games). If you only plan to code some music player, you should use 44100 Hz for better sound quality.
As sample format it's recommended to use signed 16 bit samples. On very old systems, you may have to use 8 bit samples as the soundcard may not support the 16 bit mode.
Always use stereo output when possible. This allows you some additional effects like positioning sound source.
Leave wave chunk size at 4 KB as this seems to be a good value in memory consuming applications (like games).
Note: You don't need to close the mixer device as this is also done when disabling the audio subsystem.