class_docstr: The Spectrum_Visualizer visualizes spectral FFT data using a simple PyGame GUI
class_docstr_tok: ["The","Spectrum_Visualizer","visualizes","spectral","FFT","data","using","a","simple","PyGame","GUI"]
code: def __init__(self, ear):
      self.plot_audio_history = True
      self.ear = ear
  
      self.HEIGHT = self.ear.height
      window_ratio = self.ear.window_ratio
  
      self.HEIGHT = round(self.HEIGHT)
      self.WIDTH = round(window_ratio * self.HEIGHT)
      self.y_ext = [round(0.05 * self.HEIGHT), self.HEIGHT]
      self.cm = cm.plasma
      # self.cm = cm.inferno
  
      self.toggle_history_mode()
  
      self.add_slow_bars = 1
      self.add_fast_bars = 1
      self.slow_bar_thickness = max(
          0.00002 * self.HEIGHT, 1.25 / self.ear.n_frequency_bins
      )
      self.tag_every_n_bins = max(
          1, round(5 * (self.ear.n_frequency_bins / 51))
      )  # Occasionally display Hz tags on the x-axis
  
      self.fast_bar_colors = [
          list((255 * np.array(self.cm(i))[:3]).astype(int))
          for i in np.linspace(
              0, 255, self.ear.n_frequency_bins
          ).astype(int)
      ]
      self.slow_bar_colors = [
          list(
              np.clip(
                  (255 * 3.5 * np.array(self.cm(i))[:3]).astype(int),
                  0,
                  255,
              )
          )
          for i in np.linspace(
              0, 255, self.ear.n_frequency_bins
          ).astype(int)
      ]
      self.fast_bar_colors = self.fast_bar_colors[::-1]
      self.slow_bar_colors = self.slow_bar_colors[::-1]
  
      self.slow_features = [0] * self.ear.n_frequency_bins
      self.frequency_bin_max_energies = np.zeros(
          self.ear.n_frequency_bins
      )
      self.frequency_bin_energies = self.ear.frequency_bin_energies
      self.bin_text_tags, self.bin_rectangles = [], []
  
      # Fixed init params:
      self.start_time = None
      self.vis_steps = 0
      self.fps_interval = 10
      self.fps = 0
      self._is_running = False
  
file_path: rt-audio-fft/src/visualizer.py
imports: import numpy
  import time, sys, math
  import pygame
  from collections import deque
  from src.utils import Button
  from matplotlib import cm
label_desc: Use image node_id 1 to create a new Spectrum_Visualizer object  with example: obj = Spectrum_Visualizer(ear)