projectM-visualizer / projectm

projectM - Cross-platform Music Visualization Library. Open-source and Milkdrop-compatible.
https://discord.gg/mMrxAqaa3W
GNU Lesser General Public License v2.1
3.22k stars 364 forks source link

Delayed beat detection #711

Closed Souravgoswami closed 7 months ago

Souravgoswami commented 1 year ago

Describe the bug Whenever I run a music, the ProjectM visualization doesn't start at the exact same time. When I start and pause a music, I see projectM updates after 5 seconds or so, and as the music is played and paused for 1 second, projectM does the same as well - but everything is delayed by like 5 seconds.

The issue is annoying because say you're playing music and it has beats, ProjectM will show each beat delayed by 5 seconds. Now when the beat stops, ProjectM will still show the beats in the visualization. So it's like a the detection has a horizontal offset of 5 seconds and not close to real time update. This becomes annoying because the visualization doesn't match closely to what is playing, because 5 seconds delay is a huge delay.

Screenshots image Music running - shows black screen

Music paused but visualizer still runs: image

Desktop (please complete the following information):

Additional Details Adjusted various settings, no resolution. Can't find any setting for delayed FFT.

kblaschke commented 1 year ago

Hi,

projectM itself has no large buffer that would explain a 5-second delay (the internal buffer can hold at most ~50ms of audio data).

The screenshots show the Qt app, which has a really old and probably wrong PulseAudio implementation.

Could you try this development build of the SDL2 frontend here? This should work better as it uses libSDL2 for audio capturing: https://github.com/kblaschke/frontend-sdl2/releases/tag/2.0-linux-pre1

Drawback is that it currently has no playlist management or configuration UI, but we're working on that.

If SDL doesn't use Pipewire by default, try setting SDL_AUDIODRIVER=pipewire in the environment. Support depends on how libSDL2 was compiled though.

xsoalokinx commented 7 months ago

tested frontend-sdl2 and it worked fine, also experienced a delay like OP when using pipewire and its pulse backend. Fixed it by passing PULSE_LATENCY_MSEC=50.

Souravgoswami commented 7 months ago

Wow, I missed that comment :(

Yeah fronend-sdl2 works really great! Thank you so much!