BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_RecordStart Method (Int32, Int32, BASSFlag, Int32, RECORDPROC, IntPtr)BASS.NET API for the Un4seen BASS Audio Library
Starts recording.

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

public static int BASS_RecordStart(
	int freq,
	int chans,
	BASSFlag flags,
	int period,
	IntPtr user


Type: SystemInt32
The sample rate to record at.
Type: SystemInt32
The number of channels... 1 = mono, 2 = stereo.
Type: Un4seen.BassBASSFlag
Any combination of these flags (see BASSFlag)
BASS_SAMPLE_8BITSUse 8-bit resolution. If neither this or the BASS_SAMPLE_FLOAT flags are specified, then the recorded data is 16-bit.
BASS_SAMPLE_FLOATUse 32-bit floating-point sample data. WDM drivers are required to use this flag in Windows. See Floating-point channels for more information.
BASS_RECORD_PAUSEStart the recording paused. Use BASS_ChannelPlay(Int32, Boolean) together with the handle returned by this method to start it.
Type: SystemInt32
Set the period (in milliseconds) between calls to the callback function (RECORDPROC). The minimum period is 5ms, the maximum the maximum is half the BASS_CONFIG_REC_BUFFER setting. If the period specified is outside this range, it is automatically capped. The default is 100ms.
Type: Un4seen.BassRECORDPROC
The user defined function to receive the recorded sample data... can be if you do not wish to use a callback.
Type: SystemIntPtr
User instance data to pass to the callback function.

Return Value

Type: Int32
If successful, the new recording's handle is returned, else is returned. Use BASS_ErrorGetCode to get the error code.

Use BASS_ChannelStop(Int32) to stop the recording. Recording can also be paused with BASS_ChannelPause(Int32).

The sample data will generally arrive from the recording device in blocks rather than in a continuous stream, so when specifying a very short period between callbacks, some calls may be skipped due to there being no new data available since the last call.

When specifying a very short period between RECORDPROC calls, some calls may be skipped due to there being no new data available from the recording device since the last call. This is more likely to happen with drivers that do not have hardware support.

Starting the recording paused (BASS_RECORD_PAUSE) allows DSP/FX to be set on the recording channel before any data reaches the RECORDPROC function.

Not using a callback (proc = ) allows lower latency for full-duplex recording (ie. playing the data as it's being recorded), as you get the recorded data on demand via the BASS_ChannelGetData(Int32, IntPtr, Int32) function. To keep latency at a minimum, the amount of data in the recording buffer should be monitored (also done via BASS_ChannelGetData(Int32, IntPtr, Int32), with the BASS_DATA_AVAILABLE flag) to check that there's not too much data; freshly recorded data will only be retrieved after the older data in the buffer is.

ERROR CODEDescription
BASS_ERROR_INITBASS_RecordInit(Int32) has not been successfully called.
BASS_ERROR_BUSYThe device is busy. An existing recording must be stopped before starting another one. Multiple simultaneous recordings can be made from the same device on Windows XP and Vista, but generally not on older Windows.
BASS_ERROR_NOTAVAILThe recording device is not available. Another application may already be recording with it, or it could be a half-duplex device and is currently being used for playback.
BASS_ERROR_FORMATThe specified format is not supported. If using the BASS_SAMPLE_FLOAT flag, it could be that floating-point recording is not supported.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_UNKNOWNSome other mystery problem!


Start recording at 44100hz 16-bit stereo with a 50ms recording period:
Private _myRecProc As RECORDPROC
_myRecProc = New RECORDPROC(AddressOf MyRecording)
' start recording paused
Dim recChannel As Integer = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _myRecProc, IntPtr.Zero)
' really start recording
Bass.BASS_ChannelPlay(recChannel, False)
' the recording callback
Private Function MyRecording(handle As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Boolean
  Return True
End Function
private RECORDPROC _myRecProc; // make it global, so that the Garbage Collector can not remove it
_myRecProc = new RECORDPROC(MyRecording);
// start recording paused
int recChannel = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _myRecProc, IntPtr.Zero);
// really start recording
Bass.BASS_ChannelPlay(recChannel, false);
// the recording callback
private bool MyRecording(int handle, IntPtr buffer, int length, IntPtr user)
  return true;
See BASS_RecordInit(Int32) for a recording callback sample.
See Also