Assembly: Bass.Net (in Bass.Net.dll) Version: 220.127.116.11
[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)] public static int BASS_ChannelGetData( int handle, short buffer, int length )
<DllImportAttribute("bass.dll", CharSet := CharSet.Unicode>] Public Shared Function BASS_ChannelGetData ( handle As Integer, <OutAttribute> buffer As Short(), length As Integer ) As Integer
public: [DllImportAttribute(L"bass.dll", CharSet = CharSet::Unicode)] static int BASS_ChannelGetData( int handle, [InAttribute] [OutAttribute] array<short>^ buffer, int length )
[<DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)>] static member BASS_ChannelGetData : handle : int * buffer : int16 byref * length : int -> int
- Type: SystemInt32
The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD.
- Type: SystemInt16
The array (short) to receive the data, e.g. when creating the channel stream with default setting, meaning 16-bit samples!
- Type: SystemInt32
Number of bytes wanted, and/or the following flags (BASSData):
BASS_DATA_AVAILABLE Query the amount of data the channel has buffered. This flag is primarily of use when recording, and can't be used with decoding channels as they do not have playback buffers. buffer can be when using this flag.
Return ValueType: Int32
If an error occurs, -1 is returned, use BASS_ErrorGetCode to get the error code.
When requesting sample data, the number of bytes written to buffer will be returned (not necessarily the same as the number of bytes read).
When using the BASS_DATA_AVAILABLE flag, the number of bytes in the channel's buffer is returned.
This function can only return as much data as has been written to the channel's buffer, so it may not always be possible to get the amount of data requested, especially if you request large amounts. If you really do need large amounts, then increase the buffer lengths (BASS_CONFIG_BUFFER). The BASS_DATA_AVAILABLE flag can be used to check how much data a channel's buffer contains at any time, including when stopped or stalled.
When requesting data from a "decoding channel" (BASS_STREAM_DECODE or BASS_MUSIC_DECODE was used at creation), there are no intermediate buffers involved, so as much data as is available can be decoded in one go.
When retrieving sample data, the returned data is in the standard Windows PCM format: 8-bit samples are unsigned, 16-bit samples are signed, 32-bit floating-point samples range from -1 to 1 (not clipped, so can actually be outside this range). That's unless the BASS_DATA_FLOAT flag is used, in which case, the sample data will be converted to 32-bit floating-point (if it isn't already).
This function is most useful if you wish to visualize (eg. spectrum analyze) the sound.
|BASS_ERROR_HANDLE||handle is not a valid channel.|
|BASS_ERROR_ENDED||The channel has reached the end.|
|BASS_ERROR_NOTAVAIL||The BASS_DATA_AVAILABLE flag was used with a decoding channel.|
|BASS_ERROR_BUFLOST||Should not happen... check that a valid window handle was used with.|
' a 30ms window in bytes to be filled with sample data Dim length As Integer = CInt(Bass.BASS_ChannelSeconds2Bytes(channel, 0.03)) ' first we need a mananged object where the sample data should be placed ' length is in bytes, so the number of floats to process is length/2 Dim data(length/2 -1) As Short ' get the sample data length = Bass.BASS_ChannelGetData(channel, data, length)
// a 30ms window in bytes to be filled with sample data int length = (int)Bass.BASS_ChannelSeconds2Bytes(channel, 0.03); // first we need a mananged object where the sample data should be placed // length is in bytes, so the number of shorts to process is length/2 short data = new short[length/2]; // get the sample data length = Bass.BASS_ChannelGetData(channel, data, length);