User Tools

Site Tools


doc:appunti:linux:audio:audio_recording_usb_adapter

Audio recording with wireless mic and USB adapter

Ugreen USB Audio Adapter We tried and Ugreen USB audio adapter.

The microphone socket is a 3.5 mm TRS type (three poles), it provides a bias current of 2.6 V on both the tip and the ring, so it is advisable, as reported in the device manual, to NOT use a simple two poles mono jack (TS type), because it will short-circuit the bias current on the ring with the ground on the sleeve.

The device is detected by the Linux Kernel 4.9.0 in this way:

usb 2-1.3: new full-speed USB device number 5 using ehci-pci
usb 2-1.3: New USB device found, idVendor=0d8c, idProduct=0024
usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-1.3: Product: USB Advanced Audio Device
usb 2-1.3: Manufacturer: C-Media Electronics Inc.
input: C-Media Electronics Inc. USB Advanced Audio Device as /devices/pci0000:00/0000:00:1d.0
    /usb2/2-1/2-1.3/2-1.3:1.3/0003:0D8C:0024.0004/input/input18
hid-generic 0003:0D8C:0024.0004:
    input,hidraw2: USB HID v1.11 Device [C-Media Electronics Inc. USB Advanced Audio Device]
    on usb-0000:00:1d.0-1.3/input3

Setting volume with ALSA

Launching alsamixer and hitting F6 you can select the USB Advanced Audio Device sound card. Hit F4 to view the only one capture device, i.e. the microphone input line. Press Space to enable/disable the capture and Up/Down arrows to increase/decrease the gain.

It seems that the best setting for audio recording through the mic, is to keep the capture mic gain to 100:

USB Advenced Audio Device in Alsamixer

Setting volume with PulseAudio

I use the PulseAudio subsystem above the ALSA modules (this is the preferred method in modern GNU/Linux distro). In this case the volume is controlled via the graphics app pavucontrol or on the command line using the pacmd tool. The PulseAudio recording volume level should be between the base volume (value 20724) and the 100% (value 65536).

Recording audio with PulseAudio

Here are the commands to start an audio recording using a shell script:

#!/bin/sh
SOURCE='alsa_input.usb-C-Media_Electronics_Inc._USB_Advanced_Audio_Device-00.analog-stereo'
PORT='analog-input-mic'
VOLUME=65536
pacmd set-default-source "$SOURCE"
pacmd set-source-port "$SOURCE" "$PORT"
pacmd set-source-volume "$SOURCE" "$VOLUME"
pacmd set-source-mute "$SOURCE" 0
parecord --verbose --device="$SOURCE" --channels=1 --fix-rate foobar.wav

WARNING: The audio files produced by this USB adapter do not cover the entire 16-bit range; the values returned (converted into float dB) extend from -0.5 to +0.5, i.e. exactly the half of what expected (-1.0 to +1.0). Above that values, the audio is clipped. You can view this in the pavucontrol monitor: it does not matter how loud you speak into the microphone, the volume meter bar never reaches the full scale. So it is advisable eventually to lower the volume (e.g. to 75% or 50%) to avoid clipping, and to proceed with post-processing software amplification.

doc/appunti/linux/audio/audio_recording_usb_adapter.txt · Last modified: 2020/12/28 17:18 by niccolo