BASS.NET API for the Un4seen BASS Audio Library

WaveFormRenderRecording Method

BASS.NET API for the Un4seen BASS Audio Library
Renders live recorded data and generates the WaveForm data for it.

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

public void RenderRecording()
Remarks

Call this method subsequently and often enough to get the actual recording data and perform the rendering of that data.

You must have started live rendering recording with RenderStartRecording(Int32, Int32, Int32) before calling this method.

You might use the method either within a RECORDPROC or via your own timer callback at any time when new sample data is available. This overload actually calls BASS_ChannelGetData(Int32, IntPtr, Int32) internally, so it is not recommended to use this with a stream channel (but only with buffered recording channels), since it will steal sample from the stream.

This overload only exists for backwards compatibility it is advised to use this overload only when needed, since the 'other' overload of this method might be faster and more accurate.

Calling this method after you have stopped live recording rendering with RenderStopRecording has no effect anymore.

Examples

private WaveForm WF = null;
private RECORDPROC _myRecProc; // make it global, so that the GC can not remove it
private int _recHandle = 0;
...
_myRecProc = new RECORDPROC(MyRecording);
_recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, _myRecProc, IntPtr.Zero);
// create a live recording WaveForm
WF = new WaveForm();
WF.FrameResolution = 0.01f; // 10ms are nice
// start a live recording waveform with 10sec. init size and 5sec. next size
WF.RenderStartRecording(_recHandle, 10, 5);
// really start recording
Bass.BASS_ChannelPlay(_recHandle, false);
...
// stops recording
Bass.BASS_ChannelStop(_recHandle);
// stop the live recording waveform
if (WF != null)
{
  WF.RenderStopRecording();
  DrawWave();
}
...
// the recording callback in which we will render the WaveForm
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user)
{
  if (length > 0 && buffer != IntPtr.Zero)
  {
    // get and draw our live recording waveform
    WF.RenderRecording(buffer, length);
    DrawWave();
  }
  return true; // always continue recording
}
...
// draws a rendered WaveForm to a PictureBox
private void DrawWave()
{
  if (WF != null)
    this.pictureBoxLiveWave.BackgroundImage = WF.CreateBitmap(this.pictureBoxLiveWave.Width, 
                                                              this.pictureBoxLiveWave.Height, 
                                                              -1, -1, false);
  else
    this.pictureBoxLiveWave.BackgroundImage = null;
}
See Also

Reference