BASS.NET API for the Un4seen BASS Audio LibraryWaveFormRenderRecording 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.12.0
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

VB
Private WF As WaveForm = Nothing
Private _myRecProc As RECORDPROC ' make it global, so that the GC can not remove it
Private _recHandle As Integer = 0
...
_myRecProc = New RECORDPROC(AddressOf 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 Not (WF Is Nothing) Then
  WF.RenderStopRecording()
  DrawWave()
End If
...
' the recording callback in which we will render the WaveForm
Private Function MyRecording(handle As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Boolean
  If length > 0 AndAlso buffer <> IntPtr.Zero Then
    ' get and draw our live recording waveform
    WF.RenderRecording(buffer, length)
    DrawWave()
  End If
  Return True ' always continue recording
End Function

' draws a rendered WaveForm to a PictureBox
Private Sub DrawWave()
  If Not (WF Is Nothing) Then
    Me.pictureBoxLiveWave.BackgroundImage = WF.CreateBitmap(Me.pictureBoxLiveWave.Width, 
                                                            Me.pictureBoxLiveWave.Height, 
                                                            -1, -1, False)
  Else
    Me.pictureBoxLiveWave.BackgroundImage = Nothing
  End If
End Sub
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