Can't record with USB microphone

I'm using a USB microphone that works well with Firefox, but:

Code:
$ rec -r 44100 -b 16 -e signed-integer test.wav
rec FAIL formats: can't open input  `default': open failed for device: /dev/dsp

Do I need to enable it with sysctl or something? Any help would be tremendously appreciated!
 
Code:
$ rec -r 44100 -b 16 -e signed-integer test.wav
rec FAIL formats: can't open input  `default': open failed for device: /dev/dsp
If /dev/dsp already correctly corresponds to your mic, then the error message indicates that your mic doesn't support s16le with a 44100 samplerate. When you plug in your mic, dmesg should show the supported formats of your USB mic. If you run rec test.wav without specifying the parameters then sox(1) should actually open the audio device successfully with supported parameters.
 
sox(1) uses your default audiodevice /dev/dsp by default. Is this your USB microphone? Please show cat /dev/sndstat. As an example: if your mic is /dev/dsp3, then execute AUDIODEV=/dev/dsp3 rec.

No problem:

Code:
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC269 (Analog)> (play/rec)
pcm1: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <USB audio> (play) default
pcm5: <USB audio> (rec)
No devices installed from userspace.

It's pcm5, as usual. Alas,

Code:
$ sudo AUDIODEV=pcm5 rec
rec FAIL sox: Sorry, there is no default audio device configured

I probably flubbed something, eh?

If /dev/dsp already correctly corresponds to your mic, then the error message indicates that your mic doesn't support s16le with a 44100 samplerate. When you plug in your mic, dmesg should show the supported formats of your USB mic. If you run rec test.wav without specifying the parameters then sox(1) should actually open the audio device successfully with supported parameters.

Unfortunately.....

Code:
$ rec test.wav
rec FAIL formats: can't open input  `default': open failed for device: /dev/dsp

This has yet to be resolved, but I appreciate your advice. If you've any other suggestions, I'm very receptive!
 
Code:
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC269 (Analog)> (play/rec)
pcm1: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <USB audio> (play) default
pcm5: <USB audio> (rec)
No devices installed from userspace.
It's pcm5, as usual.
No, currently pcm4 is set as your default. And this only has play-capabilities. So when sox(1) says it uses /dev/dsp, it is actually using /dev/dsp4. And because it doesn't have rec-capabilities sox(1) isn't able to open that device for recording.

Your pcm5 sound device actually corresponds to your mic, therefore the correct audio device to use is /dev/dsp5. Try if AUDIODEV=/dev/dsp5 rec works.
 
Your pcm5 sound device actually corresponds to your mic, therefore the correct audio device to use is /dev/dsp5. Try if AUDIODEV=/dev/dsp5 rec works.

Code:
$ sudo AUDIODEV=/dev/dsp5 rec
rec FAIL sox: Sorry, there is no default audio device configured

I tried:

Code:
$ sysctl hw.snd.default_unit=5
hw.snd.default_unit: 4 -> 5

Checked:

Code:
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC269 (Analog)> (play/rec)
pcm1: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <USB audio> (play)
pcm5: <USB audio> (rec) default
No devices installed from userspace.

Unfortunately, again:

Code:
$ sudo AUDIODEV=/dev/dsp5 rec
rec FAIL sox: Sorry, there is no default audio device configured

So again, I'm stumped. I sense that we're close to resolving this, but I don't know how! 😂
Again, thank you for guiding me through this crash course in OSS, which I've only learned how to configure variably for playback during the past lustrum. Sheesh!
 
Strange. Please try again without sudo.

Just to be sure that recording wih sox(1) does indeed work I tried it myself with my headset which has an integrated microphone:
Code:
# dmesg | grep uaudio
uaudio0 on uhub3
uaudio0: <vendor 0x1395 EPOS H3PRO, class 0/0, rev 2.00/27.26, addr 5> on usbus0
uaudio0: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x2ms buffer.
uaudio0: Record[0]: 16000 Hz, 1 ch, 16-bit S-LE PCM format, 2x2ms buffer.
uaudio0: No MIDI sequencer.
pcm1: <USB audio> on uaudio0
uaudio0: HID volume keys found.
Code:
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC1220 (Rear Analog Line-out)> (play)
pcm1: <USB audio> (play/rec) default
No devices installed from userspace.

rec /tmp/test.wav and AUDIODEV=/dev/dsp1 rec /tmp/test.wav both work on my side.

What does sysctl dev.pcm.5 say?
 
Strange. Please try again without sudo.

That yields the same output that it did initially:

Code:
$ AUDIODEV=/dev/dsp5 rec
AUDIODEV=/dev/dsp5: Command not found.

Am I just a cretin who needs to install something? 😂

rec /tmp/test.wav and AUDIODEV=/dev/dsp1 rec /tmp/test.wav both work on my side.

What does sysctl dev.pcm.5 say?

It seems OK:

Code:
$ sysctl dev.pcm.5
dev.pcm.5.feedback_rate: 0
dev.pcm.5.mixer.mute_2.desc:
dev.pcm.5.mixer.mute_2.max: 1
dev.pcm.5.mixer.mute_2.min: 0
dev.pcm.5.mixer.mute_2.val: 0
dev.pcm.5.mixer.vol_1_1.desc:
dev.pcm.5.mixer.vol_1_1.max: 3072
dev.pcm.5.mixer.vol_1_1.min: -2688
dev.pcm.5.mixer.vol_1_1.val: -1248
dev.pcm.5.mixer.vol_1_0.desc:
dev.pcm.5.mixer.vol_1_0.max: 3072
dev.pcm.5.mixer.vol_1_0.min: -2688
dev.pcm.5.mixer.vol_1_0.val: -1248
dev.pcm.5.mixer.selector_0.desc:
dev.pcm.5.mixer.selector_0.max: 1
dev.pcm.5.mixer.selector_0.min: 1
dev.pcm.5.mixer.selector_0.val: 1
dev.pcm.5.mode: 5
dev.pcm.5.bitperfect: 0
dev.pcm.5.buffersize: 0
dev.pcm.5.rec.vchanformat: s16le:2.0
dev.pcm.5.rec.vchanrate: 48000
dev.pcm.5.rec.vchanmode: fixed
dev.pcm.5.rec.vchans: 1
dev.pcm.5.hwvol_mixer: vol
dev.pcm.5.hwvol_step: 5
dev.pcm.5.%parent: uaudio1
dev.pcm.5.%pnpinfo:
dev.pcm.5.%location:
dev.pcm.5.%driver: pcm
dev.pcm.5.%desc: USB audio

I dunno 🤷‍♂️
 
Code:
$ AUDIODEV=/dev/dsp5 rec
AUDIODEV=/dev/dsp5: Command not found.
You used tcsh(1) as your shell when you executed it. Then try setenv AUDIODEV /dev/dsp5; rec test.wav.

Code:
dev.pcm.5.rec.vchans: 1
This could prevent sox(1) from opening the device if it's already opened by another program. Do you have the mic in use by another program at the same time? You can increase that value, then this shouldn't be a problem anymore: sysctl dev.pcm.5.rec.vchans=16.
 
Do you have the mic in use by another program at the same time?

No.

Code:
$ sysctl dev.pcm.5.rec.vchans=16
dev.pcm.5.rec.vchans: 1
sysctl: dev.pcm.5.rec.vchans=16: Operation not permitted
$ sudo sysctl dev.pcm.5.rec.vchans=16
Password:
dev.pcm.5.rec.vchans: 1 -> 16
$ sysctl hw.snd.default_unit=5
hw.snd.default_unit: 0 -> 5
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC269 (Analog)> (play/rec)
pcm1: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <USB audio> (play)
pcm5: <USB audio> (rec) default
No devices installed from userspace.
$ setenv AUDIODEV /dev/dsp5
$ AUDIODEV=/dev/dsp5 rec
AUDIODEV=/dev/dsp5: Command not found.
$ sudo AUDIODEV=/dev/dsp5 rec
Password:
rec FAIL sox: Sorry, there is no default audio device configured
$ rec test.wav
rec FAIL sox: Sorry, there is no default audio device configured

Do I need to join a group or something?
 
Ok, so far we have established that you increase the vchans for pcm5 in order to rule out any exclusive opening of the device, and you set the default audio device unit to 5. Therefore you do not need to specify the audio device with AUDIODEV=/dev/dsp5 rec test.wav OR setenv AUDIODEV /dev/dsp5; rec test.wav. A simple
Code:
$ rec test.wav
like what you showed at the end of your listing should be enough to start recording from your mic.

The error message rec FAIL sox: Sorry, there is no default audio device configured indicates that sox(1) can indeed not open /dev/dsp5. Something's off here. Can you please post dmesg | grep uaudio after you plug in your USB mic. Perhaps we can get further intel from there.
 
The error message rec FAIL sox: Sorry, there is no default audio device configured indicates that sox(1) can indeed not open /dev/dsp5. Something's off here. Can you please post dmesg | grep uaudio after you plug in your USB mic. Perhaps we can get further intel from there.

Code:
uaudio0 on uhub4
uaudio0: <vendor 0x1130 USB  AUDIO, class 0/0, rev 1.10/1.87, addr 3> on usbus2
uaudio0: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x2ms buffer.
uaudio0: No recording.
uaudio0: No MIDI sequencer.
pcm4: <USB audio> on uaudio0
uaudio0: HID volume keys found.
uaudio1 on uhub3
uaudio1: <DYNEX DYNEX USB MIC Device, class 0/0, rev 2.00/1.00, addr 5> on usbus1
uaudio1: No playback.
uaudio1: Record[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x2ms buffer.
uaudio1: No MIDI sequencer.
pcm5: <USB audio> on uaudio1
uaudio1: HID volume keys found.
uaudio1: at uhub3, port 4, addr 5 (disconnected)
uaudio1: detached
uaudio1 on uhub3
uaudio1: <DYNEX DYNEX USB MIC Device, class 0/0, rev 2.00/1.00, addr 5> on usbus1
uaudio1: No playback.
uaudio1: Record[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x2ms buffer.
uaudio1: No MIDI sequencer.
pcm5: <USB audio> on uaudio1
uaudio1: HID volume keys found.

It's clearly identified.....
 
This looks ok. I'm running out of ideas, it *should* work as described. You say the mic works with www/firefox. Do you have a media.cubeb.backend entry in about:config? Also what audio devices are listed under about:support#media? When you use the mic with firefox, what does ls /dev | grep dsp list? The /dev/dspX devices only show up in /dev when in use.
 
This looks ok. I'm running out of ideas, it *should* work as described. You say the mic works with www/firefox. Do you have a media.cubeb.backend entry in about:config? Also what audio devices are listed under about:support#media? When you use the mic with firefox, what does ls /dev | grep dsp list? The /dev/dspX devices only show up in /dev when in use.

Yes media.cubeb.backend is present.

Code:
$ ls /dev | grep dsp
dsp0.0
dsp1.0
dsp2.0
dsp3.0
dsp4.0
dsp4.1
dsp4.2
dsp5.0
dsp5.1

Thank you again!
 

Attachments

  • 2024-03-02-234144_1360x768_scrot.png
    2024-03-02-234144_1360x768_scrot.png
    79.4 KB · Views: 27
Ok, this also looks ok. Last straw for me: try the following invocations as a normal user:
Code:
$ sh -c 'AUDIODEV=/dev/dsp5 rec test.wav'
$ sh -c 'AUDIODEV=/dev/dsp5.0 rec test.wav'
$ sh -c 'AUDIODEV=/dev/dsp5.1 rec test.wav'
$ sh -c 'AUDIODEV=/dev/dsp5.2 rec test.wav'
 
For the record, the following was executed in Bourne shell. Let me know if this is helpful. Even if it isn't, I deeply appreciate the patience and succor that you extended to me in this thread. Thank you!

Code:
$ sysctl hw.snd.default_unit=5
hw.snd.default_unit: 0 -> 5
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC269 (Analog)> (play/rec)
pcm1: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <USB audio> (play)
pcm5: <USB audio> (rec) default
No devices installed from userspace.
$ sh -c 'AUDIODEV=/dev/dsp5 rec test.wav'
rec FAIL sox: Sorry, there is no default audio device configured
$ sh -c 'AUDIODEV=/dev/dsp5.0 rec test.wav'
rec FAIL sox: Sorry, there is no default audio device configured
$ sh -c 'AUDIODEV=/dev/dsp5.1 rec test.wav'
rec FAIL sox: Sorry, there is no default audio device configured
$ sh -c 'AUDIODEV=/dev/dsp5.2 rec test.wav'
rec FAIL sox: Sorry, there is no default audio device configured
 
For the record, the following was executed in Bourne shell. Let me know if this is helpful.
Unfortunately not, I'm now out of ideas. It seems sox(1) can't access the device because it can't see and open the device. But somehow www/firefox is able to do it ... 🤷‍♂️

Even if it isn't, I deeply appreciate the patience and succor that you extended to me in this thread. Thank you!
No problem, I just wished we would have solved it. This problem is weird. Hopefully you find a solution somewhere.
 
Back
Top