Wednesday, May 15, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1564  / 3 Years ago, thu, september 23, 2021, 9:02:22

There is a long standing sound issue in Debian and derivatives like Ubuntu, where the FIRST playback of a track to a digital eg: HDMI output misses the first second or two, or plays a short sound at low volume "muffled", or fails to play a very short sound at all. Subsequent plays will usually be OK, at least within the next 5 seconds to 20 minutes - then the issue recurrs. It happens with all sound apps and file types.
Because it has the worst effect on the shortest sounds, it is particularly annoying for desktop alerts or 'event' sounds, and the terminal bell (another can of worms in Xfce).
The issue can be forced by logging out and in again, or if your machine is attached to a KVM, possibly just by switching the KVM to another machine and back again. I have had this since Debian 6 Squeeze through to Xubuntu 20.04 LTS, on several machines, both Intel and AMD chipsets. It's not PulseAudio - the Debian machine only used ALSA, no PulseAudio. It was present in Debian with Gnome 2, Ubuntu with Gnome 3, and Xubuntu (Xfce 4).
Analogue output is not affected.


Backgound
Many people seem to have fixed a similar issue with various ways of disabling the 'power save' feature of the Intel HDA driver, but they didn't work for me. That issue seems to be associated with clicks or pops at the beginning/end of playback - which I don't get. However, my issues also seem to result from a delay in starting the sound system.
Others fixed this by playing continuous silence to keep the system turned on, eg: Sound output starts delayed and https://unix.stackexchange.com/questions/362223/short-audio-playback-is-muted-requires-warming-up-or-secondary-audio-in-backgro - but again this didn't work for me.


More From » sound

 Answers
0

What Does Work for Me on Debian, Ubuntu and Xubuntu



  1. I needed to create a short "inaudible" sound file which has some content (a totally silent track does not work) but is too quiet to hear (more on this below). It can be a .wav (played by aplay) or .ogg (played by paplay).
    Test by logging out + in, then do:-


$ aplay path/to/inaudible.wav; paplay /usr/share/sounds/freedesktop/stereo/bell.oga


If the 'bell' alert sound plays normally when it follows 'inaudible' then it has done the trick.



  1. This can then be put into a daemon script eg: (by root) /usr/local/bin/SoundKeepAlive.sh which reiterates every 4 seconds:-


     #!/bin/bash

    while true
    do
    aplay -q path/to/inaudible.wav
    sleep 4
    done



Ensure this is executable.



  1. The daemon can then be started automatically at graphical login by creating a Startup/autostart job:-
    Xfce: Apps > Settings > Session & Startup > Appn AutoStart; or
    Gnome 3: Apps > Startup Applications,
    with the command: bash -c "/usr/local/bin/SoundKeepAlive.sh"



  2. Log out and in. Then do $ ps -fwe | grep SoundKeepAlive | grep -v grep
    This should show the process of the daemon now running.
    $ paplay /usr/share/sounds/freedesktop/stereo/bell.oga should now play normally.



  3. If this needs to run for multiple users, move (as root) the autostart 'desktop' file ~/.config/autostart/SoundKeepAlive.desktop to /etc/xdg/autostart/ and change its permissions to match the others there.



  4. A final note about further testing: after logging in and out (or switching via a KVM) wait 5 seconds before testing, to ensure the daemon has fired at least once.




Creating the 'inaudible' Sound File


I used the https://audio-joiner.com/ site (others are available), and started with /usr/share/sounds/gnome/default/alerts/sonar.ogg


This site does not work with the 'ogg' format, so I first created a wav:-


$ oggdec -o sonar.wav /usr/share/sounds/gnome/default/alerts/sonar.ogg

I uploaded the sonar.wav, then moved the left end slider to start about half way through (to get the lowest volume sound content). Then I used the Audio Tools > Change Volume to reduce the volume by 90%, rendering it inaudible. I downloaded this as 'inaudible.wav'.
I also produced an ogg version:-


$ ffmpeg -i /path/to/inaudible.wav  -acodec libvorbis /path/to/inaudible.ogg

This file worked first time for me, but if not it might be necessary to experiment with the duration and volume.
I put it (as root) into /usr/local/share/sounds/ for all users.


[#2045] Saturday, September 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rmodmi

Total Points: 390
Total Questions: 122
Total Answers: 111

Location: Venezuela
Member since Mon, Oct 18, 2021
3 Years ago
;