Use this method to provide the 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
Parameters
- buffer
- Type: SystemIntPtr
The IntPtr containing the sample data. - length
- Type: SystemInt32
The number of BYTEs in the buffer.
Remarks
Please note, that the sample data provided in the buffer must conform the OrigResolution property! Meaning if the OrigResolution=32 float sample data is expected, if OrigResolution=16 short sample data is expected and if OrigResolution=8 byte samples are expected!
However, the data written to the wave file will be in BitsPerSample resolution (as specified in the constructor). If the OrigResolution is different from this one an automatic bit resolution conversion will take place.
When using a decoding stream other overloads might be more conviniant.
Examples
private WaveWriter _waveWriter = null; // make it global, so that the GC can not remove it private RECORDPROC _myRecProc; private int _recHandle = 0; ... // start recording _myRecProc = new RECORDPROC(MyRecording); _recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE | BASSFlag.BASS_SAMPLE_FLOAT, _myRecProc, IntPtr.Zero); // create a WaveWriter using the _recHandle to set the freq. and channels, but write the wave at 24-bit _waveWriter = new WaveWriter( "test.wav", _recHandle, 24, true); Bass.BASS_ChannelPlay(_recHandle, false); ... // when finished recording call this! if (_waveWriter != null) { // finilize the wave file! _waveWriter.Close(); } ... // the recording callback private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user) { // we will get float sample data here // so make sure the _waveWriter.OrigResolution property is set to 32 // this was automatically done, since we started recording with BASSFlag.BASS_SAMPLE_FLOAT _waveWriter.Write( buffer, length ); return true; // always continue recording }
See Also