Close

Switching between mono & stereo

A project log for The ultimate vlogging mic

Recording the best headset audio in a portable form factor

lion-mclionheadlion mclionhead 01/24/2021 at 08:450 Comments

The lion kingdom revisited this project after 3 years, to do single channel vlog recording again.  Apparently, there was no way for jack to play back while recording from 2 soundcards, so that's why monitoring was dropped for recording stereo.

Using the same board as a voice recorder with monitoring & a stereo recorder without monitoring ended up requiring 2 different executables.  To record a single channel with monitoring, you have to run jackd & then usbmic.c

/root/jack2-1.9.12/build/jackd -P70 -p16 -t2000 -dalsa -dhw:1 -p256 -n3 -r48000 -s &

/root/usbmic

This picks 1 of the 2 soundcards, as specified with the -dhw:1 option.  Jackd handles the full duplex I/O in what was deemed to be a very efficient loop.

To record stereo from 2 soundcards without monitoring, you have to kill jackd & run usbmic2.c.  Jackd was abandoned for stereo in favor of using raw alsa calls.

This requires a /root/.asoundrc file to merge the 2 soundcards.

root@raspberrypi:~# cat .asoundrc
pcm.merge {
    type multi;
    slaves.a.pcm hw:1
    slaves.a.channels 1;
    slaves.b.pcm hw:2
    slaves.b.channels 1;
    bindings.0.slave a;
    bindings.0.channel 0;
    bindings.1.slave b;
    bindings.1.channel 0;
}

ctl.merge {
    type hw
    card 0
}

It still may be possible to record stereo with monitoring, thereby allowing a single executable to be used for stereo & mono.  Some ideas are directing playback to the virtual merged device instead of a single soundcard or using raw alsa calls for playback instead of jackd.  Unfortunately, there's no reason to monitor stereo recordings.  That mode wouldn't be used for vlogging.

Discussions