Fixing rate issues with audio on FreeBSD
It has been mentioned by a friend that my voice in the recent unreasonable podcast episodes is much higher than it is in reality. Of course for the first few episodes he just said 'your audio is fucked' which didn't help me resolve the issue at all.
With the detail that pitch was off I knew where to start looking, the pitch issue was present on both the audacity recording and the mumble back up. The audio rate for the microphone and audacity where both the same, 44.1kHz.
The last thing to check was the audio sub system on FreeBSD. I read the snd man page and it pointed me to a few sysctl knobs that I might be able to tweak. I also checked the man page for usb audio and found this little notice in the bugs section:
BUGS The PCM framework in FreeBSD only supports synchronous device detach. That means all mixer and DSP character devices belonging to a given USB audio device must be closed when receiving an error on a DSP read, a DSP write or a DSP IOCTL request. Else the USB audio driver will wait for this to happen, preventing enumeration of new devices on the parenting USB controller.
Some USB audio devices might refuse to work properly unless the sample
rate is configured the same for both recording and playback, even if only
simplex is used. See the dev.pcm.%d.[play|rec].vchanrate sysctls.
The PCM framework in FreeBSD currently doesn't support the full set of
USB audio mixer controls. Some mixer controls are only available as
dev.pcm.%d.mixer sysctls.
vchanrate is a per device sample rate that can be controlled by a sysctl, toggling the value showed me the problem. With the rate at the correct 44100 my deep voice poured out of my microphone and into a file.
$ sudo sysctl dev.pcm.4.rec.vchanrate=44100
dev.pcm.4.rec.vchanrate: 48000 -> 44100