Module reference

Audio

Records a USB microphone to a WAV file, with a timing file that has one row per chunk and a level meter to check the signal.

Each audio module instance records one input. A webcam’s built-in microphone is listed here as well as in the cameras module; record it here for a separate WAV, or through the cameras module to put the audio in the video file.

Getting started

  1. Connect the microphoneUSB. The system’s other audio inputs are listed too.
  2. Enable the moduleCheck Audio in the Modules menu. The inputs appear in the Devices panel.
  3. Connect the inputClick it in the Devices panel. A level meter appears when it is ready.
  4. RecordStart a session and click Record.

Level meter

The meter shows the input level so you can see that the microphone is picking up sound before a trial.

ColourLevelMeaning
GreenBelow −12 dBNormal
Yellow−12 to −6 dBLoud
RedAbove −6 dBClose to clipping

For speech, a level that touches yellow on the loudest words and rarely reaches red is about right.

What is written

For each trial, a WAV file and a timing CSV in the Audio folder.

{session_dir}/Audio/{token}_AUD_trial001_MIC0_{microphone}.wav
{session_dir}/Audio/{token}_AUD_trial001_MIC0_{microphone}_timing.csv

MIC0 carries the input’s index on the host. The microphone name is lower case with spaces removed.

WAV format

PropertyValue
EncodingPCM, 16-bit signed integer
ChannelsOne. A multi-channel input is recorded from its first channel
Sample rate48 000 Hz by default. If the input cannot run at the requested rate, the module records at the rate the driver gives it and logs the change

Timing CSV, 8 columns

Audio arrives from the driver in chunks, and the timing file has one row per chunk.

ColumnDescription
trialTrial number
moduleAudio
device_idThe input’s index on the host
labelThe trial label, if any
record_time_unixHost wall-clock time in the driver callback that delivered the chunk, six decimals
record_time_monoHost monotonic clock at the same instant, nine decimals
device_time_unixThe driver’s ADC timestamp for the chunk, in seconds on the audio stream’s own clock, when the driver provides one. Otherwise empty
chunk_numberSequential chunk number, from 1

Example row

1,Audio,0,baseline,1774149567.378456,373235.004822011,,1

The file does not record how many samples each chunk held. RSLogger lets the driver choose the chunk size, which is constant for most drivers, so the WAV’s sample count divided by the row count gives it. Synchronization shows two ways to find the sample at a given time.

Settings

SettingDefaultNotes
Sample rate48 000 HzSet in the module’s configuration file. The driver may substitute a rate the input supports
ChannelsOneFixed
Bit depth16-bitFixed

Troubleshooting

The input is not listed

Check the USB connection and that the operating system sees the input: arecord -l on Linux, System Settings > Sound > Input on macOS, Sound settings > Recording on Windows. On Linux, your user must be in the audio group.

The meter shows nothing

Speak into the microphone or tap it. Check for a mute switch on the microphone itself. Check that the right input is connected in the Devices panel. Restart the module from the Modules menu.

The WAV is silent

The meter would have shown nothing during the trial. Check the input’s level in the operating system’s sound settings and that the microphone was not muted.

device_time_unix is empty

The driver did not supply an ADC timestamp for that input. Nothing is wrong. Use record_time_mono.

The log warns about dropped audio blocks

The computer could not write chunks as fast as they arrived. Close other programs, record to faster storage, or lower the sample rate.