diff --git a/redisplay.py b/redisplay.py index c7efa99..1c753ca 100644 --- a/redisplay.py +++ b/redisplay.py @@ -12,7 +12,7 @@ Key Features: - Configurable audio parameters (sample rate, window size). - Device selection from available system audio inputs. - VU meters for different frequency bands. -- Optional connection to a Redis server (for potential future use). +- Pushes computed spectrum data (10 frequency bins) and rms to a Redis server. - Dark theme for the GUI using sv_ttk. Author: Sam @@ -105,6 +105,7 @@ class AudioPlotterApp(tk.Tk): self._force_focus() def _force_focus(self): + """Force the window to the front, specifically for macOS.""" if sys.platform != "darwin": return self.lift() @@ -394,6 +395,17 @@ class AudioPlotterApp(tk.Tk): return (self.spectrum_line, self.waveform_line) def update_vu_meters(self, magnitude): + """ + Calculate frequency band levels and update the VU meters. + + The method divides the frequency spectrum into logarithmic bins, calculates the + average magnitude for each bin, converts it to a scaled level (0-10), and + updates the corresponding VU meter. It also pushes the resulting list of + levels to a Redis key named 'spectrum_10' if a connection is active. + + Args: + magnitude (np.ndarray): The magnitude spectrum of the audio data. + """ if not self.vu_meters or self.xf is None: return