Assembly: Bass.Net (in Bass.Net.dll) Version: 126.96.36.199
[DllImportAttribute("bass")] public static int BASS_ChannelGetData( int handle, byte buffer, int length )
<DllImportAttribute("bass">] Public Shared Function BASS_ChannelGetData ( handle As Integer, <OutAttribute> buffer As Byte(), length As Integer ) As Integer
- Type: SystemInt32
The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD.
- Type: SystemByte
The array (byte) to receive the data, e.g. when creating the channel with BASS_SAMPLE_8BITS!
- 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_FLOAT flag).
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.|
Dim length As Integer = CInt(Bass.BASS_ChannelSeconds2Bytes(channel, 0.03)) Dim data(length - 1) As Byte length = Bass.BASS_ChannelGetData(channel, data, length)
int length = (int)Bass.BASS_ChannelSeconds2Bytes(channel, 0.03); // 30ms window byte data = new byte[length]; // 8-bit are bytes length = Bass.BASS_ChannelGetData(channel, data, length);