BASS.NET API for the Un4seen BASS Audio LibraryWaveWriterWrite Method (Single, Int32)BASS.NET API for the Un4seen BASS Audio Library
Use this method to provide 32-bit sample data to the WaveWriter and write these samples to the wave file.

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

public void Write(
	float[] buffer,
	int length
)

Parameters

buffer
Type: SystemSingle
An array of float values to write to the wave file.
length
Type: SystemInt32
The number of BYTEs in the buffer.
Remarks

This method is best used with e.g. BASS_ChannelGetData(Int32, IntPtr, Int32) and e.g. decoding channels.

The data written to the wave file will be in BitsPerSample resolution (as specified in the constructor). If this is not 32 (float) an automatic bit resolution conversion will take place.

Examples

Converting an OGG file to WAV (32-bit quality):
VB
' create a stream with the float option
Dim stream As Integer = Bass.BASS_StreamCreateFile("test.ogg", 0, 0, 
                             BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)
' set the target bit resolution to 32
Dim WW As New WaveWriter("test.wav", stream, 32, True)
Dim data(32768 - 1) As Single
While Bass.BASS_ChannelIsActive(stream) = BASSActive.BASS_ACTIVE_PLAYING
  ' get the sample data as float values as well
  Dim length As Integer = Bass.BASS_ChannelGetData(stream, data, 32768)
  ' and write the data to the wave file
  If length > 0 Then
    WW.Write(data, length)
  End If
End While
' finilize the wave file!
WW.Close()
Bass.BASS_StreamFree(stream)
// create a stream with the float option
int stream = Bass.BASS_StreamCreateFile("test.ogg", 0, 0, 
                  BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
// set the target bit resolution to 32
WaveWriter WW = new WaveWriter("test.wav", stream, 32, true);
float[] data = new float[32768];
while (Bass.BASS_ChannelIsActive(stream) == BASSActive.BASS_ACTIVE_PLAYING)
{
  // get the sample data as float values as well
  int length = Bass.BASS_ChannelGetData(stream, data, 32768);
  // and write the data to the wave file
  if (length > 0)
    WW.Write(data, length);
}
// finilize the wave file!
WW.Close();
Bass.BASS_StreamFree(stream);
See Also

Reference