dreamlayers / synaesthesia

Synaesthesia music visualization program
GNU General Public License v2.0
31 stars 5 forks source link

Framerate limit in version 20221112 #3

Open ra-om opened 1 year ago

ra-om commented 1 year ago

Hi, it seems the visualization display is now limited to about 43fps, whereas it used to be over 100. It looks fine as-is though. Is this intentional? Vsync is completely turned off but has no effect

dreamlayers commented 1 year ago

The frame rate is synchronized with audio data. The FFT (which produces the spectrum from waveform data) processes 1024 samples (NumSamples) by default. The PortAudio code gets data at inFrequency (22050 Hz by default) in chunks of half of that. Then code in soundbuf.cc creates a new visualization frame after it receives MIN_NEW_SAMPLES, which is also NumSamples/2. So: 22050 / 512 is close to 43.

Changing both the Pa_OpenStream() chunk size and MIN_NEW_SAMPLES can easily speed up visualization. I suppose this should be made customizable somehow, at least with a command line argument.

Successive frames use overlapping sound data, and speeding up frame rate increases the overlap, but it can still reveal more detail in the music.

dreamlayers commented 1 year ago

https://github.com/dreamlayers/synaesthesia/commit/795788a26fc9dbb807662d2f125c92c4af72ee93 adds a FPS setting.

ra-om commented 1 year ago

Amazing, Thank you! also for the explanation.