Creates a new sample.
HSAMPLE BASS_SampleCreate( DWORD length, DWORD freq, DWORD chans, DWORD max, DWORD flags );
|length||The sample's length, in bytes.|
|freq||The default sample rate.|
|chans||The number of channels... 1 = mono, 2 = stereo, etc.|
|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 is invalid.|
|BASS_ERROR_FORMAT||The sample format is not supported by the device/drivers.|
|BASS_ERROR_MEM||There is insufficient memory.|
|BASS_ERROR_NO3D||Could not initialize 3D support.|
|BASS_ERROR_UNKNOWN||Some other mystery problem!|
Unless the BASS_SAMPLE_SOFTWARE flag is used, the sample will use hardware mixing if hardware resources are available. Use BASS_GetInfo to see if there are hardware mixing resources available, and which sample formats are supported by the hardware. The BASS_SAMPLE_VAM flag allows a sample to be played by both hardware and software, with the decision made when the sample is played rather than when it is loaded. A sample's VAM options are set via BASS_SampleSetInfo.
To play a sample, first a channel must be obtained using BASS_SampleGetChannel, which can then be played using 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_StreamCreate.
HSAMPLE sample = BASS_SampleCreate(256, 440 * 64, 1, 1, BASS_SAMPLE_LOOP | BASS_SAMPLE_OVER_POS); // create sample short data; // data buffer int a; for (a = 0; a < 128; a++) data[a] = (short)(32767.0 * sin(a * 6.283185 / 64)); // sine wave BASS_SampleSetData(sample, data); // set the sample's data