Move the graph smoothing to the bars

This commit is contained in:
Correl Roush 2020-09-26 21:03:48 -04:00
parent 3ef9d208d8
commit 11b9220ea9

View file

@ -52,8 +52,7 @@ class Plot:
fft = fft[: len(fft) // 2] fft = fft[: len(fft) // 2]
dbfs = 20 * np.log10(fft * 2 / (len(fft) * 2 ** 15)) dbfs = 20 * np.log10(fft * 2 / (len(fft) * 2 ** 15))
dbfs = np.maximum(-100, dbfs) + 100 dbfs = np.maximum(-100, dbfs) + 100
self.spectrums.append(dbfs) return dbfs
return np.mean(np.column_stack(self.spectrums), axis=1)
def draw_lines(self) -> None: def draw_lines(self) -> None:
data = self.spectrum() data = self.spectrum()
@ -84,6 +83,8 @@ class Plot:
), ),
axis=1, axis=1,
) )
self.spectrums.append(fft)
fft = np.mean(np.column_stack(self.spectrums), axis=1)
light_width = self.width // (2 * self.bars - 1) light_width = self.width // (2 * self.bars - 1)
light_height = self.height // 2 // light_width light_height = self.height // 2 // light_width