diff --git a/spectrogram.cpp b/spectrogram.cpp index 9af9732..2c4ec20 100644 --- a/spectrogram.cpp +++ b/spectrogram.cpp @@ -10,6 +10,7 @@ Spectrogram::Spectrogram() { inputSource = nullptr; + fftSize = 1024; powerMax = 0.0f; powerMin = -50.0f; } @@ -26,7 +27,7 @@ void Spectrogram::pickFile() ); if (fileName != nullptr) { try { - InputSource *newFile = new InputSource(fileName.toUtf8().constData(), (inputSource != nullptr) ? inputSource->GetWidth() : 1024); + InputSource *newFile = new InputSource(fileName.toUtf8().constData(), fftSize); delete inputSource; inputSource = newFile; resize(inputSource->GetWidth(), inputSource->GetHeight()); @@ -135,9 +136,12 @@ void Spectrogram::paintEvent(QPaintEvent *event) void Spectrogram::setFFTSize(int size) { - inputSource->setFFTSize(size); - update(); - resize(inputSource->GetWidth(), inputSource->GetHeight()); + fftSize = size; + if (inputSource != nullptr) { + inputSource->setFFTSize(size); + update(); + resize(inputSource->GetWidth(), inputSource->GetHeight()); + } } void Spectrogram::setPowerMax(int power) diff --git a/spectrogram.h b/spectrogram.h index 849d14c..70e4ea1 100644 --- a/spectrogram.h +++ b/spectrogram.h @@ -23,6 +23,7 @@ protected: private: InputSource *inputSource; + int fftSize; float powerMax; float powerMin; }; \ No newline at end of file