StepanD
Posts: 4
Joined: Mon May 04, 2020 11:19 pm

Audio recording (over USB) stuttery on RPi4

Tue May 05, 2020 12:00 am

I am observing regular gaps ("stutter" or "skipping) when recording audio over USB. The screenshot is of me making constant sound into the microphone while recording using Audacity, and the gaps are evident:
Image

The gaps are constantly spaced, and happen almost always, although there were a few exceptions when the recording was uninterrupted. The hickups are short, but clearly disruptive to any reasonable recording, even just for voice calls.

I have tried two devices:
1) Jabra 510+ (using both wireless and wired connection)
2) SoundBlaster X-Fi Surround 5.1

Given that two very dissimilar USB devices presented the same problem, I have also tried plugging into USB2.0 ports, USB3.0 ports, turning off BT and WiFi while recording. I have also tried unplugging essentially all other USB devices. I have received the same results in each experiment.

As a baseline, I have tried using Audacity with the Jabra 510+ on another computer. Recording was flawless.

I'm kind of at a loss where to even start. My knowledge of USB stack is pretty much non-existent, but I'm happy to shotgun-debug with any ideas anyone might have -- module parameters, firmware versions, power saving options, etc.

User avatar
Botspot
Posts: 1265
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: Audio recording (over USB) stuttery on RPi4

Tue May 05, 2020 6:13 pm

Maybe the problem is Audacity - does the same problem happen when recording using other software?
Try simplescreenrecorder - I've used it before to record my screen and my narration via a mic. I don't remember any stuttering.
Ever wished you could "open" a RaspiOS .img file? Well now you can! I've developed Pi-Power-Tools, the only RaspiOS img editor on the planet.
https://github.com/Botspot/Pi-Power-Tools
Want to try it out?

Code: Select all

wget -O - https://raw.githubusercontent.com/Botspot/Pi-Power-Tools/master/update | bash

renice123
Posts: 198
Joined: Tue Oct 15, 2019 3:56 pm

Re: Audio recording (over USB) stuttery on RPi4

Wed May 06, 2020 5:11 am

Most likely problems should be sought:

0. Poor configuration of working with the cache - a slow sd card does not have time to process requests and freezes. Take the program cache to the "virtual disk". As a rule, this is enough so that the program does not freeze during a data reset.

1. RPI4 is overloaded with tasks - the simultaneous launch of some processes, programs. Check with the top and ps -A commands, see what services start when the RPI boots
It is known that after the implementation of systemd, written by a poor programmer (he is the author of the buggy pulseaudio), problems of a different kind began. So breaks may well
be associated with a huge amount of unnecessary garbage in the background. This garbage eats up processor resources and is extremely difficult to detect.
Check which services start automatically.

2. Perhaps you have some high-speed devices hanging on usb. For example, ssd drives.

3. Look at the sound settings. I occasionally experienced stuttering due to resource-intensive professional sound cards. I had to abandon hi-fi and die appetites to 48/24

PS I hope you are not using pulseaudio?

StepanD
Posts: 4
Joined: Mon May 04, 2020 11:19 pm

Re: Audio recording (over USB) stuttery on RPi4

Wed May 06, 2020 7:58 pm

Hey,

thanks all for the ideas!

- Audacity does not seem to be the issue, as I experience it with other applications also. Having said that, I'll try to keep using it as a playground, and maybe have it cache on tmpfs or something to make sure it's not I/O. The SD card is also a high-end one which I'm using for photography, precisely because the more low-end ones sucked :)

- Nothing really specific running in the background, this is a pretty much vanilla Raspbian install. I'll give it a scrub though, just in case.

- I am _suspecting_ that I am experiencing the same audio defects on output as well, but only under some conditions, and I have not yet gotten to the bottom of it. So this may be red herring.

- I've tried disconnecting all devices beyond the USB audio and my USB wireless keyboard (Logitech K400 Plus, in case that's a bad choice), and that was of no help.

- No Pulse audio anywhere in my household :-)

- When you say "Look at the sound settings", what do you have in mind?

Thanks,
- Steve

pjnoxon
Posts: 32
Joined: Sun Apr 05, 2020 7:15 am

Re: Audio recording (over USB) stuttery on RPi4

Thu May 07, 2020 12:54 am

Go over to Audacity > Edit > Preferences > Devices and check the Buffer length

it probably needs to be larger.

What are the other settings:
Host
Playback Device
Recording Device and Channels

Also check Audacity > Edit > Preferences > Recording

maybe something amiss in there with Sound Activated Recording?

How about Audacity > Edit > Preferences > Quality

Have you turned on the stutter effect?

lingon
Posts: 158
Joined: Fri Aug 26, 2011 7:31 am

Re: Audio recording (over USB) stuttery on RPi4

Thu May 07, 2020 2:54 pm

Which version of the VL805 firmware do you have? Run

Code: Select all

sudo rpi-eeprom-update
to find out the version. There is a new VL805 beta firmware available. It could be worth trying: viewtopic.php?f=29&t=273027#p1654842

renice123
Posts: 198
Joined: Tue Oct 15, 2019 3:56 pm

Re: Audio recording (over USB) stuttery on RPi4

Fri May 08, 2020 11:22 am

RPI uses a somewhat unusual sound configuration. This means that RPIs abandoned the traditional Debian pulseaudio in the world (I also hate this program), and also uses the Baster kernel, which does not work well with some sound cards. Unfortunately, these Buster errors are critical and did not allow me to use my sound card on RPI4 at all. However, if I roll back to Jessie (for example, on Volumio), then my sound card works.
The problems with the sound were unusual and “as if random” - the sound card sometimes worked, sometimes it stopped working and it was impossible to restore the sound without rebooting. Thus, I can say that some sound card chipsets are simply not supported by Buster.
However, “stuttering” is more likely for a computer overloaded with processes (or a process) than for a kernel driver failure. I got them almost constantly if I watched HD video or listened to HQ sound. I partially got rid of “stuttering” when I started using the virtual file system for the program cache (Chromium and others) and when I abandoned LXDE in favor of a less energy-intensive window manager. In particular, window manager applets can cause stuttering if you have a monitor for memory, processor resources, etc.

StepanD
Posts: 4
Joined: Mon May 04, 2020 11:19 pm

Re: Audio recording (over USB) stuttery on RPi4

Mon May 18, 2020 12:15 am

It took me a while to get back to this, sorry about that, and thanks y'all for help so far! Intermediate results:

1) In Audacity, I'm not using sound-activated recording. Also, changing buffering had no effect on performance. In general, Audacity does not seem to be CPU intensive at all.

2) Current firmware is 137ad; somewhat reluctant to jump on a firmware from somebody's gdrive folder:) I don't know enough about USB to tell from the changelog if it'd be relevant, but perhaps it won't be too long before the firmware is available through more regular paths?

pjnoxon
Posts: 32
Joined: Sun Apr 05, 2020 7:15 am

Re: Audio recording (over USB) stuttery on RPi4

Tue May 19, 2020 6:06 pm

This is certainly a very interesting problem, sorry I am sure it is frustrating too.
The gaps are constantly spaced, and happen almost always, although there were a few exceptions when the recording was uninterrupted. The hickups are short, but clearly disruptive to any reasonable recording, even just for voice calls.
Are you experiencing this problem when making some sort of a call? Is the RPi involved in the making of this call?

This would bring up the possibility of the speakerphone needing to send the audio to both Audacity and another program.

We should concentrate on those few exceptions where the recording was uninterrupted.

In another thread there was a similar problem when someone had a USB 2 device plugged into a USB 3 port.

StepanD
Posts: 4
Joined: Mon May 04, 2020 11:19 pm

Re: Audio recording (over USB) stuttery on RPi4

Sat May 23, 2020 6:13 pm

During testing, Audacity is the only application (beyond desktop environment etc.) that's running. No ongoing call of any kind.

I've tried both USB2 and USB3 ports, no apparent change.

Return to “Troubleshooting”