BASS_SampleLoad

Loads a WAV sample.

HSAMPLE WINAPI BASS_SampleLoad(
    BOOL mem,
    void *file,
    DWORD offset,
    DWORD length,
    DWORD max,
    DWORD flags
);

Parameters
memTRUE = load the sample from memory.
fileFilename (mem = FALSE) or a memory location (mem = TRUE).
offsetFile offset to load the sample from (only used if mem = FALSE).
lengthData length (only used if mem = FALSE)... 0 = use all data up to the end of file. If length over-runs the end of the file, it'll automatically be lowered to the end of the file.
maxMaximum 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).
flagsA combination of these flags.
BASS_SAMPLE_LOOPLooped? Note that only complete sample loops are allowed by DirectSound (ie. you can't loop just part of a sample).
BASS_SAMPLE_SOFTWAREForce the sample to not use hardware mixing.
BASS_SAMPLE_VAM
requires DirectX 7.0 or above
Enables the DX7 voice allocation and management features on the sample, which allows the sample to be played in software or hardware. Do not use together with the BASS_SAMPLE_SOFTWARE flag.
BASS_SAMPLE_3DUse 3D functionality. This is ignored if BASS_DEVICE_3D wasn't specified when calling BASS_Init.
BASS_SAMPLE_MUTEMAXMute the sample when it is at (or beyond) it's max distance (3D samples only).
BASS_SAMPLE_OVER_VOLOverride: the channel with the lowest volume is overriden.
BASS_SAMPLE_OVER_POSOverride: the longest playing channel is overriden.
BASS_SAMPLE_OVER_DISTOverride: the channel furthest away (from the listener) is overriden (3D samples only).

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_INITBASS_Init has not been successfully called.
BASS_ERROR_FILEOPENThe file could not be opened.
BASS_ERROR_FORMATThe file's format is not recognised/supported.
BASS_ERROR_MEMThere is insufficent memory.
BASS_ERROR_NO3DCouldn't initialize 3D support for the sample.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks
WAV files can be in standard Windows PCM format or they can be compressed with any CODEC, but the CODEC is required to be installed on the user's computer for the WAV to be decoded. So, you should either distribute the CODEC with your software, or use a CODEC that comes with Windows (eg. Microsoft ADPCM).

The BASS_SAMPLE_VAM flag is ignored if the version of DirectX used is less than 7.0, you can check which version of DirectSound is being used with BASS_GetInfo.

Use BASS_SampleGetInfo and BASS_SampleSetInfo to set the default attributes (volume, etc...) of the sample.

See also
BASS_SampleCreate, BASS_SampleFree, BASS_SampleGetInfo, BASS_SamplePlay, BASS_SamplePlay3D, BASS_SamplePlay3DEx, BASS_SamplePlayEx