BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit ebb3d63b09b8a654fdf54f74647b0032d4de5b5e
parent 8dc5b190bcd70ca6e54f423bd9693c6216153aeb
Author: Matt Demanett <matt@demanett.net>
Date:   Sat, 24 Nov 2018 21:27:16 -0500

ANALYZER: use 1, 4, 8k buffers for quality settings if sample rate is below 96k; 2, 8, 16k otherwise.

Diffstat:
Msrc/Analyzer.cpp | 31+++++++++++++++++++++++--------
Msrc/dsp/analyzer.cpp | 15+++++++++++++++
Msrc/dsp/analyzer.hpp | 21+++++++++++++++++++++
3 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/src/Analyzer.cpp b/src/Analyzer.cpp @@ -180,15 +180,30 @@ void Analyzer::resetChannels() { } SpectrumAnalyzer::Size Analyzer::size() { - switch (_quality) { - case QUALITY_ULTRA: { - return SpectrumAnalyzer::SIZE_16384; - } - case QUALITY_HIGH: { - return SpectrumAnalyzer::SIZE_4096; + if (engineGetSampleRate() < 96000.0f) { + switch (_quality) { + case QUALITY_ULTRA: { + return SpectrumAnalyzer::SIZE_8192; + } + case QUALITY_HIGH: { + return SpectrumAnalyzer::SIZE_4096; + } + default: { + return SpectrumAnalyzer::SIZE_1024; + } } - default: { - return SpectrumAnalyzer::SIZE_1024; + } + else { + switch (_quality) { + case QUALITY_ULTRA: { + return SpectrumAnalyzer::SIZE_16384; + } + case QUALITY_HIGH: { + return SpectrumAnalyzer::SIZE_8192; + } + default: { + return SpectrumAnalyzer::SIZE_2048; + } } } } diff --git a/src/dsp/analyzer.cpp b/src/dsp/analyzer.cpp @@ -37,6 +37,21 @@ void FFT4096::do_fft(float* out, float* in) { } +typedef ffft::FFTRealFixLen<13> FIXED_FFT8192; + +FFT8192::FFT8192() { + _fft = new FIXED_FFT8192(); +} + +FFT8192::~FFT8192() { + delete (FIXED_FFT8192*)_fft; +} + +void FFT8192::do_fft(float* out, float* in) { + ((FIXED_FFT8192*)_fft)->do_fft(out, in); +} + + typedef ffft::FFTRealFixLen<14> FIXED_FFT16384; FFT16384::FFT16384() { diff --git a/src/dsp/analyzer.hpp b/src/dsp/analyzer.hpp @@ -101,6 +101,14 @@ struct FFT4096 { void do_fft(float* out, float* in); }; +struct FFT8192 { + void* _fft = NULL; + FFT8192(); + ~FFT8192(); + + void do_fft(float* out, float* in); +}; + struct FFT16384 { void* _fft = NULL; FFT16384(); @@ -117,6 +125,7 @@ struct SpectrumAnalyzer : OverlappingBuffer<float> { SIZE_1024 = 1024, SIZE_2048 = 2048, SIZE_4096 = 4096, + SIZE_8192 = 8192, SIZE_16384 = 16384 }; @@ -138,6 +147,7 @@ struct SpectrumAnalyzer : OverlappingBuffer<float> { ffft::FFTReal<float>* _fft; FFT1024* _fft1024; FFT4096* _fft4096; + FFT8192* _fft8192; FFT16384* _fft16384; Window* _window; float* _windowOut; @@ -155,6 +165,7 @@ struct SpectrumAnalyzer : OverlappingBuffer<float> { , _fft(NULL) , _fft1024(NULL) , _fft4096(NULL) + , _fft8192(NULL) , _fft16384(NULL) , _window(NULL) , _windowOut(NULL) @@ -171,6 +182,10 @@ struct SpectrumAnalyzer : OverlappingBuffer<float> { _fft4096 = new FFT4096(); break; } + case SIZE_8192: { + _fft8192 = new FFT8192(); + break; + } case SIZE_16384: { _fft16384 = new FFT16384(); break; @@ -212,6 +227,9 @@ struct SpectrumAnalyzer : OverlappingBuffer<float> { if (_fft4096) { delete _fft4096; } + if (_fft8192) { + delete _fft8192; + } if (_fft16384) { delete _fft16384; } @@ -236,6 +254,9 @@ struct SpectrumAnalyzer : OverlappingBuffer<float> { else if (_fft4096) { _fft4096->do_fft(_fftOut, input); } + else if (_fft8192) { + _fft8192->do_fft(_fftOut, input); + } else if (_fft16384) { _fft16384->do_fft(_fftOut, input); }