Loads a WAV, AIFF, MP3, MP2, MP1, OGG or plugin supported sample.
HSAMPLE BASS_SampleLoad( BOOL mem, void *file, QWORD offset, DWORD length, DWORD max, DWORD flags );
mem | TRUE = load the sample from memory. | ||||||||||||||||||
file | Filename (mem = FALSE) or a memory location (mem = TRUE). | ||||||||||||||||||
offset | File offset to load the sample from (only used if mem = FALSE). | ||||||||||||||||||
length | Data length... 0 = use all data up to the end of file (if mem = FALSE). If length over-runs the end of the file, it will automatically be lowered to the end of the file. | ||||||||||||||||||
max | Maximum number of simultaneous playbacks... 1 (min) - 65535 (max). Use one of the BASS_SAMPLE_OVER flags to choose the override decider, in the case of there being no free channel available for playback (ie. the sample is already playing max times). | ||||||||||||||||||
flags | A combination of these flags.
|
BASS_ERROR_INIT | BASS_Init has not been successfully called. |
BASS_ERROR_ILLPARAM | max and/or length is invalid. The length must be specified when loading from memory. |
BASS_ERROR_FILEOPEN | The file could not be opened. |
BASS_ERROR_FILEFORM | The file's format is not recognised/supported. |
BASS_ERROR_NOTAUDIO | The file does not contain audio, or it also contains video and videos are disabled. |
BASS_ERROR_CODEC | The file uses a codec that is not available/supported. This can apply to WAV and AIFF files. |
BASS_ERROR_FORMAT | The sample format is not supported. |
BASS_ERROR_EMPTY | The file does not contain any sample data. |
BASS_ERROR_MEM | There is insufficient memory. |
BASS_ERROR_NO3D | Could not initialize 3D support. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
To play a sample, first a channel must be obtained using BASS_SampleGetChannel, which can then be played using BASS_ChannelStart or BASS_ChannelPlay.
After loading a sample from memory (mem = TRUE), the memory can safely be discarded, as a copy is made.
If you want to play a large or one-off sample, then it would probably be better to stream it instead with BASS_StreamCreateFile.