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

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

[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)]
public static int BASS_RecordStart(
	int freq,
	int chans,
	BASSFlag flags,
	RECORDPROC proc,
	IntPtr user
)

Parameters

freq
Type: SystemInt32
The sample rate to record at.
chans
Type: SystemInt32
The number of channels... 1 = mono, 2 = stereo, etc.
flags
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.
proc
Type: Un4seen.BassRECORDPROC
The user defined function to receive the recorded sample data... can be if you do not wish to use a callback.
user
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.
Remarks

Use BASS_ChannelStop(Int32) to stop the recording, and BASS_ChannelPause(Int32) to paused it. Recording can also be started in a paused state (via the BASS_RECORD_PAUSE flag), allowing DSP/FX to be set on it before any data reaches the callback function.

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 not using a callback (proc = ), the recorded data is instead retrieved via BASS_ChannelGetData(Int32, IntPtr, Int32). 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 is 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!

Platform-specific

Multiple simultaneous recordings can be made from the same device on Windows XP and later, but generally not on older Windows. Multiple simultaneous recordings are possible on iOS and OSX, but may not always be on Linux or Windows CE. On OSX and iOS, the device is instructed (when possible) to deliver data at the period set in the HIWORD of flags, even when a callback function is not used. On other platforms, it is up the the system when data arrives from the device.

Examples

Start recording at 44100hz 16-bit stereo:
VB
Private _myRecProc As RECORDPROC
...
Bass.BASS_RecordInit(- 1)
_myRecProc = New RECORDPROC(AddressOf MyRecording)
' start recording paused
Dim recChannel As Integer = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, _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
...
Bass.BASS_RecordInit(-1);
_myRecProc = new RECORDPROC(MyRecording);
// start recording paused
int recChannel = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, _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

Reference