This section describes all functions available for MIDAS stream playback.
MIDASstreamHandle MIDASplayStreamFile(unsigned channel, char *fileName, unsigned sampleType, unsigned sampleRate, unsigned bufferLength, int loopStream)
Starts playing a digital audio stream from a file.
This function starts playing a digital audio stream from a file. It allocates the stream buffer, creates a new thread that will read sample data from the file to the stream buffer, and starts the Sound Device to play the stream. The stream will continue playing until it is stopped with MIDASstopStream. When a stream is being played on a channel, that channel may not be used for other purposes.
The stream buffer length should be at least around 500ms if the stream file is being read from a disc, to avoid breaks in stream playback
MIDAS stream handle if successful, NULL if failed.
Win32, Linux
BOOL MIDASstopStream(MIDASstreamHandle stream)
Stops playing a digital audio stream.
This function stops playing a digital audio stream. It stops the stream player thread, deallocates the stream buffer and closes the stream file. The stream playback channel can then be used for other purposes.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASstreamHandle MIDASplayStreamPolling(unsigned channel, unsigned sampleType, unsigned sampleRate, unsigned bufferLength)
Starts playing a digital audio stream in polling mode.
This function starts playing a digital audio stream in polling mode. It allocates and empty stream buffer, and starts the Sound Device to play the stream. Sample data can be fed to the stream buffer with MIDASfeedSteramData. The stream will continue playing until it is stopped with MIDASstopStream. When a stream is being played on a channel, that channel may not be used for other purposes.
To avoid breaks in playback, the stream buffer size should be at least twice the expected polling period. That is, if you will be feeding data 5 times per second (every 200ms), the buffer should be at least 400ms long.
MIDAS stream handle if successful, NULL if failed.
Win32, Linux
MIDASstopStream, MIDASfeedStreamData
unsigned MIDASfeedStreamData(MIDASstreamHandle stream, unsigned char *data, unsigned numBytes, BOOL feedAll);
Feeds sound data to a digital audio stream buffer.
This function is used to feed sample data to a stream that has been started with MIDASplayStreamPolling. Up to numBytes bytes of new sample data from *data will be copied to the stream buffer, and the stream buffer write position is updated accordingly. The function returns the number of bytes of sound data actually used. If feedAll is TRUE, the function will block the current thread of execution until all sound data is used.
The number of bytes of sound data actually used.
Win32, Linux
BOOL MIDASsetStreamRate(MIDASstreamHandle stream, unsigned rate);
Changes stream playback sample rate.
This function changes the playback sample rate for a stream that is being played. The initial sample rate is given as an argument to the function that starts stream playback.
Note that the stream playback buffer size is calculated based on the initial sample rate, so the stream sample rate should not be changed very far from that figure. In particular, playback sample rates over two times the initial value may cause breaks in stream playback. Too low rates, on the other hand, will increase latency.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASsetStreamVolume, MIDASsetStreamPanning
BOOL MIDASsetStreamVolume(MIDASstreamHandle stream, unsigned volume);
Changes stream playback volume.
This function changes the playback volume for a stream that is being played. The initial volume is 64 (maximum).
TRUE if successful, FALSE if not.
Win32, Linux
MIDASsetStreamRate, MIDASsetStreamPanning
BOOL MIDASsetStreamPanning(MIDASstreamHandle stream, int panning);
Changes stream panning position.
This function changes the panning position for a stream that is being played. The initial volume is 0 (center). See description of enum MIDASpanning for information about the panning position values.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASsetStreamVolume, MIDASsetStreamRate