Record USB audio input


29 posts   Page 1 of 2   1, 2
by neoben » Tue Jul 10, 2012 7:44 pm
I tried to record the sound input from the LogiLink sound card listed on the hardware support page.

It works great on my desktop but delivers poorly on the RPi due to a heavy noise. I tested the device using arecord/ffmpeg and alsa...

Has anybody else been successful with a different USB device to record audio with a decent/good quality?
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by mahjongg » Tue Jul 10, 2012 8:56 pm
Do you use it directly on a USB port of a PI?
Are you aware that these are only good for official "low power low speed devices", as only these can work with the limited power the USB fuses of the R-Pi let through?
The excessive noise might be an indication that some of the logic on the USB adapter doesn't get enough power!

The solution might be to use a powered hub (that also powers the PI), but there might be software problems with such a setup.
Another solution is to solder two 0.5 Ohm resistors over both polyfuses (F1 and F2).

Note that the `R-Pi was not designed to support such USB devices.

Post edit:
As per revision 2 boards (the ones with mounting holes) the above problem has largely disappeared, as polyfuses F1 and F2 were removed from the design.
User avatar
Forum Moderator
Forum Moderator
Posts: 6043
Joined: Sun Mar 11, 2012 12:19 am
by neoben » Tue Jul 10, 2012 9:30 pm
Hi,

The sound card is directly connected to the RPi.
I am using Debian Squeeze with the default Alsa configuration.

mahjongg, thanks for the reply!!

I cannot find the power consumption specs for the UA0053 LogiLink sound card, but I guess it consumes more than 100mA... I am trying to keep the RPi and accessories cheap and compact; so I might go for the two resistors or look into some low power I2C ADC modules...if it exists.

ben
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by neoben » Tue Jul 10, 2012 10:15 pm
Forgot to mention something that may help troubleshoot: the audio output works great! Maybe not a power supply issue in the end??
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by observing » Wed Jul 11, 2012 2:56 am
I'm getting the same results as neoben from a usb audio adapter with a C-Media chipset connected through a powered hub
Posts: 43
Joined: Mon Feb 27, 2012 12:18 pm
by r4049zt » Sat Jul 21, 2012 3:11 pm
Check for ground connections.
A multimeter from your audio device earth to a bare metal part of your audio computer such as the 'H' on the metal of the ethernet socket can test whether there is an earth connection.

Some soundcards tie the cableground outer sheath to the earthed metal case, and some don't tie audio cable-ground to any local earth. I don't know the rPi yet to know which.

The former is better for microphones and other handheld audio devices, whilst the latter is better for equipment which earths the cable ground at the other end, such as a hi-fi.

Signs of an earth loop problem (apart from destructive failure) can be noisy audio input, emphasising 50 Mains with an ugly waveform shape. A non-connected cable earth gives an undefined audio input which wanders up and down erratically. If unsure about poking, check with 1k-ohm resistors first. Those don't fix any fault but are reasonably safe for prodding things with. A multimeter on its ohm-meter setting can distinguish between connected (1001 Ohms) and not connected.
User avatar
Posts: 93
Joined: Sat Jul 21, 2012 1:36 pm
by thexman » Sun Jul 22, 2012 11:20 pm
mahjongg wrote:Do you use it directly on a USB port of a PI?


Note that the `R-Pi was not designed to support such USB devices.


Shame that's not an official quote but all USB hosts should be 100% backwards comparable it makes no sense not too

And I've already started to make a big list of things that don't work because there v1 or v1.1 devices
one armed controls engineer, my grammar is bad but lets face it most keyboards don't suit a one armed man
Posts: 259
Joined: Sat Apr 07, 2012 2:18 pm
by neoben » Sun Aug 12, 2012 6:13 pm
Hello,

Tried both suggested approaches:
- solder two 0.5 Ohm resistors over both polyfuses (F1 and F2).
- use a USB powered hub (Logik l4thub10)

No success...the sound quality is as terrible as it was before:
>arecord -d 10 -D plughw:1,0 test.wav

I have updated to wheezy raspbian since my initial tests...
Any other suggestions? Has anybody else been successful with this (mic or webcam)?
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by observing » Mon Aug 13, 2012 1:19 am
Since I last posted in this thread, I have seen greatly improved results under Raspian by setting the sampling rate to 48000 Hz. This might be specific to the chipset of my audio adapter (C-Media), but note that the default sampling rate is 8000 Hz. Also, see the thread: ALSA and Debian Squeeze 19-04-2012 (viewtopic.php?f=50&t=8561).
Posts: 43
Joined: Mon Feb 27, 2012 12:18 pm
by pholy » Mon Aug 13, 2012 1:48 am
There have been reports that low sampling rate files have problems with playback. I believe Dom is aware of these problems and working on a fix (or fixes). You might try installing sox and converting a file up to 48000 - although re-recording is obviously best, this would test the theory. I wish we could get an alsa expert interested in the Raspberry....
Posts: 42
Joined: Sun Jun 24, 2012 11:29 pm
by neoben » Mon Aug 13, 2012 8:17 pm
Thanks for your feedback.
Still very disappointed at 48000hz... If I had to rate the quality from 1 to 10 where 1 is the quality at 8000hz and 10 the quality when the usb sound card is connected to my Mac, it would be 2: clicks, pops and constant background noise...
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by paulie » Mon Aug 13, 2012 8:41 pm
To get more info on your usb devices:

lsusb -v¦ less

Where ¦ is the pipe character, which is a solid vertical bar ( but not present on my phone keyboard ).
I too have a c-media usb soundcard and Will try to get it working this week.
Need audio in & out to get soundmodem for xastir/APRS.
Posts: 183
Joined: Thu Jan 19, 2012 6:51 pm
by neoben » Tue Aug 14, 2012 7:45 pm
Hi paulie,

This is the device : ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
Looks like the same as you.

The sound card is: UA0053 USB Soundcard with Virtual 3D Soundeffects LogiLink.

It listed on the verified peripherals on the rpi wiki.

thanks
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by TJ Shickley » Fri Aug 24, 2012 12:18 am
I hope we can get this worked out. I'm a Linux noob but an amateur radio operator. I want to interface my RPi to my transceiver for digital transmission modes and CW. This is an interesting thread for this. TJ Shickley AKA KB3VLW also on gmail.
Posts: 3
Joined: Wed Aug 22, 2012 2:53 am
by mahjongg » Fri Aug 24, 2012 12:48 am
perhaps an isolation transformer before the input will help, or perhaps grounding the PI, normally the only ground path the PI gets is when its grounded through a HDMI monitor and the HDMI cable.
With an ungrounded PI there will be all kind of high voltage noises on the GND of the PI, which may cause unwanted audio currents into the audio input, if grounds are not galvanically isolated (with an audio transformer).
User avatar
Forum Moderator
Forum Moderator
Posts: 6043
Joined: Sun Mar 11, 2012 12:19 am
by obcd » Fri Aug 24, 2012 11:52 am
The usb port has a ground signal, and if you plug in a device in an usb sound card, the ground of that device and the ground of the Pi should be on the same potential.
I think it's again a case of usb packet loss. Audio adapters are streaming devices that use the isochronous transfer protocol. Basically with that protocol, there is no error checking on the usb data packets as there is no time to resend them. So, if packets get errors or become missing, this will be heared as noise and clicks. I have done tests with a very old webcam. (Uses the same usb protocol to transfer it's video.) Even at 1 frame/sec I couldn't get a stable picture out of it. I will repeat my tests with an old desktop running debian to make sure it's not the webcam itself, or the software I use to stream the picture. I have no usb or mouse connected, just the webcam. Using a powered hub, or connecting it directly doesn't make a difference. As usual, the webcam works fine on an x86 pc. On Ubuntu running under virtual box, it doesn't run either. It seems that webcam sharing between the host and a client isn't working. That's why I will test a native debian machine.
Posts: 890
Joined: Sun Jul 29, 2012 9:06 pm
by f6bvp » Sun Aug 26, 2012 1:59 pm
Good news for amateur radio Raspberry Pi users !

After creating a new system with August 16 raspbian image on my second RPi
and updating (upgrading) the system,
I found that hamradio mkiss, ax25 and rose were already compiled into the kernel.
This is great for this means that there is no need to build a custom kernel for hamradio any more.

73's de Bernard, f6bvp
Posts: 9
Joined: Fri Jun 22, 2012 9:22 pm
by neoben » Sun Aug 26, 2012 3:48 pm
Hi,

After further testing, the command:
Code: Select all
pi@raspberrypi ~ $ arecord -f dat test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo


definitely yielded some good results. Still some blips here and there, but that's perfectly usable (i would rate it a 8/10 where 10 is the quality of the mic when used on my mac).

FYI, the worst parameterization is U8 8000Hz. Thanks for keeping me going on this one.

Ben
Posts: 10
Joined: Sun Jul 08, 2012 10:34 pm
by VoltVader » Wed Oct 03, 2012 5:05 am
neoben wrote:Hi,
Code: Select all
pi@raspberrypi ~ $ arecord -f dat test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo


definitely yielded some good results. Still some blips here and there, but that's perfectly usable (i would rate it a 8/10 where 10 is the quality of the mic when used on my mac).
Ben


Ben, I'm curious what your alsa config settings are?
User avatar
Posts: 3
Joined: Tue Sep 11, 2012 12:36 am
by mrraspberrypi » Sun Oct 07, 2012 2:25 am
I would be interested to know as I've spent DAYS looking for a way to stream audio via a usb audio device. Please report full configs and settings please I would really appreciate it. :P
Posts: 10
Joined: Tue Sep 25, 2012 2:37 am
by Steve-o » Sun Oct 07, 2012 3:00 pm
USB soundcards (and webcams) use isochronous transfers which are broken in the raspberry pis usb driver. You will have to wait for a fix before using the usb soundcard.
Posts: 15
Joined: Tue Mar 06, 2012 8:24 pm
by sleep lack » Sun Oct 07, 2012 5:47 pm
Alternatively, force the pi to run at USB 1.1 speed, those parts of the driver seem to work OK with isochronous traffic it seems. To do that, add:
dwc_otg.speed=1
into your /boot/cmdline.txt file and reboot. It slows down network traffic as well, but might be an acceptable tradeoff if it helps.
Posts: 19
Joined: Thu Mar 08, 2012 3:33 pm
by odokemono » Sun Oct 07, 2012 11:46 pm
sleep lack wrote:Alternatively, force the pi to run at USB 1.1 speed, those parts of the driver seem to work OK with isochronous traffic it seems. To do that, add:
dwc_otg.speed=1
into your /boot/cmdline.txt file and reboot. It slows down network traffic as well, but might be an acceptable tradeoff if it helps.


Even with that parameter, I'm still getting nasty pops, as seen in these scope caps: http://imgur.com/a/rVR99

The third cap is produced by sox's synth, so no concurrent I/O.

cat /proc/cmdline:
Code: Select all
dma.dmachans=0x3c bcm2708_fb.fbwidth=720 bcm2708_fb.fbheight=480 bcm2708.boardrev=0x2 bcm2708.serial=0xf8ea0704 smsc95xx.macaddr=B8:27:EB:EA:07:04 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait dwc_otg.speed=1
Posts: 3
Joined: Tue Nov 29, 2011 8:27 pm
by mrraspberrypi » Thu Oct 11, 2012 12:44 am
I just tried setting the device to use USB 1.1 as suggested above and it had no effect. So we have to wait for the next release? Does this mean the 3 rapsberry pi's I purchased are useless, as I've just read that there is a new revision of the pi due to appear with audio fixes http://www.raspberrypi.org/archives/1929
unless you have a specific requirement to add an audio codec
Posts: 10
Joined: Tue Sep 25, 2012 2:37 am
by tedhale » Mon Oct 29, 2012 3:16 pm
Your existing RasPis will be fine. You will need to update the firmware and install a new kernel (well, probably just flash the new one) and be good to go. Hopefully with less noise. (at least, once they fix the async USB problems.)
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 112
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA