BASS.NET API for the Un4seen BASS Audio Library

WaveFormRenderRecording Method (IntPtr, Int32)

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(
	IntPtr buffer,
	int length
)

Parameters

buffer
Type: SystemIntPtr
The pointer to the sample data to render (e.g. as received within a RECORDPROC).
length
Type: SystemInt32
The length of the data with the buffer.
Remarks

Call this method subsequently and often enough to get the actual recording data and perform the rendering of that data - typically with a RECORDPROC.

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 any other BASS callback in which you receive sample data (a DSPPROC for example).

Use this overload, if you want to render live sample data even from a decoding stream!

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