# smrec Minimalist multi-track audio recorder which may be controlled via OSC or MIDI. I did this because I needed a simple multi-track audio recorder which I could control via OSC or MIDI. I didn't want and do not have the resources to use a DAW for this purpose in my setup and wanted mono wave files for each channel organized in a directory per recording by date and time I'm using this recorder in a setup where I use a [Behringer XR18](https://www.behringer.com/product.html?modelCode=P0BI8) as an audio interface and a [LattePanda 3 Delta](https://www.lattepanda.com/lattepanda-3-delta) as a SBC. Now let's record some sound! 🔔 --- ## Installation ``` cargo install smrec ``` ### Installing for Windows and ASIO support `smrec` uses [`cpal`](https://github.com/RustAudio/cpal) as the underlying audio API. `cpal` supports WASAPI, DirectSound and ASIO on Windows. However, since `cargo` builds binaries from source in the target machine and it is [not very straight forward](https://github.com/RustAudio/cpal#asio-on-windows) to build `cpal` with ASIO support due to `asio-sys` build script, **there is a pre-build script provided** in this repository. To install `smrec` on Windows, please follow these steps in order: - Install the latest Visual Studio (if you don't have it already) - Install the latest LLVM (if you don't have it already) from [here](https://releases.llvm.org/download.html) - Open Command Prompt as administrator - Set LLVM path in the environment variables (system wide) ``` setx /M LIBCLANG_PATH "C:\Program Files\LLVM\bin" ``` - Open PowerShell as administrator - Check if the environment variable is set correctly ``` $env:LIBCLANG_PATH ``` - Source the pre-build script in the repository (assuming you are in the root of the repository) ``` . .\pre-build-win.ps1 ``` this script will download the ASIO SDK, set Visual Studio environment variables and `CPAL_ASIO_DIR` variable for the current shell session. - Install as usual ``` cargo install smrec ``` If you know what you're doing feel free to skip these steps and consult the [`cpal` documentation](https://github.com/RustAudio/cpal#asio-on-windows). ### Pre-built binaries Pre-built binaries as an alternative are available for Windows [here](https://github.com/alisomay/smrec/releases) due to the complicated process of building `cpal` with ASIO support on Windows currently. ## Tutorial ### Simply as a command ``` smrec ``` Runs with the default configuration which is: - The default audio host - The default audio device - The default set of input channels - The default directory to record which is the current working directory - The recording goes on until `ctrl+c` is pressed and the program is interrupted. - Creates a directory named `rec_YYYYMMDD_HHMMSS` in the current working directory and records the audio in that directory. - The audio is recorded in `wav` format. - The audio is recorded in the default sample rate and buffer size and sample format of the audio device. - For every channel a separate file is created (mono) and the file name for each is `chn_XX.wav` where `XX` is the channel number. To record for a specific duration, use the `--duration` flag and specify the duration in seconds. The following command records for 10 seconds: ``` smrec --duration 10 ``` By using the `--host` and `--device` flag , you can specify the audio host and device to use. The following command uses `MacBook Pro Microphone` as the audio device: ``` smrec --device "MacBook Pro Microphone" ``` #### Listing midi ports and audio hosts and devices ``` smrec list ``` #### Including and excluding channels from a recording By default, all channels of the audio device are recorded. You can specify which channels to include or exclude from the recording by using the `--include` and `--exclude` flags. These flags can not be used together. The following command records only the first two channels of a 4 channel audio device: ``` smrec --include 1,2 ``` And this command records all channels except the first channel of a 4 channel audio device: ``` smrec --exclude 1 ``` as seen in the examples, the channel numbers start from 1 and they can be specified as a comma separated list. #### Recording to a specific directory By default, the recording is done in the current working directory. You can specify a directory to record to by using the `--directory` flag. The following command records to the `~/Music` directory: ``` smrec --out ~/Music ``` #### Configuring with a configuration file `smrec` uses the cli arguments for configuration and they precede everything. However, you can configure some aspects (probably more to come) of `smrec` by using a configuration file so they replace the default configuration. The configuration file is a `toml` file and it is named `config.toml`. The configuration file is searched in the following order: - `.smrec/config.toml` in the current working directory. - `.smrec/config.toml` in the user home directory. - If none of the above is found, the default configuration is used. The configuration file can configure: - Channel names ```toml [channel_names] 1 = "Kick" 2 = "Snare" 3 = "Hi-Hat" ``` - More to come.. ### OSC control `smrec` normally starts recording as soon as it is run. However it also has options for various control methods. Running, `smrec --osc` will not start recording immediately but instead it will wait for an OSC message to start recording. The default OSC port for receiving and sending is chosen randomly by the os and the default addresses for sending and receiving is `127.0.0.1` and `0.0.0.0`. After running the command above, the output might look like this: ``` Will be sending OSC messages to 127.0.0.1:61213 Listening for OSC messages on 0.0.0.0:51014 ``` Currently `smrec` does not support IPv6. In the default configuration: - Listens for OSC messages on a randomly chosen port on all addresses. - Sends OSC messages to localhost on a randomly chosen port. To configure OSC further arguments could be added to the flag: ``` smrec --osc "