better redisplay.py doc
This commit is contained in:
parent
93a4279dd7
commit
12b1a3312e
14
redisplay.py
14
redisplay.py
@ -12,7 +12,7 @@ Key Features:
|
|||||||
- Configurable audio parameters (sample rate, window size).
|
- Configurable audio parameters (sample rate, window size).
|
||||||
- Device selection from available system audio inputs.
|
- Device selection from available system audio inputs.
|
||||||
- VU meters for different frequency bands.
|
- 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.
|
- Dark theme for the GUI using sv_ttk.
|
||||||
|
|
||||||
Author: Sam
|
Author: Sam
|
||||||
@ -105,6 +105,7 @@ class AudioPlotterApp(tk.Tk):
|
|||||||
self._force_focus()
|
self._force_focus()
|
||||||
|
|
||||||
def _force_focus(self):
|
def _force_focus(self):
|
||||||
|
"""Force the window to the front, specifically for macOS."""
|
||||||
if sys.platform != "darwin":
|
if sys.platform != "darwin":
|
||||||
return
|
return
|
||||||
self.lift()
|
self.lift()
|
||||||
@ -394,6 +395,17 @@ class AudioPlotterApp(tk.Tk):
|
|||||||
return (self.spectrum_line, self.waveform_line)
|
return (self.spectrum_line, self.waveform_line)
|
||||||
|
|
||||||
def update_vu_meters(self, magnitude):
|
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:
|
if not self.vu_meters or self.xf is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user