From 52443066e7993dbce4f6fadc789cecc0e4ea86dd Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 14 Feb 2022 21:10:57 -0800 Subject: [PATCH] Spectrum Visualizer: Fix frequency range, bands Reduce the virtual resolution to match the actual resolution, and set the analyzere frequency to Nyquist of the audio input, as it seems to behave as if the entire range of the input FFT bands are up to the specified frequency, rather than half of it. Otherwise, we lose half of the frequency range provided by the input data. Signed-off-by: Christopher Snowhill --- Visualization/SpectrumView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Visualization/SpectrumView.m b/Visualization/SpectrumView.m index ad4528945..58033a282 100644 --- a/Visualization/SpectrumView.m +++ b/Visualization/SpectrumView.m @@ -66,7 +66,7 @@ extern NSString *CogPlaybackDidStopNotficiation; ddb_analyzer_init(&_analyzer); _analyzer.db_lower_bound = LOWER_BOUND; _analyzer.peak_hold = 10; - _analyzer.view_width = 1000; + _analyzer.view_width = 64; _analyzer.fractional_bars = 1; _analyzer.octave_bars_step = 2; _analyzer.max_of_stereo_data = 1; @@ -247,7 +247,7 @@ extern NSString *CogPlaybackDidStopNotficiation; [self->visController copyVisPCM:&visAudio[0] visFFT:&visFFT[0]]; - ddb_analyzer_process(&_analyzer, [self->visController readSampleRate], 1, visFFT, 4096); + ddb_analyzer_process(&_analyzer, [self->visController readSampleRate] / 2.0, 1, visFFT, 4096); ddb_analyzer_tick(&_analyzer); ddb_analyzer_get_draw_data(&_analyzer, self.bounds.size.width, self.bounds.size.height, &_draw_data);