BASS.NET API for the Un4seen BASS Audio LibraryBassWmaBASS_WMA_EncodeGetRates Method BASS.NET API for the Un4seen BASS Audio Library
Retrieves the WMA encoding bitrates available for a specified sample format.

Namespace: Un4seen.Bass.AddOn.Wma
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static int[] BASS_WMA_EncodeGetRates(
	int freq,
	int chans,
	BASSWMAEncode flags


Type: SystemInt32
The sample rate in Hz, or a BASS channel handle if the BASS_WMA_ENCODE_SOURCE flag is specified.
Type: SystemInt32
The number of channels (1=mono, 2=stereo, etc.).
Type: Un4seen.Bass.AddOn.WmaBASSWMAEncode
Any combination of these flags (see BASSWMAEncode):
BASS_WMA_ENCODE_RATES_VBRGet available VBR (Variable BitRate) quality settings.
BASS_WMA_ENCODE_RATES_CBRGet available CBR (Constant BitRate) quality settings.
BASS_WMA_ENCODE_STANDARDGet only bitrates available for standard WMA encoding. If neither this or the BASS_WMA_ENCODE_PRO flag is specified, then the bitrates available for either codec are returned.
BASS_WMA_ENCODE_PROGet only bitrates available for WMA Pro encoding.
BASS_WMA_ENCODE_24BITGet available bitrates for 24-bit encoding, else 16-bit encoding rates.
BASS_WMA_ENCODE_SOURCEUse the sample format of the BASS channel with the handle in freq. The chans parameter is ignored.

Return Value

Type: Int32
If succesful, an array of the available bitrates is returned (int[], in bits per second), else is returned. Use BASS_ErrorGetCode to get the error code.

When requesting VBR rates, the rates returned are quality settings. For example, 10 = 10% quality, 25 = 25% quality, etc... 100% quality is lossless.

The WMA codec expects 16-bit or 24-bit sample data depending on the BASS_WMA_ENCODE_24BIT flag, but BASSWMA will accept 8-bit, 16-bit or floating-point data, and convert it to the appropriate format. Of course, it makes little sense to encode 8-bit or 16-bit data in 24-bit.

The WMA codec currently supports the following sample rates: 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000. And the following number of channels: 1, 2, 6, 8. But not all combinations of these are supported. To encode other sample formats, the data will first have to be resampled to a supported format.

ERROR CODEDescription
BASS_ERROR_WMAThe Windows Media modules (v9 or above) are not installed.
BASS_ERROR_NOTAVAILNo codec could be found to support the specified sample format.
BASS_ERROR_UNKNOWNSome other mystery problem!


List the CBR bitrates available at 44100hz 16-bit stereo:
Dim bitrates As Integer() = BassWma.BASS_WMA_EncodeGetRates(44100, 2, BASSWMAEncode.BASS_WMA_ENCODE_RATES_CBR)
If Not (bitrates Is Nothing) Then
  Dim bitrate As Integer
  For Each bitrate In bitrates
  Next bitrate
End If
int[] bitrates = BassWma.BASS_WMA_EncodeGetRates(44100, 2, BASSWMAEncode.BASS_WMA_ENCODE_RATES_CBR );
if (bitrates != null)
  foreach (int bitrate in bitrates)
    Console.WriteLine( bitrate );
See Also