Creates a mixer stream.
HSTREAM BASS_Mixer_StreamCreate( DWORD freq, DWORD chans, DWORD flags );
freq | The sample rate of the mixer output. | ||||||||||||||||||||||||
chans | The number of channels... 1 = mono, 2 = stereo, 4 = quadraphonic, 6 = 5.1, 8 = 7.1. | ||||||||||||||||||||||||
flags | Any combination of these flags.
|
BASS_ERROR_INIT | BASS_Init has not been successfully called. |
BASS_ERROR_NOTAVAIL | The BASS_STREAM_AUTOFREE flag cannot be combined with the BASS_STREAM_DECODE flag. |
BASS_ERROR_FORMAT | The sample format is not supported. |
BASS_ERROR_SPEAKER | The specified SPEAKER flags are invalid. |
BASS_ERROR_MEM | There is insufficient memory. |
BASS_ERROR_NO3D | Could not initialize 3D support. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
If the mixer output is being played, there will be some delay in the effect of adding/removing source channels or changing their attributes being heard, due to buffering. This latency can be reduced via the BASS_ATTRIB_BUFFER attribute. The playback buffer can be flushed by calling BASS_ChannelPlay (restart = TRUE) or BASS_ChannelSetPosition (pos = 0). That can also be done to restart a mixer that has ended.
Seeking in a mix via BASS_ChannelSetPosition directly is not possible, but seeking can be implemented by setting the position of each source to where it would be at the seek position, and then flushing the mixer's playback buffer (see above) if required.
Unless the BASS_MIXER_END flag is specified, a mixer stream will never end. When there are no sources (or the sources have ended/stalled), it will produce no output until there is an active source. That is unless the BASS_MIXER_NONSTOP flag is used, in which case it will produce silent output while there are no active sources. The BASS_MIXER_END and BASS_MIXER_NONSTOP flags can be toggled at any time, using BASS_ChannelFlags.
A queued mixer, with the BASS_MIXER_QUEUE flag set, will play its sources one after another in the order that they were added, without a gap unless a delay is specified with BASS_Mixer_StreamAddChannelEx. After a source has been played, it will be removed from the mixer. Queueing can be enabled or disabled at any time using BASS_ChannelFlags. If it is disabled that way then all currently queued sources will start immediately, and if it is enabled then any current sources will continue to play normally and newly queued sources will start when the current ones have all ended. A BASS_SYNC_MIXER_QUEUE sync can be set to be notified whenever a source is dequeued.
Besides mixing channels, a mixer stream can be used for sample rate conversion. In that case the freq parameter would be set to the new sample rate, and the source channel's attributes would be left at their defaults. A mixer stream can also be used to downmix, upmix and generally rearrange channels, using the matrix mixing features.
By default, a mixer is single-threaded, meaning it will process its sources one at a time. When there are multiple sources and multiple CPU cores available, it may be advantageous to enable multiple threads via the BASS_ATTRIB_MIXER_THREADS setting.