BASS.NET API for the Un4seen BASS Audio LibraryBassWmaBASS_WMA_EncodeWrite Method (Int32, IntPtr, Int32)BASS.NET API for the Un4seen BASS Audio Library
Encodes sample data, and writes it to the file or network.

This overload uses an IntPtr to point to the memory block containing the data.

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

[DllImportAttribute("basswma.dll", CharSet = CharSet.Auto)]
public static bool BASS_WMA_EncodeWrite(
	int handle,
	IntPtr buffer,
	int length
)

Parameters

handle
Type: SystemInt32
The encoder handle.
buffer
Type: SystemIntPtr
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

Stream what you are recording using a system-chosen port, and allowing up to 5 clients:
VB
Private _myRecProc As RECORDPROC
...
If Bass.BASS_RecordInit(-1) Then
  Dim enc As Integer = BassWma.BASS_WMA_EncodeOpenNetwork(44100, 2, BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, 
                               128000, 0, 5)
  _myRecProc = New RECORDPROC(AddressOf MyRecording)
  Dim recHandle As Integer = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_DEFAULT, _myRecProc, New IntPtr(enc))
End If
...
Private Function MyRecording(handle As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Boolean
  If length > 0 AndAlso buffer <> IntPtr.Zero Then
    ' write the recorded data to the encoder
    BassWma.BASS_WMA_EncodeWrite(user.ToInt32(), buffer, length)
  End If
  Return True
End Function
private RECORDPROC _myRecProc;
...
if ( Bass.BASS_RecordInit(-1) )
{
  int enc = BassWma.BASS_WMA_EncodeOpenNetwork(44100, 2, BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, 
                    128000, 0, 5);
  _myRecProc = new RECORDPROC(MyRecording);
  int recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_DEFAULT, _myRecProc, new IntPtr(enc));
}
...
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user)
{
  if (length > 0 && buffer != IntPtr.Zero)
  {
    // write the recorded data to the encoder
    BassWma.BASS_WMA_EncodeWrite(user.ToInt32(), buffer, length);
  }
  return true;
}
See Also

Reference