This section describes all function available in the MIDAS DLL API. Not all of these functions are available in all operating systems, so the description for each function also lists the systems in which the function is available.
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
BOOL MIDASinit(void)
Initializes MIDAS Sound System.
None.
This function initializes all MIDAS Sound System components, and sets up the DLL API. Apart from configuration functions, this function must be called before any other MIDAS functions are used.
TRUE if successful, FALSE if not.
All
MIDASsetOption, MIDASclose
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
MIDASinit
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
MIDASinit
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.
TRUE if successful, FALSE if not.
All
MIDASinit
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 - module->numChans) channels are available for effects and streams.
If this function has not been called before MIDASplayModule, 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
MIDASmodule MIDASloadModule(char *fileName)
Loads a module file into memory.
This function loads a module file into memory. It checks the module format based on the module file header, and invokes the correct loader to load the module into memory in GMPlayer internal format. The module can then be played using MIDASplayModule, and deallocated from memory with MIDASfreeModule.
Module handle if successful, NULL if not.
All
MIDASplayModule, MIDASfreeModule
BOOL MIDASplayModule(MIDASmodule module, int numEffectChannels)
Starts playing a module.
This functions starts playing a module that has been previously loaded with MIDASloadModule. If channels have not been previously opened using MIDASopenChannels, this function opens the channels necessary to play the module, and if numEffectChannels is nonzero, it opens additional channels for sound effects. The module is always played on the last possible channels, so the first numEffectChannels are available for effects and streams.
Note! Currently only one module can be played at a time.
TRUE if successful, FALSE if not.
All
MIDASloadModule, MIDASstopModule, MIDASopenChannels
BOOL MIDASstopModule(MIDASmodule module)
Stops playing a module.
This function stops playing a module that has been played with MIDASplayModule. If the channels were opened automatically by MIDASplayModule, this function will close them, but if they were opened manually with MIDASopenChannels, they will be left open.
TRUE if successful, FALSE if not.
All
MIDASplayModule, MIDASopenChannels
BOOL MIDASfreeModule(MIDASmodule module)
Deallocates a module.
This function deallocates a module loaded with MIDASloadModule. It should be called to free unused modules from memory, after they are no longer being played, to avoid memory leaks.
TRUE if successful, FALSE if not.
All
MIDASloadModule
BOOL MIDASstartPlayThread(DWORD pollPeriod)
Starts polling MIDAS in a thread.
This function starts polling MIDAS Sound System in a separate thread. It creates a new thread that will run in the background, polling MIDAS periodically, with a delay of pollPeriod milliseconds between two successive polls.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASstopPlayThread
BOOL MIDASstopPlayThread(void)
Stops polling MIDAS in a thread.
None.
This function stops polling MIDAS in a thread, and destroys the polling thread. The thread must have been previously created with MIDASstartPlayThread.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASstartPlayThread
MIDASsample MIDASloadRawSample(char *filename, int sampleType, int loopSample)
Loads a raw sound effect sample.
This function loads a sound effect sample into memory and adds it to the Sound Device. The sample file must contain just the raw sample data, and all of it will be loaded into memory. If loopSample is 1, the whole sample will be looped. After the sample has been loaded, it can be played using MIDASplaySample, and it should be deallocated with MIDASfreeSample after it is no longer used.
Sample handle if successful, NULL if failed.
All
MIDASplaySample, MIDASfreeSample
BOOL MIDASfreeSample(MIDASsample sample)
Deallocates a sound effect sample.
This function deallocates a sound effect sample that has been previously loaded with MIDASloadRawSample. It removes the sample from the Sound Device and deallocates the memory used. This function may not be called if the sample is still being played.
TRUE if successful, FALSE if not.
All
MIDASloadRawSample
BOOL MIDASsetAutoEffectChannels(unsigned firstChannel, unsigned numChannels)
Sets the range of channels that can be used as automatic effect channels.
This function is used to set the range of channels that can be used as automatic effect channels by MIDASplaySample. When MIDASplaySample is passed MIDAS_CHANNEL_AUTO as the channel number, it will use one of these automatic channels to play the sound.
TRUE if successful, FALSE if not.
All
MIDASplaySample
MIDASsamplePlayHandle MIDASplaySample(MIDASsample sample, unsigned channel, int priority, unsigned rate, unsigned volume, int panning)
Plays a sound effect sample.
This function is used to play a sound effect sample on a given channel. The sample will receive as initial parameters the values passed as arguments, and playing the sample will be started. If channel is MIDAS_CHANNEL_AUTO, the channel will be selected automatically. The sample playing priority is used to choose the channel the sample will be played on in this case.
This function returns a sample playing handle, that can later be used to stop the sample or change its parameters. This makes it possible to refer to samples without knowing the exact channel they are played on.
Sample playing handle if successful, NULL if failed.
All
MIDASstopSample, MIDASsetSampleRate, MIDASsetSampleVolume, MIDASsetSamplePanning, MIDASsetSamplePriority
BOOL MIDASstopSample(MIDASsamplePlayHandle sample)
Stops playing a sample.
This function stops playing a sound effect sample started with MIDASplaySample. Playing the sound will stop, and the channel is freed for other samples to use.
TRUE if successful, FALSE if not.
All
MIDASplaySample
BOOL MIDASsetSampleRate(MIDASsamplePlayHandle sample, unsigned rate)
Changes the sample rate for a sound effect sample.
This function changes the sample rate for a sound effect sample that is being played.
TRUE if successful, FALSE if not.
All
MIDASplaySample
BOOL MIDASsetSampleVolume(MIDASsamplePlayHandle sample, unsigned volume)
Changes the volume for a sound effect sample.
This function changes the volume for a sound effect sample that is being played.
TRUE if successful, FALSE if not.
All
MIDASplaySample
BOOL MIDASsetSamplePanning(MIDASsamplePlayHandle sample, int panning)
Changes the panning position of a sound effect sample.
This function changes the panning position of a sound effect sample that is being played. See description of enum MIDASpanning for information about the panning position values.
TRUE if successful, FALSE if not.
All
MIDASplaySample
BOOL MIDASsetSamplePriority(MIDASsamplePlayHandle sample, int priority)
Changes the playing priority of a sound effect sample.
This function changes the playing priority a sound effect sample that is being played.
TRUE if successful, FALSE if not.
All
MIDASplaySample