BASS.NET API for the Un4seen BASS Audio Library

WaveWriterWrite Method (Int16, Int32)

BASS.NET API for the Un4seen BASS Audio Library
Use this method to provide 16-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.17.5
Syntax

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

Parameters

buffer
Type: SystemInt16
An array of short 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.

However, the data written to the wave file will be in BitsPerSample resolution (as specified in the constructor). If this is not 16 (short) an automatic bit resolution conversion will take place.

Examples

Writing a MP3 file to WAV:
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE);
WaveWriter WW = new WaveWriter("test.wav", stream, true);
short[] data = new short[32768];
while (Bass.BASS_ChannelIsActive(stream) == BASSActive.BASS_ACTIVE_PLAYING)
{
  int length = Bass.BASS_ChannelGetData(stream, data, 32768);
  if (length > 0)
    WW.Write(data, length);
}
// finilize the wave file!
WW.Close();
Bass.BASS_StreamFree(stream);
See Also

Reference