Skip to content

perf: improve visualizer smoothness with render cache and timing telemetry#1

Open
userlg wants to merge 13 commits intomainfrom
codex/review-app-and-suggest-improvements
Open

perf: improve visualizer smoothness with render cache and timing telemetry#1
userlg wants to merge 13 commits intomainfrom
codex/review-app-and-suggest-improvements

Conversation

@userlg
Copy link
Owner

@userlg userlg commented Feb 18, 2026

Motivation

  • Reduce per-frame work that causes jitter by avoiding repeated expensive image scaling and provide runtime observability to diagnose bottlenecks.
  • Surface audio callback and frame timing so performance issues can be measured in-app.
  • Make a few error handlers and time/sleep usages safer and clearer to improve robustness.

Description

  • Added callback_time_ms telemetry to the audio pipeline by extending audio_data_ready to emit (waveform, fft_data, activity_level, callback_time_ms) and storing last_callback_ms in AudioProcessor while measuring callback duration with time.perf_counter().
  • Replaced a few broad except: clauses with except Exception: and aliased time to time_module to avoid name collisions and make sleeps explicit (time_module.sleep).
  • Implemented scaled background caching in VisualizerWidget so QPixmap.scaled(...) runs only on image or size change, added _invalidate_background_cache() and updated resizeEvent/set_background_image to invalidate the cache.
  • Added frame and callback timing metrics to VisualizerWidget (last_frame_time_ms, last_audio_callback_ms) and passed them to the debug overlay, which now renders Frame: X ms and Audio CB: Y ms and increases overlay background height for readability.

Testing

  • Ran python -m compileall src to ensure the modified source compiles, and compilation completed successfully.
  • Per-file static sanity checks via local edits and compileall succeeded with no syntax errors.

Codex Task

- Expandido el ancho al 98% de la pantalla.
- Elevada drásticamente la potencia (x1.5) y sensibilidad (.65) de la gráfica.
- Cambiado el suavizado de ataque a casi instantáneo y caída 3x más lenta para sensación líquida.
- Removed hardcoded internal smoothing loops from SoundWave2, SpectrumBars, CircularSpectrum, and AudioLines.
- Removed excessive exponentiation math in SoundWave2 that forced clipping, hiding Gain changes.
- Visualizers now properly trust and display the ft_data output that contains UI-controlled Gain and CavaFilter Smoothing.
- Enhanced the base scalar coefficient (x3.5) during FFT generation so that values pushed to Visualizers carry satisfying height out-of-the-box.
- This effectively solves the issue where 200% Gain in the UI showed underwhelming graphics due to raw FFT values being exceptionally small prior to clipping.
- Shifted the gain representation so that the internal variable matches the user-facing UI value (100.0 instead of 60.0).
- Users will now safely see 'Gain set to: 157.0' instead of arbitrary internal mathematical multipliers like '94.2' in the logs.
- Replaced get_color() with get_gradient_color() when passing a float value (0.2).
- Prevented the 'TypeError: list indices must be integers or slices, not float' crash.
- Replaced basic jagged line-drawing with high-performance cubicTo Bezier curves for a liquid-smooth appearance.
- Implemented soft-clipping (
p.tanh) to tame explosive volume drops instead of hard math cutoffs.
- Added multi-layered glowing strokes (wide nebulous, middle intense, core laser) to generate a premium cinematic look.
- Changed an old, erroneous multiplier of 15000.0 to a sensible 2.0 on the raw �udio_buffer generation.
- The massive 15000x multiplier was forcing all audio input straight to its limits (-1.0 or 1.0), artificially turning all audio samples into hard, unnatural square waves which ruined 'Waveform' and 'Oscilloscope' visualizations.
- Relaxed Math: Downscaled excessive
p.power() bounds and hardcoded height multipliers inside SpectrumBars, CircularSpectrum, SoundWave2 and AudioLines.
- Issue Fixed: Prevent visualizers from immediately clipping to the absolute screen border on low-gain setups, thus maintaining elegant breathing room for acoustic responses.
…ectre theme, and circular visualizer smoothing optimizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant