This section describes all functions available for MIDAS initialization, configuration and system control. This includes error handling.
BOOL MIDASstartup(void)
Prepares MIDAS Sound System for initialization and use.
None.
This function sets all MIDAS configuration variables to default values and prepares MIDAS for use. It must be called before any other MIDAS function, including MIDASinit and MIDASsetOption, is called. After this function has been called, MIDASclose can be safely called at any point and any number of times, regardless of whether MIDAS has been initialized or not. After calling this function, you can use MIDASsetOption to change MIDAS configuration before initializing MIDAS with MIDASinit.
TRUE if successful, FALSE if not.
All
MIDASsetOption, MIDASinit, MIDASclose
int MIDASgetLastError(void)
Gets the MIDAS error code for last error.
None.
This function can be used to read the error code for most recent failure. When a MIDAS API function returns an error condition, this function can be used to determine the actual cause of the error, and this error can then be reported to the user or ignored, depending on the kind of response needed. Use MIDASgetErrorMessage to get a textual message corresponding to an error code.
This function can be called at any point after MIDASstartup has been called.
MIDAS error code for the most recent error.
All
char *MIDASgetErrorMessage(int errorCode)
Gets an error message corresponding to an error code.
This function returns a textual error message corresponding to a MIDAS error code. It can be used for displaying an error message to the user. Use MIDASgetLastError to determine the error code.
This function can be called at any point after MIDASstartup has been called.
Error message string corresponding to the error code.
All
BOOL MIDASinit(void)
Initializes MIDAS Sound System.
None.
This function initializes all MIDAS Sound System components, and sets up the API. Apart from configuration functions, this function must be called before any other MIDAS functions are used.
TRUE if successful, FALSE if not.
All
BOOL MIDASclose(void)
Uninitializes MIDAS Sound System.
None.
This function uninitializes all MIDAS Sound System components, deallocates all resources allocated, and shuts down all MIDAS processing. This function must always be called before exiting under MS-DOS and is also strongly recommended under other operating systems. After this function has been called, no MIDAS function may be called unless MIDAS is initialized again.
TRUE if successful, FALSE if not.
All
BOOL MIDASdetectSD(void)
Attempts to detect the Sound Device to use.
None.
This function attempts to detect the Sound Device that should be used. It is called internally by MIDASinit, and should not normally be called by user programs. Note that the function returns TRUE even if it fails to detect a Sound Device.
TRUE if successful, FALSE if not.
All
BOOL MIDASsetOption(int option, int value)
Sets a MIDAS option.
This function sets a value to a MIDAS option. The different number codes for different options are described above. All MIDAS configuration options must be set with this function before MIDASinit is called.
TRUE if successful, FALSE if not.
All
BOOL MIDASopenChannels(int numChans)
Opens Sound Device channels for sound and music output.
This function opens a specified number of channels for digital sound and music output. The channels opened can be used for playing streams, samples and modules. When MIDASplayModule is used to play modules, it will use the last possible channels for the module, so that the first (numChans - number-of-channels-in-module) channels are available for effects and streams.
If this function has not been called before MIDASplayModule is called, MIDASplayModule will open the channels it needs for module playback. However, if this function has been called, but the number of channels opened is inadequate for the module, MIDASplayModule will return an error and refuse to play the module.
TRUE if successful, FALSE if not.
All
MIDAScloseChannels, MIDASplayModule
BOOL MIDAScloseChannels(void)
Closes Sound Device channels opened with MIDASopenChannels.
None.
This function closes Sound Device channels that were opened with MIDASopenChannels. Note that you may not use this function to close channels that were opened by MIDASplayModule -- MIDASstopModule will do that automatically.
TRUE if successful, FALSE if not.
All
MIDASopenChannels, MIDASplayModule, MIDASstopModule
BOOL MIDASstartBackgroundPlay(DWORD pollRate)
Starts playing music and sound in the background.
This function starts playing sound and music in the background. pollRate controls the target polling rate -- number of polls per second. Polling might not be done at actually the set rate, although usually it will be faster. Under Win32 and Linux, a new thread will be created for playing. Under MS-DOS this function is currently ignored, and background playback starts immediately when MIDAS is initialized.
TRUE if successful, FALSE if not.
All, but see MS-DOS note above.
MIDASstopBackgroundPlay, MIDASpoll
BOOL MIDASstopBackgroundPlay(void)
Stops playing sound and music in the background.
None.
This function stops music and sound background playback that has been started with MIDASstartBackgroundPlay. Under Win32 and Linux, this function also destroys the thread created for playback. Under MS-DOS this function is currently ignored, and background playback starts immediately when MIDAS is initialized.
If background playback has been started with MIDASstartBackgroundPlay, this function bf must be called before the program exits.
TRUE if successful, FALSE if not.
All, but see MS-DOS note above.
MIDASstartBackgroundPlay, MIDASpoll
BOOL MIDASpoll(void)
Polls the MIDAS sound and music player.
None.
This function can be used to poll MIDAS sound and music player manually. It plays music forward, mixes sound data, and sends it to output. When using manual polling, make sure you call MIDASpoll often enough to make sure there are no breaks in sound output -- at least two times during buffer length, preferably four times or more. Under multitasking operating systems such as Win32 and Linux, this may be difficult, so very short buffer sizes can't be used reliably.
Also note that currently this function is not available under MS-DOS. Under MS-DOS, playback is always done in background using the system timer (IRQ 0).
TRUE if successful, FALSE if not.
Win32, Linux
MIDASstartBackgroundPlay, MIDASstopBackgroundPlay
char *MIDASgetVersionString(void)
Gets the current MIDAS version as a string.
None.
This function can be used to determine the MIDAS version being loaded. It returns a text string description of the version. Version numbers are usually of form ``x.y.z'', where ``x'' is the major version number, ``y'' minor version number and ``z'' patch level. In some occasions, ``z'' can be replaced with a textual message such as ``rc1'' for Release Candidate 1. All MIDAS versions with the major and minor version numbers equal have a compatible DLL API, and can be used interchangeably.
MIDAS Sound System version number as a string.
Win32, Linux