From 7ba3c22ce1c353cacc6b1f8f0d5501b16519f0f8 Mon Sep 17 00:00:00 2001 From: "Simon A. Eugster" Date: Tue, 14 Dec 2010 12:59:29 +0000 Subject: [PATCH] Audio Scope: * Fixed crash when using too high max frequency * Fixed glitch changing the maximum frequency to 96 kHz when zooming in to 1 kHz too quickly (unsigned overflow) * Fixed frequency labeled twice as high as it actually was svn path=/trunk/kdenlive/; revision=5175 --- src/audioscopes/audiospectrum.cpp | 16 +++++++++------- src/audioscopes/audiospectrum.h | 2 +- src/audioscopes/spectrogram.cpp | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/audioscopes/audiospectrum.cpp b/src/audioscopes/audiospectrum.cpp index a92f6f5d..e0ce51de 100644 --- a/src/audioscopes/audiospectrum.cpp +++ b/src/audioscopes/audiospectrum.cpp @@ -177,8 +177,8 @@ QImage AudioSpectrum::renderAudioScope(uint, const QVector audioFrame, m_lastFFT = QVector(fftWindow/2); memcpy(m_lastFFT.data(), &(freqSpectrum[0]), fftWindow/2 * sizeof(float)); - uint right = ((float) m_freqMax)/(m_freq) * (m_lastFFT.size() - 1); - dbMap = interpolatePeakPreserving(m_lastFFT, m_innerScopeRect.width(), 0, right, -120); + uint right = ((float) m_freqMax)/(m_freq/2) * (m_lastFFT.size() - 1); + dbMap = interpolatePeakPreserving(m_lastFFT, m_innerScopeRect.width(), 0, right, -180); m_lastFFTLock.release(); @@ -269,8 +269,8 @@ QImage AudioSpectrum::renderHUD(uint) int x = 0; const int rightBorder = leftDist + m_innerScopeRect.width()-1; y = topDist + m_innerScopeRect.height() + textDistY; - for (uint hz = 0; x <= rightBorder; hz += hzDiff) { - davinci.setPen(AbstractScopeWidget::penLight); + for (int hz = 0; x <= rightBorder; hz += hzDiff) { + davinci.setPen(AbstractScopeWidget::penLighter); x = leftDist + m_innerScopeRect.width() * ((float)hz)/m_freqMax; if (x <= rightBorder) { @@ -310,7 +310,7 @@ QImage AudioSpectrum::renderHUD(uint) // We need to test whether the mouse is inside the widget // because the position could already have changed in the meantime (-> crash) if (m_lastFFT.size() > 0 && mouseX >= 0 && mouseX < m_innerScopeRect.width()) { - uint right = ((float) m_freqMax)/(m_freq) * (m_lastFFT.size() - 1); + uint right = ((float) m_freqMax)/(m_freq/2) * (m_lastFFT.size() - 1); QVector dbMap = AudioSpectrum::interpolatePeakPreserving(m_lastFFT, m_innerScopeRect.width(), 0, right, -120); db = dbMap[mouseX]; @@ -500,8 +500,10 @@ const QVector AudioSpectrum::interpolatePeakPreserving(const QVector in[xi+1] diff --git a/src/audioscopes/audiospectrum.h b/src/audioscopes/audiospectrum.h index 057dcdee..670160c8 100644 --- a/src/audioscopes/audiospectrum.h +++ b/src/audioscopes/audiospectrum.h @@ -75,7 +75,7 @@ private: /** Maximum frequency (limited by the sampling rate if determined automatically). Stored for the painters. */ - uint m_freqMax; + int m_freqMax; /** The user has chosen a custom frequency. */ bool m_customFreq; diff --git a/src/audioscopes/spectrogram.cpp b/src/audioscopes/spectrogram.cpp index 5a81a419..5bf9a86b 100644 --- a/src/audioscopes/spectrogram.cpp +++ b/src/audioscopes/spectrogram.cpp @@ -376,6 +376,7 @@ QImage Spectrogram::renderAudioScope(uint, const QVector audioFrame, co windowSize = (*it).size(); + // TODO use function for (uint i = 0; i < w; i++) { // i: Pixel coordinate -- 2.39.2