JDSP4Linux icon indicating copy to clipboard operation
JDSP4Linux copied to clipboard

I can hear the end of the previous buffer after a pause

Open ryuukk opened this issue 3 years ago • 3 comments

Hello

Here is how to reproduce the issue i am having:

  • Use this config: https://gist.github.com/ryuukk/c3cf6052c0468be79ba11338d9c08b33
  • Play a youtube video
  • Pause it
  • Open a new youtube video
  • Play it
  • You'll hear few milliseconds of what i was listening to previously

I don't know what the issue could be, maybe a buffer overflow? timing issue?

OS: Arch Linux Kernel: 5.18.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Package: aur/jamesdsp 2.3-3 (+10 1.30) Audio: extra/pipewire 1:0.3.51-1

ryuukk avatar Jun 13 '22 15:06 ryuukk

On my setup, I only hear a sharp pop when a new sound plays after several seconds of total silence. In extreme cases, I would sometimes hear either or both channels being cut out for several milliseconds in the exact same scenario. This occurs both in the PulseAudio and Pipewire flavors, the latter I'm using now as I gave up using PA due to unsolvable overruns with DSP apps.

I think this is more of a timing issue because the DSP pipeline has its own buffer (I may be wrong as I have not studied the app's source code), so there would always be a short delay as the audio is being passed through. Every time the pipeline becomes idle when no sound is playing, it would get paused after a short amount of time. Combine that with the tiny delay caused by the buffer and you get a tiny bit of the previously played sound immediately after the pipeline is unpaused.

On a related note, I've also noticed that some effects such as long reverbs do get paused with the entire pipeline when no audio is playing. As a result, you'd hear the previous sound's reverb once the pipeline gets unpaused. I find that annoying, but that's a topic for another issue.

acarasimon96 avatar Jul 04 '22 23:07 acarasimon96

I will take a look on that. Reverb does has multiple feedback and delay lines

Cleaning up the filter state of reverb will do the job, but in general, we need to know when audio get paused.

@ThePBone Are there ways to obtain stream pause/resume, I mean, of course, I could detect signal volume and a counter to check for silence, but I think stream pausing isn't a silent, but a event?

james34602 avatar Aug 03 '22 01:08 james34602

Yes, I can detect when an application attaches and detaches from the audio server, so I know when the stream is paused.

I did some tests, and this issue only happens when no applications are attached. So Pipewire pauses the entire audio pipeline instead of filling the audio buffers with silence.

timschneeb avatar Aug 03 '22 10:08 timschneeb