Starts recording.
HRECORD BASS_RecordStart( DWORD freq, DWORD chans, DWORD flags, RECORDPROC *proc void *user );
freq | The sample rate to record at... 0 = device's current sample rate. | ||||||
chans | The number of channels... 1 = mono, 2 = stereo, etc. 0 = device's current channel count. | ||||||
flags | A combination of these flags.
| ||||||
proc | The user defined function to receive the recorded sample data... can be NULL if you do not wish to use a callback. | ||||||
user | User instance data to pass to the callback function. |
BASS_ERROR_INIT | BASS_RecordInit has not been successfully called. |
BASS_ERROR_BUSY | The device is busy. An existing recording may need to be stopped before starting another one. |
BASS_ERROR_DENIED | Recording permission has not been granted by the user. |
BASS_ERROR_FORMAT | The sample format is not supported. |
BASS_ERROR_MEM | There is insufficient memory. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
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. A loopback recording device will only deliver data while the corresponding output device is active.
When not using a callback (proc = NULL), the recorded data is instead retrieved via BASS_ChannelGetData. To keep latency at a minimum, the amount of data in the recording buffer should be monitored (also done via BASS_ChannelGetData, 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.
The BASS_POS_END mode can be used with BASS_ChannelSetPosition to limit the length of a recording.
When freq and/or chans is set to 0 for the device's current values, BASS_ChannelGetInfo can be used afterwards to find out what values are being used by the recording.
A recording may end unexpectedly if the device fails, eg. if it is disconnected/disabled. A BASS_SYNC_DEV_FAIL sync can be set via BASS_ChannelSetSync to be informed if that happens. It will not be possible to resume the recording channel then; a new recording channel will need to be created when the device becomes available again.
Loopback recording is only available on Windows Vista and above. The option to use the device's current sample rate and/or channel count is only available on Windows/macOS/iOS.
On macOS 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.
On macOS and iOS, this function may succeed but only capture silence when recording permission has not been granted. The AVCaptureDevice authorizationStatusForMediaType method (or the AVAudioSession recordPermission method on iOS) can be used to check the permission status.
HRECORD record = BASS_RecordStart(44100, 2, 0, MyRecordProc, 0);