BASS.NET API for the Un4seen BASS Audio Library

BassWmaBASS_WMA_EncodeWrite Method (Int32, Byte, Int32)

BASS.NET API for the Un4seen BASS Audio Library
Encodes sample data, and writes it to the file or network.

This overload uses a managed byte[] to handover sample data to the encoder (perfect for 8-bit samples).

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

[DllImportAttribute("basswma")]
public static bool BASS_WMA_EncodeWrite(
	int handle,
	byte[] buffer,
	int length
)

Parameters

handle
Type: SystemInt32
The encoder handle.
buffer
Type: SystemByte
The buffer containing the sample data.
length
Type: SystemInt32
The number of BYTES in the buffer.

Return Value

Type: Boolean
If succesful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

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.

There is generally no need to call this function if the BASS_WMA_ENCODE_SOURCE flag has been set on the encoder, as the encoder will automatically be fed the data that its source BASS channel produces.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_UNKNOWNSome other mystery problem!

Examples

Initialize encoding 44100hz 16-bit stereo sample data at 128kb/s to a file called "output.wma":
int stream = Bass.BASS_StreamCreateFile("input.mp3", 0L, 0L, BASSFlag.BASS_STREAM_DECODE);
if (stream != 0)
{
  byte[] buffer = new byte[16384]; // 16KB decode buffer
  int enc = BassWma.BASS_WMA_EncodeOpenFile(44100, 2, BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, 
                    128000, "output.wma");
  while (Bass.BASS_ChannelIsActive(stream) == BASSActive.BASS_ACTIVE_PLAYING)
  {
    int len = Bass.BASS_ChannelGetData(stream, buffer, 16384);
    if (len > 0)
      BassWma.BASS_WMA_EncodeWrite(enc, buffer, len);
  }
  BassWma.BASS_WMA_EncodeClose(enc);
}
See Also

Reference