This section describes all functions available for MIDAS stream playback.
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
DWORD MIDASgetStreamBytesBuffered(MIDASstreamHandle stream)
Gets the number of bytes of stream currently buffered.
This function returns the number of bytes of sound data currently stored in the stream buffer. It can be used to monitor the stream playback, and possibly prepare to feed extra data if the figure gets too low.
The number of bytes of sound data currently buffered.
Win32, Linux
BOOL MIDASpauseStream(MIDASstreamHandle stream)
Pauses stream playback.
This function pauses the playback of a stream. When a stream is paused, stream data can be fed normally with MIDASfeedStreamData, but nothing will actually be played. Playback can be resumed with MIDASresumeStream.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASresumeStream, MIDASfeedStreamData
MIDASstreamHandle MIDASplayStreamFile(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. The file must contain raw audio data with no headers -- to play WAVE files, use MIDASplayStreamWaveFile. The function 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. A Sound Device channel will be automatically allocated for the stream.
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
MIDASplayStreamWaveFile, MIDASstopStream
MIDASstreamHandle MIDASplayStreamWaveFile(char *fileName, unsigned bufferLength, int loopStream)
Starts playing a digital audio stream from a RIFF WAVE file.
This function starts playing a digital audio stream from a file. The file must be a standard RIFF WAVE (.wav) sound file containing raw PCM sound data -- compressed WAVE files are not supported. The function 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. A Sound Device channel will be automatically allocated for the stream.
The stream buffer length should be at least around 500ms if the stream file is being read from a disk, to avoid breaks in stream playback
MIDAS stream handle if successful, NULL if failed.
Win32, Linux
MIDASplayStreamFile, MIDASstopStream
MIDASstreamHandle MIDASplayStreamPolling(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 MIDASfeedStreamData. The stream will continue playing until it is stopped with MIDASstopStream. This function will automatically allocate a Sound Device channel for the stream.
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
BOOL MIDASresumeStream(MIDASstreamHandle stream)
Resumes stream playback after pause.
This function resumes the playback of a stream that has been paused with MIDASpauseStream.
TRUE if successful, FALSE if not.
Win32, Linux
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
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 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, closes the stream file (if playing from a file) and deallocates the stream playback channel.
TRUE if successful, FALSE if not.
Win32, Linux
MIDASplayStreamFile, MIDASplayStreamPolling