Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Dec 2017 14:23:10 +0100
From:      "Onno K." <onno.k@gmx.com>
To:        Freebsd-multimedia@freebsd.org, freebsd-questions@freebsd.org
Subject:   How to capture audio with FreeBSD?
Message-ID:  <trinity-b639b15a-c1a2-426d-b47a-69ab299dbcc3-1513171390323@3c-app-mailcom-bs16>

Next in thread | Raw E-Mail | Index | Archive | Help
Dear list,

I have got my Raspberry Pi 3 (ARM64) working with FreeBSD 12-CURRENT - cool stuff!

Though I believe this to be unrelated to the RPi, I cannot figure out how to capture audio with it. The RPi only has audio output and no input, so I am using a simple USB-dongle audio device that has both input and output. It is recognised as following by FreeBSD 12-CURRENT Nov 30 2017 snapshot:


..
uaudio0 on uhub1
uaudio0: <vendor 0x0d8c C-Media USB Audio Device, class 0/0, rev 1.10/1.00, addr 4> on usbus0
uaudio0: Play: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record: 48000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record: 44100 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No MIDI sequencer.
pcm0: <USB audio> on uaudio0
uaudio0: HID volume keys found.
..


Looks good to me! Additionally, /dev/sndstat reveals:


Installed devices:
pcm0: <USB audio> (play/rec) default
No devices installed from userspace.


A more verbose /dev/sndstat reads:


# sysctl hw.snd.verbose=2
hw.snd.verbose: 0 -> 2
# cat /dev/sndstat 
FreeBSD Audio Driver (64bit 2009061500/aarch64)
Installed devices:
pcm0: <USB audio> at ? kld snd_uaudio (1p:1v/1r:1v) default
	snddev flags=0x2e6<AUTOVCHAN,SOFTPCMVOL,BUSY,MPSAFE,REGISTERED,VPC>
	[pcm0:play:dsp0.p0]: spd 48000, fmt 0x00200010, flags 0x00002100, 0x00000004
	interrupts 0, underruns 0, feed 0, ready 0 [b:3072/1536/2|bs:4096/2048/2]
	channel flags=0x2100<BUSY,HAS_VCHAN>
	{userland} -> feeder_mixer(0x00200010) -> {hardware}
	pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp0]: spd 8000, fmt 0x00100008, flags 0x10000000, 0x00000000
	interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:0/0/0]
	channel flags=0x10000000<VIRTUAL>
	{userland} -> feeder_root(0x00000000) -> {hardware}
	[pcm0:record:dsp0.r0]: spd 48000, fmt 0x00200010/0x00100010, flags 0x00002100, 0x00000045
	interrupts 0, overruns 0, feed 0, hfree 1536, sfree 4096 [b:1536/768/2|bs:4096/2048/2]
	channel flags=0x2100<BUSY,HAS_VCHAN>
	{hardware} -> feeder_root(0x00100010) -> feeder_matrix(1.0 -> 2.0) -> feeder_mixer(0x00200010) -> {userland}
	pcm0:record:dsp0.r0[pcm0:virtual:dsp0.vr0]: spd 8000, fmt 0x00100008, flags 0x10000000, 0x00000000
	interrupts 0, overruns 0, feed 0, hfree 0, sfree 0 [b:0/0/0|bs:0/0/0]
	channel flags=0x10000000<VIRTUAL>
	{hardware} -> feeder_root(0x00000000) -> {userland}
No devices installed from userspace.


On Linux platform, I had success with capturing audio using the same hardware using the 'aplay' and 'arecord' tools from the ALSA library. So the hardware works, on Linux, but not on FreeBSD. It appears not to detect the sound card:


# aplay -l
aplay: device_list:273: no soundcards found...
# arecord -l
arecord: device_list:273: no soundcards found...


So at first glance, ALSA does not work (out of the box, after installing pkg) with FreeBSD. But 'alsamixer' does appear to work, since the volume buttons on the USB dongle would affect the sound level in alsamixer.

Now my questions:
-> Does ALSA even work in FreeBSD or is any configuration required to get it to work?
-> How can one capture audio on FreeBSD?
-> Any hints in general on how to proceed?

Addendum:
-> The handbook was not very useful to me. Nothing about capturing audio mentioned: https://www.freebsd.org/doc/handbook/sound-setup.html.
-> I did read something about being able to use 'dd' to directly capture audio to a file. Any examples on such a command would be appreciated, as my simple 'dd if=/dev/dsp of=test.wav' did not work properly for me.

Thanks for any help!



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?trinity-b639b15a-c1a2-426d-b47a-69ab299dbcc3-1513171390323>