BASS_StreamCreate

Creates a user sample stream.

HSTREAM BASS_StreamCreate(
    DWORD freq,
    DWORD chans,
    DWORD flags,
    STREAMPROC *proc,
    void *user
);

Parameters

freqThe default sample rate. The sample rate can be changed using BASS_ChannelSetAttribute.
chansThe number of channels... 1 = mono, 2 = stereo, 4 = quadraphonic, 6 = 5.1, 8 = 7.1.
flagsA combination of these flags.
BASS_SAMPLE_8BITSUse 8-bit resolution. If neither this or the BASS_SAMPLE_FLOAT flags are specified, then the stream is 16-bit.
BASS_SAMPLE_FLOATUse 32-bit floating-point sample data. See Floating-point channels for info.
BASS_SAMPLE_3DEnable 3D functionality. The stream must be mono (chans=1). The SPEAKER flags cannot be used together with this flag.
BASS_STREAM_AUTOFREEAutomatically free the stream when playback ends.
BASS_STREAM_DECODEDecode the sample data, without playing it. Use BASS_ChannelGetData to retrieve decoded sample data. The BASS_SAMPLE_3D, BASS_STREAM_AUTOFREE and SPEAKER flags cannot be used together with this flag.
BASS_SPEAKER_xxxSpeaker assignment flags. These flags have no effect when the stream is more than stereo.
procThe user defined stream writing function, or one of the following.
STREAMPROC_DEVICECreate a "dummy" stream for the device's final output mix. This allows DSP/FX to be applied to all channels that are playing on the device, rather than individual channels. DSP/FX parameter change latency is also reduced because channel playback buffering is avoided. The stream is created with the device's current output sample format; the freq, chans, and flags parameters are ignored. It will always be floating-point.
STREAMPROC_DUMMYCreate a "dummy" stream. A dummy stream does not have any sample data of its own, but a decoding dummy stream (with BASS_STREAM_DECODE flag) can be used to apply DSP/FX processing to any sample data, by setting DSP/FX on the stream and feeding the data through BASS_ChannelGetData. The dummy stream should have the same sample format as the data being fed through it.
STREAMPROC_PUSHCreate a "push" stream. Instead of BASS pulling data from a STREAMPROC function, data is pushed to BASS via BASS_StreamPutData.
userUser instance data to pass to the callback function. Unused when creating a dummy or push stream.

Return value

If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_INITBASS_Init has not been successfully called.
BASS_ERROR_NOTAVAILThe BASS_STREAM_AUTOFREE flag cannot be combined with the BASS_STREAM_DECODE flag.
BASS_ERROR_FORMATThe sample format is not supported.
BASS_ERROR_SPEAKERThe specified SPEAKER flags are invalid.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_NO3DCould not initialize 3D support.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks

Sample streams allow any sample data to be played through BASS, and are particularly useful for playing a large amount of sample data without requiring a large amount of memory. If you wish to play a sample format that BASS does not support, then you can create a stream and decode the sample data into it.

Each device has a single final output mix stream, which can be used to apply DSP/FX to the device output. Multiple requests for a final output mix stream (using STREAMPROC_DEVICE) on the same device will receive the same stream handle, which cannot be freed via BASS_StreamFree or BASS_ChannelFree. It will automatically be freed if the device's output format (sample rate or channel count) changes. A BASS_SYNC_FREE sync can be set via BASS_ChannelSetSync to be notified when this happens, at which point a new stream with the device's new format could be created.

BASS can automatically stream MP3, MP2, MP1, OGG, WAV and AIFF files, using BASS_StreamCreateFile, and also from HTTP and FTP servers, using BASS_StreamCreateURL. BASS_StreamCreateFileUser allows streaming from other sources too.

See also

BASS_ChannelPlay, BASS_ChannelSetAttribute, BASS_ChannelSetDSP, BASS_ChannelSetFX, BASS_ChannelSetLink, BASS_StreamCreateFile, BASS_StreamCreateFileUser, BASS_StreamCreateURL, BASS_StreamFree, BASS_StreamPutData, STREAMPROC callback, BASS_CONFIG_BUFFER