Is it me or is it a bug?

Version: Ubuntu 18.04 LTS
Audacity: 2.2.2
Distribution release

I know that this may sound trivial to some, but to me it is a real nuisance from time to time.

What I have noticed is when highlighting a section, so that I may listen that part only, it works great. However… if I highlight a section less than a .1 sec the meters display normally but I hear absolutely nothing in my headphones. Even if I increase the amplitude it still plays back nothing even though the meter displays there is something there. Anything larger than .1 sec and it works like it is suppose to. Yet… when I do this in Audacity on my Windows laptop it works great.

Any thoughts as to what I am doing wrong, that is, if it is not a bug?

It’s not you. It’s a sound system issue. Some sound card drivers do not flush their buffers when they stop playing. Audio buffers are typically around 100 ms (0.1 seconds). If the selection is less than the buffer length, and the sound card driver does not flush its input buffer through the audio hardware, then Audacity sends the audio data to the sound card, which loads into the playack buffer, but never comes out again.

The exact behaviour depends on the sound card, the drivers and the sound system settings. On my (Xubuntu) machine I can play selections less than 0.1 second when playing back via Pulse, or Dmix, or Jack Audio System, but not via the straight ALSA “hw” option. With Dmix, selection less that 0.06 seconds don’t play (though they do with Pulse or Jack). Your mileage may vary.

Okay, here is where my ignorance comes in but the button to the left of the mic (see attached) only gives me ALSA while the button at the far right gives a some of the options you mentioned plus some but do not work (i.e. dmix, pulse, iec958…).

So since I am not an Audacity expert would you please expand a bit on this so that I may move with it in the right direction.

Also, I gather it is not something that can be done in code to empty the buffers or would that cause more of a problem? Could Audacity make it an option since it appears to be more common than not?

The first box in the device toolbar is the “audio host system”. On Linux this is usually ALSA, though there could be options for OSS and/or Jack Audio System if they are installed and running (usually only ALSA).

The recording and playback “devices” depend on what devices the host system says are available. Just because the host system says that an input or output is available does not mean that it is actually available. On my laptop, ALSA says that I have several surround sound outputs, because the sound chip has several surround sound outputs, but the surround sound outputs are not physically connected to anything - only “front left” and “front right” are actually wired up.

“Dmix” is an ALSA plug-in that is intended to allow multiple applications to share the sound card. This “should” work, though on a standard Ubuntu setup it is rarely used because Ubuntu uses PulseAudio by default. I don’t know how reliable this is because hardly anyone uses it on Ubuntu.

Pulse (PulseAudio) is a “sound server” that sits on top of ALSA. ALSA provides the low level drivers, and PulseAudio provides a range of services, including allowing multiple applications to access the sound card simultaneously, “loopback” recording, network audio streaming, on the fly resampling, and much more. For simple media players, PulseAudio (these days) usually “just works” and requires little attention (this was not always the case). However, PulseAudio is a very powerful and versatile sound server, and for more advanced audio applications (such as Audacity or Ardour) it can require a bit of configuration to get it working properly.

There is one problem with using PulseAudio with Audacity, which is that on some systems, rapid starting / stopping of playback can cause Audacity to freeze. This is due to the way that Audacity connects to the sound system, which in turn is due to historical reasons. Not everyone gets this problem, but it is extremely annoying if you do.

Why doesn’t Pulse work on your machine? What happens when you try it?

The problem is not in the Audacity code. Audacity does play short selections (as can be seen by the meter), but sound systems have and control their own buffers. As far as I’m aware, Audacity does “the right thing”, and then delegates playing the audio data to the sound system.

By the way, I don’t intend to sound critical of ALSA. The guys that develop ALSA drivers do a phenomenal job, providing working drivers for thousands of sound cards, often with very little technical documentation from the hardware manufacturers. Note that for Windows and Mac you often have to manually install drivers supplied by the manufacturer, whereas Linux has drivers built in for a massive range of hardware (largely because many manufacturers fail to provide drivers for Linux).

Steve, thank you for the explanation. Here is what I found:

Pulse: Did give me anything even at 1.1 secs
DMix: Plays exactly what is highlighted even at .08 secs but like you said at approx .06 secs I lose it all together. - Does not play thru my headphones which is probably an Ubuntu setting is my thinking.

Is that a typo? Did you mean “Did not give me anything”?
What exactly happens if you try to play a 30 second audio track with “Pulse” selected as the output device?

Thanks for the catch. it did NOT give me anything, but at approx .15 I start to hear something.