Recorded sound is 11X too fast and underruns

I am running Audacity 2.1.2 installed via apt on a new Ubuntu 16.04 box. The project sample rate is 44.1kHz. Software playthrough is disabled. Audacity is having 2 problems with recording:

  1. The recorded sound is 11X to fast (i.e., it is sampling at around 4kHz) and thus very short. Eventually there are underruns too.
  2. Immediately after I launch Audacity (recording or not) it causes other programs to have a similar problem. For example, the browser will record with the pitch 11X too high – though it will insert skips while Audacity does not. The problem is not resolved until I reboot the computer.

The forums suggest checking the sound driver and reinstalling Audacity. I am using built-in motherboard sound. My motherboard is an ASRock X299 OC Formula and the realtek driver is installed. After reboot, before I run Audacity, sound is working. I can record and playback in a web browser and in ardour4. I can also record a sound with:

arecord -r44100 -fS16_LE /tmp/file.wav
aplay /tmp/file.wav

Repeated recording and playback work just fine (in the browser, with arecord, or ardour4) so long as I don’t start Audacity. So it appears that the driver is working for most programs. In all cases I am using the “default” device which is Line In on the motherboard.

As suggested on the forums, I tried removing the audacity config file from ~/.audacity-data and reinstalling using

apt-get remove audacity
apt-get install audacity

but alas the recording problem remains.
I do notice the following messages when I start Audacity. I don’t know if they’re relevant.

ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
Expression 'stream->playback.pcm' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4611
Expression 'stream->playback.pcm' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4611
Expression 'stream->playback.pcm' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4611

Also when I’m recording I can see Audacity showing up in pavucontrol (pulse audio) as

ALSA plug-in [audacity]

and actually it fails in a few seconds as Audacity prints:

1: »0⋅1/1⋅1/1⋅1/1
1: »0⋅1/1⋅1/1⋅1/1
ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred

Occasionally there’s a more interesting one:

Expression 'err' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3355
Expression 'ContinuePoll( self, StreamDirection_In, &pollTimeout, &pollCapture )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3881
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4253

I also tried to compile the latest Audacity code (2.2.2) but this appears it will take some more effort, as I get “Audacity requires expat to be enabled.” despite expat being installed actually. In any case, it seems unlikely that Audacity 2.1.2 wouldn’t work on such a stable OS/mobo combination.

I also tried uncommenting this line in /etc/pulse/daemon.conf:

; default-sample-rate = 44100

and restarted pulseaudio as suggested on other forums, but it did not restore recording function (until reboot).

I would really like to use Audacity for recording on Linux. But I have tried many suggestions (check sound driver, reinstall audacity, remove config, change pulse config) and nothing seems to fix this problem of losing 91% of the samples.

Are there any other suggestions?

This is puzzling. I also have Ubuntu 16.04, and the repo version of Audacity works fine with my on-board sound card (ALC269VC Analog).

When you say that it plays 11x too fast, is it also playing very high pitched, or just very fast at normal pitch?

It is playing back very high pitched.
If I apply a 0.09X speed adjustment to the result, it has the correct pitch and is intelligible (but missing the highs of course).

In the Audacity Help menu, find the “Audio Device Info” and click on it. When the window appears, click “Save” and save the info file somewhere convenient, then attach it to your reply.

audio_devices.txt (3.36 KB)

OK, there’s something strange there: There’s no “hw:0,0” device.

Try rebooting your computer and do not launch any audio capable applications. If you have Jack installed, ensure that it does not automatically start on log-in.
Then launch Audacity and get the Audio Device Info again.
Is the info the same?
Is there a “hw:0,0” device listed?

Side issues that may or may not be related:
How did you install Ardour 4? (the Ubuntu 16.04 repo version is Ardour 3)
How are you “recording in a web browser”?

I rebooted; jack is not running (or at least there is no process with “jack” in the name). And so then I went straight to Audacity. The info is identical to what I already uploaded. There is no “hw:0,0”.

Interestingly, Audacity prints the following messages (repeated many times) while generating the info.

Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( outputParameters, hostApi, StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1846

There is no corresponding error for StreamDirection_In. But sometimes there is this when generating the info:

ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736
Expression 'AlsaOpen( hostApi, parameters, streamDir, &pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1768
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave

Also the next time I start Audacity it generates some errors I didn’t see before:

Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904
Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2171
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840

Also interestingly, if I plug in a USB recording device (Alesis io2),
the info reported by Audacity is also the same (there is no io2) yet
the io2 appears in the output of “aplay -lL” and “arecord -lL”.
aplay.txt (4.28 KB)
aplay1.txt (4.28 KB)
arecord.txt (3.17 KB)
I don’t know why Subdevices on 3 of the devices changed from 0/1 to 1/1 the second time I ran “aplay” (nor have I researched that). Anyways, the problem is with recording, not playback.



apt-get install ardour



https://online-voice-recorder.com/

No plug-ins needed… apparently JavaScript must support it. It’s probably going through the default pulseaudio device, since I don’t see a way to select the device outside of pavucontrol.

Audacity only looks for devices on start-up, and when you explicitly tell it to (Transport menu > Rescan Audio Devices).
If you plug in a USB device while Audacity is running, Audacity won’t see it.
If you plug in the device first and then start Audacity, Audacity should see it. Does it?

If you plug in the device first and then start Audacity, Audacity should see it. Does it?

Yes, how about that!
Indeed, sometimes Audacity does see the io2 if I already had it plugged in, and hadn’t run Audacity before (since reboot).
In that case the device info reported is as follows.
audio_devices4.txt (7.52 KB)
When I try recording with the io2, it seems to play back at a lower pitch. This is the case when I select either “io2: Front Mic:0” or “io|2: USB Audio (hw:2,0): Front Mic:0” as the input. It appears that it is recording at 48kHz even though my project rate (and track rate) are 44.1kHz. (If I change the track rate to 48kHz after recording, the pitch is corrected). This is puzzling because the “io2” and “io|2” devices both support 44.1kHz (as well as 48kHz). Though the 44.1 vs 48 problem seems more common:

and perhaps more work-aroundable (I might consider changing my project to 48kHz… but not 4kHz).


Do any of these observations shed any light on the issue I was having with sound input from the built-in device?

In this one, you have:

Device name: HDA Intel PCH: ALC1220 Analog (hw:0,0)

This suggests that when you previously tried, some other application had grabbed exclusive access to the hw:0,0 device, so it was not available for Audacity.
All other “hw:0,x” devices are physically part of the same device, so it is not surprising that the sound system gets messed up when Audacity tries to access a sub-device when another application has grabbed exclusive access to the first sub-device.

Try selecting hw:0,0 as the recording and playback device (now that it is available).

There’s something not quite right about your sound system - quite possibly due to the on-board sound card not being fully supported on Linux. If we can achieve a reasonable workaround, then that may be the best we can achieve.

I’m having the exact same issue here, and it’s been driving me crazy.

Recording from the microphone input (tried default and specifying the source manually) records way too fast… the line creeps across the screen, and when I do play it back, it’s just unintelligibly fast.
Changing the project rate to 384,000 Hz helps a little, but it’s still much too fast.

This is using Audacity 2.2.2 from the https://launchpad.net/~ubuntuhandbook1/+archive/ubuntu/audacity repo.

I’ve attached my audio diagnostic output as well, this is on Xubuntu Artful (17.10) on an MSI X370 AMD motherboard. I’ve also added some info from lspci and dmesg on startup.
I also went ahead and booted into a live USB of 18.04 to validate if it was still an issue, and the same thing happened using the same version of Audacity within the live distro.
lspci-dmesg.txt (2.16 KB)
diaginfo.txt (7 KB)

Hi!

Little history first.

Over 10 years ago I bought cheap headset with mic. It’s old but it still works. It plugs into USB. Pulse audio always disabled it on hello. In past my solution was to rip the pulse audio out of Xubuntu and depend entirely on alsa. However, when I got to play with gui sound recorder audacity it just slow recorded everything, so I heard instead of my voice, some chipmunk. So until now, I was opting to never use audacity.

What I did to change that after a decade on this 18.04?

Well, first I picked slow and bad fight with Pulse Audio to make the mic work. I was just messing with setting. Switching things off and on. Googling for any edits to /etc/modprobe.d/xxx.conf and /etc/pulse/xxx.conf files, which i run with pulseaudio -k & pulseaudio --start. I was installing different alsa mixers to make it break in. I killed all boost to mic and I think this was a major thing for mic to react to my voice. However all other sounds, which worked just fine were going to hell. Furthermore mic sounds were not ending into any system sounds or recordings. Nothing helped. Then in the end all sounds went off. So, I had to remove all changes to all those xxx.conf files in hope to get them back. Nothing helped. So out of desperation I pressed few times too many “amixer sset Master unmute” and “amixer -D pulse sset Master toggle” and in the end I got a surprise. I got all sounds back plus as the bonus… the mic. Yay! I still am not sure, what was exactly broken with pulseaudio or mic or how I finally fixed it. It is a miracle. I am in settings for pulseaudio exactly there where I was, when I discovered this issue with my mic. Then it came time for trying audacity out. I got chipmunks again. Decade passing by and… still chipmunks. Depressing. The “play-at-speed” feature set at 0,1 played it somehow naturally. However arecord and aplay were recording and playing everything just fine. After my traumatic experiences with getting mic to work, I just refused to do anything with sound settings in pulseaudio. Audacity broke it, then audacity fix it, right?

My workaround for the chipmunks in audacity.

Instead of “pulse” I set playback “iec958” and correct mic recording device, which in my case is “HDA intel PCH:ALC1220 altAnalog (hw:0,2):line1”. Then I record for a moment. Though there is no sound in recording, the speed of recording suddenly goes at 1sec per 1sec. After undo-record, I reset “pulse” back for playback and “pulse:front mic1” for recording. I record again. This time audacity records from my mic at normal speed and then plays it at normal speed. No chipmunk there no more and no other sound artifacts either.
My sound cards are (command> inxi -Fxz):
Card-1 Intel 200 Series PCH HD Audio driver: snd_hda_intel bus-ID: 00:1f.3
Card-2 NVIDIA GP104 High Definition Audio Controller driver: snd_hda_intel bus-ID: 01:00.1
Sound: Advanced Linux Sound Architecture v: k4.15.0-45-generic

List of my capture devices is (command> arecord -l):
card 0: PCH [HDA Intel PCH], device 0: ALC1220 Analog [ALC1220 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: ALC1220 Alt Analog [ALC1220 Alt Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0

My Audacity is version 2.2.1 from Xubuntu 18.04.01’s depo.

My hope is, that my workaround will work for other sad Ubuntu users, who are hitting this chipmunk issue with Audacity.

This gives this application a second chance. Just this workaround needs to be done, after each time Audacity is started. The correct recording and playing pattern for some reason is not kept by audacity permanently around. Little annoying tbh. My guess is the issue is that mic uses max 48000, while default in pulse and in audacity are 44100 and while my sound card has settings, which goes even up to 384000 Hz. I was messing recordings with setting different Hz, without “record undo” and once, though not repeatably I succeeded to get audacity to record at normal speed when recording at 192000Hz. This had a strange visual effect though. The wave seemed to slowly stretch out from its compressed state into full length. This took like 1-2 seconds, so it was quite noticeable, as I was not using any effects or such. It was just weird. I played this part of recording and it was the only place in recording, where among chipmunks a normal human voice was appearing for a while. Just a one time weird thing.

Good luck! …and sorry for my broken English. :slight_smile: