Next: 3.2 Uninitializing MIDAS Up: 3 Using MIDAS Digital Previous: 3 Using MIDAS Digital

# 3.1 Initializing and configuring MIDAS

MIDAS Digital Audio System initialization consists of five basic steps, which are outlined below. The last two steps are not necessary in all cases.

1. Call MIDASstartup. This should be done as early in the program as possible, preferably at the very beginning. MIDASstartup does not take a significant amount of time, and does not allocate any memory, it simply initializes MIDAS to a safe and stable state and resets all configration options. Calling MIDASclose is always safe after MIDASstartup has been called.

2. Configure MIDAS. This can be done by setting different MIDAS options with MIDASsetOption, or by calling MIDASconfig to prompt the user for the settings. The configuration can also be loaded from a file (with MIDASloadConfig) or registry (with MIDASreadConfigRegistry) at this point. Apart from the configuration functions, no MIDAS functions may be called yet.

3. Initialize MIDAS by calling MIDASinit. All MIDAS functions are usable after this, and the program can fully start using MIDAS. Most MIDAS configuration options can not be changed while MIDAS is initialized, so to change the options it is necessary to uninitialize MIDAS first.

4. Start background sound playback. Unless you want to poll MIDAS manually (with MIDASpoll), you should now call MIDASstartBackgroundPlay to start background sound playback. MIDASstartBackgroundPlay starts a playback thread (in multithreaded systems) or a timer, and polls MIDAS automatically from it.

5. Open sound channels with MIDASopenChannels. The number of open sound channel limits the number of sounds that can be played simultaneously -- one sound channel can play one sound. The number of sound channels needed depends on the application, typical values might be 8-32 channels for a module, one channel per stream and 1-8 channels for sound effects. Having more channels open than necessary will not increase the CPU use, as inactive channels do not need CPU attention. However, some sound cards may place limitations on the maximum number of open channels. If you are only playing a single module, opening the channels manually is not necessary, as MIDASplayModule can open the needed channels automatically.

Next: 3.2 Uninitializing MIDAS Up: 3 Using MIDAS Digital Previous: 3 Using MIDAS Digital