This overload uses Unicode file names! A BASS_UNICODE flag will automatically be added.
Assembly: Bass.Net (in Bass.Net.dll) Version: 22.214.171.124
public static int BASS_SampleLoad( string file, long offset, int length, int max, BASSFlag flags )
Public Shared Function BASS_SampleLoad ( file As String, offset As Long, length As Integer, max As Integer, flags As BASSFlag ) As Integer
- Type: SystemString
The file name to load the sample from.
- Type: SystemInt64
File offset to load the sample from.
- Type: SystemInt32
Data length... 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.
- Type: SystemInt32
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).
- Type: Un4seen.BassBASSFlag
A combination of these flags (see BASSFlag):
BASS_SAMPLE_FLOAT Use 32-bit floating-point sample data (not really recommended for samples). WDM drivers are required to use this flag in Windows. See Floating-point channels for more info. BASS_SAMPLE_LOOP Looped? Note that only complete sample loops are allowed, you can't loop just a part of the sample. More fancy looping can be achieved by streaming the file. BASS_SAMPLE_MONO Convert the sample (MP3/MP2/MP1 only) to mono, if it's not already. This flag is automatically applied if BASS_DEVICE_MONO was specified when calling. BASS_SAMPLE_SOFTWARE Force the sample to not use hardware mixing. BASS_SAMPLE_VAM requires DirectX 7 or above: Enables the DX7 voice allocation and management features on the sample, which allows the sample to be played in software or hardware. This flag is ignored if the BASS_SAMPLE_SOFTWARE flag is also specified. BASS_SAMPLE_3D Use 3D functionality. This is ignored if BASS_DEVICE_3D wasn't specified when calling. 3D samples must be mono. BASS_SAMPLE_MUTEMAX Mute the sample when it is at (or beyond) it's max distance (3D samples only). BASS_SAMPLE_OVER_VOL Override: the channel with the lowest volume is overriden. BASS_SAMPLE_OVER_POS Override: the longest playing channel is overriden. BASS_SAMPLE_OVER_DIST Override: the channel furthest away (from the listener) is overriden (3D samples only). BASS_UNICODE file is a Unicode (16-bit characters) filename (no need to set this for this overload).
Return ValueType: Int32
If successful, the loaded sample's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.
Additional format support is available via the plugin system (see BASS_PluginLoad(String)).
Unless the BASS_SAMPLE_SOFTWARE flag is used, the sample will use hardware mixing if hardware resources are available. Use BASS_GetInfo(BASS_INFO) 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's loaded. A sample's VAM options are set via BASS_SampleSetInfo(Int32, BASS_SAMPLE).
If you want to play a large or one-off sample, then it would probably be better to stream it instead with BASS_StreamCreateFile(String, Int64, Int64, BASSFlag).
|BASS_ERROR_INIT||has not been successfully called.|
|BASS_ERROR_NOTAVAIL||Sample functions are not available when using the "no sound" device.|
|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_CODEC||The file uses a codec that's not available/supported. This can apply to WAV and AIFF files, and also MP3 files when using the "MP3-free" BASS version.|
|BASS_ERROR_FORMAT||The sample format is not supported by the device/drivers. If the sample is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported.|
|BASS_ERROR_MEM||There is insufficient memory.|
|BASS_ERROR_NO3D||Could not initialize 3D support.|
|BASS_ERROR_UNKNOWN||Some other mystery problem!|
The BASS_SAMPLE_VAM flag requires DirectX 7 (or above). Away from Windows, all mixing is done in software (by BASS), so the BASS_SAMPLE_SOFTWARE flag is unnecessary.
On Windows and Windows CE, ACM codecs are supported with compressed WAV files. On iOS and OSX, CoreAudio codecs are supported, adding support for any file formats that have a codec installed.
Dim sample As Integer = Bass.BASS_SampleLoad("test.wav", 0L.ToUInt32(), 0, 1, BASSFlag.BASS_DEFAULT) Dim channel As Integer = Bass.BASS_SampleGetChannel(sample, False) ' get a sample channel Bass.BASS_ChannelPlay(channel, False) ' play it
int sample = Bass.BASS_SampleLoad("test.wav", 0L, 0, 1, BASSFlag.BASS_DEFAULT); int channel = Bass.BASS_SampleGetChannel(sample, false); // get a sample channel Bass.BASS_ChannelPlay(channel, false); // play it