Playback with pulseaudio on Ubuntu

Help for Audacity on GNU/Linux.
Forum rules
ImageThis forum is for Audacity on GNU/Linux.
Please state:
  • which version of Linux you are using,
  • the exact three-section version number of Audacity from Help menu > About Audacity,
  • whether you installed your distribution's release, PPA version, or compiled Audacity from source code.

Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade (see https://www.audacityteam.org/download/).
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Playback with pulseaudio on Ubuntu

Post by steve » Tue Nov 05, 2013 8:35 pm

Uef wrote:Extremely fast.
I try record my desktop. File in attachments.
I was not expecting it to be like that. Thanks for the video, that illustrates the problem perfectly.
Unfortunately I have no idea what is causing it - I've never seen anything like that before.

I'll ask around and see if anyone has any ideas.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Playback with pulseaudio on Ubuntu

Post by steve » Wed Nov 06, 2013 9:03 pm

I've had a reply from the maintainer of that PPA.

The PPA build that you have has been tested and is not at fault. You should get the same results when building audacity from source with the same configure flags (preferring system libraries over local libraries). If you have non-standard system libraries (libraries that you have manually updated or modified) then the problem could be an issue in one of those.

We think that it is unlikely that the problem lies in or between ALSA and the hardware because we would expect that if that were the case then you would also have problems playing back from DeadBeef and RhythmBox.

What that leaves is the stuff between Audacity and ALSA.
The setup is: Audacity -> Portaudio -> alsa-pulseaudio bridge -> pulseaudio -> ALSA -> hardware.

Personally I think that the most likely place is the "alsa-pulseaudio bridge" because the following appear to work correctly:
Audacity -> Portaudio -> ALSA -> hardware.
DeadBeef -> pulseaudio -> ALSA -> hardware.
though it is also possible that it lies in:
Portaudio -> alsa-pulseaudio bridge

Unfortunately if the problem is somewhere in "Portaudio -> alsa-pulseaudio bridge -> pulseaudio", it's not something that we can fix because it is not our code. It would also be tricky for the guys at Portaudio, ALSA or PulseAudio to fix it either because it seems to be specific to the requirements of the E-MU 0204 and possibly also specific to 64 bit architecture.

I'm trying to think of some sort of workaround that will not be too inconvenient for you.

One possibility would be to try running Audacity with "Jack Audio System".
"Jack" (also known as "jackd") is a high performance sound system. It is great for working with audio and multi-media, but it can be difficult to set it up so that it plays nicely with PulseAudio. If you already use Jack, then please try using Audacity with Jack.

If you don't already use Jack, then I'll try and think of some other option.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Uef
Posts: 16
Joined: Mon Nov 04, 2013 10:16 am
Operating System: Please select

Re: Playback with pulseaudio on Ubuntu

Post by Uef » Thu Nov 07, 2013 9:46 pm

I found the reason of the problem.
At Skype installation I followed the topic recommendation:
http://community.skype.com/t5/Skype-%D0 ... d-p/261858
for noise elimination in Skype.
I added the "load-module module-udev-detect tsched=0" parameter in "/etc/pulse/default.pa"

It caused the wrong reproduction in Audacious
I am sorry for wasted time and thanks for participation.

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Playback with pulseaudio on Ubuntu

Post by steve » Fri Nov 08, 2013 1:32 am

Uef wrote:I found the reason of the problem.
At Skype installation I followed the topic recommendation:
So is the problem fixed now?
Thanks for getting back to us, but I don't speak Russian and Google Translate is imperfect.
For my understanding of this problem (in case it occurs for other users) could you describe in more detail how and why you (inadvertently) created the problem, and how you fixed it. In particular, what is "load-module module-udev-detect tsched=0" supposed to do and why does that mess up recording with Audacity?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Uef
Posts: 16
Joined: Mon Nov 04, 2013 10:16 am
Operating System: Please select

Re: Playback with pulseaudio on Ubuntu

Post by Uef » Fri Nov 08, 2013 2:54 pm

My english isn't better than google :)

Now the problem is solved and I continue to use Audacity.
...
One day after the next update, Skype sound began to play with real scratch.
I found decision in skype community - add "tsched=0" parameter to udev initialization string in "/etc/pulse/default.pa" file.

Really I don't know what means this parameter, and on what it influences in pulseaudio system, but it became a solution of the problem with Skype and led to effect which I showed in video from my desktop.

Спасибо Стив!

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Playback with pulseaudio on Ubuntu

Post by steve » Fri Nov 08, 2013 3:41 pm

Uef wrote:Now the problem is solved and I continue to use Audacity.
Excellent.
Uef wrote:I found decision in skype community - add "tsched=0" parameter to udev initialization string in "/etc/pulse/default.pa" file.

Really I don't know what means this parameter, and on what it influences in pulseaudio system, but it became a solution of the problem with Skype and led to effect which I showed in video from my desktop.
Thanks, that makes sense now.

I found here: https://wiki.archlinux.org/index.php/Pu ... _crackling
tsched=0 turns off time based scheduling, but without that your sound card started "free-wheeling" and so playing super-fast.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

jimford
Posts: 2
Joined: Fri Jun 13, 2014 3:35 pm
Operating System: Please select

Re: Playback with pulseaudio on Ubuntu

Post by jimford » Fri Jun 13, 2014 4:04 pm

I'm pretty sick of this Audacity problem at the moment, though I suspect it might be down to Pulseaudio. In the 10-15 years I've been using Ubuntu/Xubuntu, I can't say I've seen Pulseaudio working reliably on any machines I've used, and It beats me why a fundamental part of an OS doesn't work 'out of the box' and needs in-depth 'fiddling'!

Anyway, I've got the 'galloping playback' syndrome - where playback occurs at about 10 times normal speed and if it is paused or stopped, Audacity locks up and has to be killed. Sometimes the playback will randomly switch to normal at some point in the track.

I'm using:
Audacity 2.0.5
Xubuntu/Ubuntu 14.04
Pulseaudio 4.0

It's all very frustrating, and I'm now seriously considering searching for a distro that doesn't use the Pulseaudio sound server (and 'yes' I have tried several times reinstalling Pulseaudio and Audacity).

Jim

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Playback with pulseaudio on Ubuntu

Post by Gale Andrews » Sat Jun 14, 2014 5:55 am

jimford wrote:I'm pretty sick of this Audacity problem at the moment, though I suspect it might be down to Pulseaudio. In the 10-15 years I've been using Ubuntu/Xubuntu, I can't say I've seen Pulseaudio working reliably on any machines I've used, and It beats me why a fundamental part of an OS doesn't work 'out of the box' and needs in-depth 'fiddling'!
Linux is thousands of different libraries stitched together. Usually it works amazingly well but if you use Linux you have to be prepared to dig around in configuration settings if things don't work. If you want things to always "just work" you are on the wrong OS.
jimford wrote:Anyway, I've got the 'galloping playback' syndrome - where playback occurs at about 10 times normal speed and if it is paused or stopped, Audacity locks up and has to be killed. Sometimes the playback will randomly switch to normal at some point in the track.

I'm using:
Audacity 2.0.5
Xubuntu/Ubuntu 14.04
Pulseaudio 4.0

It's all very frustrating, and I'm now seriously considering searching for a distro that doesn't use the Pulseaudio sound server (and 'yes' I have tried several times reinstalling Pulseaudio and Audacity).
Uninstalling pulse and Audacity won't make a scrap of difference but as a starting point you should initialise the audacity.cfg settings file so Audacity runs at default settings. Please see here for how to do that: http://manual.audacityteam.org/o/man/pr ... tml#stored .

Have you tried some of the things mentioned in this topic? Have you tried selecting the (hw) devices in Device Toolbar so that you get direct access to the devices, bypassing pulse?

If you want to use pulse, have you tried: https://wiki.archlinux.org/index.php/Pu ... _crackling ?

What are you actually playing? If it's a recording from computer playback you may have sample rate mismatches somewhere. Some audio devices on Linux will only function property at 48000 Hz and do bizarre things at other rates. Pulse should sort sample rate mismatches out in theory but it doesn't always.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

OmnipotentEntity
Posts: 2
Joined: Tue Jun 17, 2014 12:05 pm
Operating System: Please select

Re: Playback with pulseaudio on Ubuntu

Post by OmnipotentEntity » Tue Jun 17, 2014 12:08 pm

Crossposting a workaround that's been discussed elsewhere for this problem.

If you run audacity with the environment variable PULSE_LATENCY_MSEC set to any value (for instance, 30 or even 1), then pulse does not exhibit these symptoms.

Code: Select all

env PULSE_LATENCY_MSEC=1 audacity

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Playback with pulseaudio on Ubuntu

Post by steve » Wed Jun 18, 2014 2:41 am

OmnipotentEntity wrote:Crossposting a workaround that's been discussed elsewhere for this problem.

If you run audacity with the environment variable PULSE_LATENCY_MSEC set to any value (for instance, 30 or even 1), then pulse does not exhibit these symptoms.

Code: Select all

env PULSE_LATENCY_MSEC=1 audacity
Thanks OmnipotentEntity. I see there are multiple confirmations of this workaround on the Ubuntu bug tracker: https://bugs.launchpad.net/ubuntu/+sour ... ug/1246092

From a short amount of testing, it looks to me like a value greater than 1 may sometimes be required.
The original posted suggestion with a value of 30 looks very promising to me at the moment.

I've been unable to reproduce Audacity bug 276 when using:

Code: Select all

env PULSE_LATENCY_MSEC=30 audacity
Rather than Audacity freezing with the bug 276 test case, I get an occasional (and harmless) "underrun".

Code: Select all

ALSA lib pcm.c:7339:(snd_pcm_recover) underrun occurred
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply