I'm interested in developing an audio recorder using BASS.NET that captures sound from an input device and saves it in WAV format with the following specifications:
Channels: 2 (Stereo)
Bit depth: 16 bits
Sample rate: 44.1 kHz
Bitrate: 1411 kbps
I have some questions on how to get started and would like some guidance from those who have experience with BASS.NET:
What DLLs do I need?
Do I need to download the BASS core library and other specific plugins?
Yes, you will need at least BASS.DLL (in addition to the BASS.NET.DLL). I would recommend BASSENC.DLL too, for the WAV file writing part.
How do I capture audio from an input device?
You basically need to call BASS_RecordInit to initialize a device and BASS_RecordStart to start recording from it. You can provide a callback function that'll receive the captured data. The following example code is taken from BASS.Net's documentation for the BASS_RecordStart 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;
}
What is the best way to select the microphone or audio source?
How do I properly initialize recording in BASS.NET?
You can use BASS_RecordGetDeviceInfo to get information on the available devices, and then initialize the one you want (eg. one with BASS_DEVICE_TYPE_MICROPHONE) with BASS_RecordInit.
How do I save audio in WAV format with the required specifications?
Does BASS.NET allow recording directly to WAV or is an additional conversion step required?
You can use the BASSenc add-on for this, specifically the BASS_Encode_Start function with the BASS_ENCODE_PCM flag.
Please see the documentation for details on all of the mentioned functions.