BASS_SampleLoad
Loads a WAV, AIFF, MP3, MP2, MP1, OGG or plugin supported sample.
HSAMPLE BASS_SampleLoad(
DWORD filetype,
void *file,
QWORD offset,
DWORD length,
DWORD max,
DWORD flags
);
Parameters
filetype | One of the following.
BASS_FILE_NAME | file is a filename. This is the default if none is specified.
| BASS_FILE_MEM | file points to a memory block. The entire file will be preloaded, so the memory does not need to stay valid beyond this function call.
| BASS_FILE_HANDLE | file is a file handle (HANDLE) on Windows or a file descriptor (int) on other platforms, and should be seekable. It will remain open after this function returns.
|
|
file | The file as described by filetype.
|
offset | File offset to begin reading from.
|
length | Maximum read length... 0 = 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_SAMPLE_FLOAT | Use 32-bit floating-point sample data. Not really recommended for samples as it (at least) doubles the memory usage.
| BASS_SAMPLE_LOOP | Loop the sample.
| BASS_SAMPLE_MONO | Convert the sample to mono, if it is not already mono. This flag is automatically applied if BASS_DEVICE_MONO was specified when calling BASS_Init.
| BASS_SAMPLE_3D | Enable 3D functionality. The sample must be mono.
| BASS_SAMPLE_MUTEMAX | Mute the sample when it is at (or beyond) its max distance (3D samples only).
| BASS_SAMPLE_OVER_VOL | Override: the channel with the lowest volume is overridden.
| BASS_SAMPLE_OVER_POS | Override: the longest playing channel is overridden.
| BASS_SAMPLE_OVER_DIST | Override: the channel furthest away (from the listener) is overridden (3D samples only).
| BASS_UNICODE | file is in UTF-16 form. Otherwise it is ANSI on Windows and UTF-8 on other platforms. This flag is ignored when file is not a filename.
|
|
Return value
If successful, the loaded sample's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.
Error codes
BASS_ERROR_INIT | BASS_Init has not been successfully called.
|
BASS_ERROR_ILLPARAM | At least one of filetype, length, max is invalid. length cannot be 0 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!
|
Remarks
This function supports the same file formats as BASS_StreamCreateFile does, including those supported via the plugin system.
To play a sample, first a channel must be obtained using BASS_SampleGetChannel, which can then be played using BASS_ChannelStart or BASS_ChannelPlay.
If you want to play a large or one-off sample, then it would probably be better to stream it instead with BASS_StreamCreateFile.
Platform-specific
On Android, when using Java, file may be one of the following: String, ByteBuffer, ParcelFileDescriptor (Android 3.1 and above), BASS.Asset. A ParcelFileDescriptor will remain open after this function returns.
See also
BASS_SampleCreate, BASS_SampleFree, BASS_SampleGetChannel, BASS_SampleGetInfo, BASS_StreamCreateFile