next up previous contents
Next: About this document Up: 5 Stream playback Previous: Data types

Functions

This section describes all functions available for MIDAS stream playback.



 

5.3.1 MIDASplayStreamFile

 
MIDASstreamHandle MIDASplayStreamFile(unsigned channel,
    char *fileName, unsigned sampleType, unsigned sampleRate,
    unsigned bufferLength, int loopStream)

Starts playing a digital audio stream from a file.

Input

channel
The channel number the stream will be played on
fileName
Stream file name
sampleType
Stream sample type, see enum MIDASsampleTypes
sampleRate
Stream sample rate
bufferLength
Stream playback buffer length in milliseconds
loopStream
1 if the stream should be looped, 0 if not

Description

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

Return value

MIDAS stream handle if successful, NULL if failed.

Operating systems

Win32, Linux

See also

MIDASstopStream



 

5.3.2 MIDASstopStream

 
BOOL MIDASstopStream(MIDASstreamHandle stream)

Stops playing a digital audio stream.

Input

stream
The stream that will be stopped

Description

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.

Return value

TRUE if successful, FALSE if not.

Operating systems

Win32, Linux

See also

MIDASplayStream



 

5.3.3 MIDASplayStreamPolling

 
MIDASstreamHandle MIDASplayStreamPolling(unsigned channel,
    unsigned sampleType, unsigned sampleRate,
    unsigned bufferLength)

Starts playing a digital audio stream in polling mode.

Input

channel
The channel number the stream will be played on
sampleType
Stream sample type, see enum MIDASsampleTypes
sampleRate
Stream sample rate
bufferLength
Stream playback buffer length in milliseconds

Description

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.

Return value

MIDAS stream handle if successful, NULL if failed.

Operating systems

Win32, Linux

See also

MIDASstopStream, MIDASfeedStreamData



 

5.3.4 MIDASfeedStreamData

 
unsigned MIDASfeedStreamData(MIDASstreamHandle stream,
    unsigned char *data, unsigned numBytes, BOOL feedAll);

Feeds sound data to a digital audio stream buffer.

Input

stream
The stream that will play the data
data
Pointer to sound data
numBytes
Number of bytes of sound data available
feedAll
TRUE if the function should block until all sound data can be fed

Description

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.

Return value

The number of bytes of sound data actually used.

Operating systems

Win32, Linux

See also

MIDASplayStreamPolling



 

5.3.5 MIDASsetStreamRate

 
BOOL MIDASsetStreamRate(MIDASstreamHandle stream,
    unsigned rate);

Changes stream playback sample rate.

Input

stream
Stream handle for the stream
rate
New playback sample rate for the stream, in Hertz.

Description

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.

Return value

TRUE if successful, FALSE if not.

Operating systems

Win32, Linux

See also

MIDASsetStreamVolume, MIDASsetStreamPanning



 

5.3.6 MIDASsetStreamVolume

 
BOOL MIDASsetStreamVolume(MIDASstreamHandle stream,
    unsigned volume);

Changes stream playback volume.

Input

stream
Stream handle for the stream
volume
New volume for the stream, 0-64.

Description

This function changes the playback volume for a stream that is being played. The initial volume is 64 (maximum).

Return value

TRUE if successful, FALSE if not.

Operating systems

Win32, Linux

See also

MIDASsetStreamRate, MIDASsetStreamPanning



 

5.3.7 MIDASsetStreamPanning

 
BOOL MIDASsetStreamPanning(MIDASstreamHandle stream,
    int panning);

Changes stream panning position.

Input

stream
Stream handle for the stream
panning
New panning position for the stream

Description

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.

Return value

TRUE if successful, FALSE if not.

Operating systems

Win32, Linux

See also

MIDASsetStreamVolume, MIDASsetStreamRate


next up previous contents
Next: About this document Up: 5 Stream playback Previous: Data types

Petteri Kangaslampi
Mon Jan 27 00:19:24 EET 1997