From: Simon A. Eugster Date: Sat, 15 Jan 2011 19:24:34 +0000 (+0000) Subject: Audio spectrum: Show overdriving (overmodulation) by colorizing the spectrum X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=07b3bca5cf74ec331484b914239fba81737e573c;p=kdenlive Audio spectrum: Show overdriving (overmodulation) by colorizing the spectrum svn path=/trunk/kdenlive/; revision=5326 --- diff --git a/kdenlive-mindmap.svg b/kdenlive-mindmap.svg index c8c53477..3b754c75 100644 --- a/kdenlive-mindmap.svg +++ b/kdenlive-mindmap.svg @@ -1072,6 +1072,13 @@ inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d" /> + STABILITY + GENERAL Keyboard Shortcuts + UI Color safety (TV) tdisplay + y="2730.7996">Color safety (TV) display Low-Resolution preview + y="28.033258">Low-Resolution preview(Proxy Clips) Support workflow + + Display both monitors (clip/project) to compare results + Hide clip names + Set audio track to general sound level + Split audio and video by default when adding a clip to the timeline + Nested tracks(similar to adding a .kdenlive file as clip to the timeline) + EDL (Edit Decision List) diff --git a/src/audioscopes/audiospectrum.cpp b/src/audioscopes/audiospectrum.cpp index 27f4c0a2..2d0bb243 100644 --- a/src/audioscopes/audiospectrum.cpp +++ b/src/audioscopes/audiospectrum.cpp @@ -25,6 +25,12 @@ #include #endif +// (defined in the header file) +#ifdef DETECT_OVERMODULATION +#include +#include +#endif + // Draw lines instead of single pixels. // This is about 25 % faster, especially when enlarging the scope to e.g. 1680x1050 px. #define AUDIOSPEC_LINES @@ -44,6 +50,7 @@ AudioSpectrum::AudioSpectrum(QWidget *parent) : ,m_timeTotal(0) ,m_showTotal(0) #endif + ,colorizeFactor(0) { ui = new Ui::AudioSpectrum_UI; ui->setupUi(this); @@ -158,6 +165,34 @@ QImage AudioSpectrum::renderAudioScope(uint, const QVector audioFrame, QTime start = QTime::currentTime(); +#ifdef DETECT_OVERMODULATION + bool overmodulated = false; + int overmodulateCount = 0; + + for (int i = 0; i < audioFrame.size(); i++) { + if ( + audioFrame[i] == std::numeric_limits::max() + || audioFrame[i] == std::numeric_limits::min()) { + overmodulateCount++; + if (overmodulateCount > 3) { + overmodulated = true; + break; + } + } + } + if (overmodulated) { + colorizeFactor = 1; + } else { + if (colorizeFactor > 0) { + colorizeFactor -= .08; + if (colorizeFactor < 0) { + colorizeFactor = 0; + } + } + } +#endif + + // Determine the window size to use. It should be // * not bigger than the number of samples actually available // * divisible by 2 @@ -203,11 +238,26 @@ QImage AudioSpectrum::renderAudioScope(uint, const QVector audioFrame, const uint h = m_innerScopeRect.height(); const uint leftDist = m_innerScopeRect.left() - m_scopeRect.left(); const uint topDist = m_innerScopeRect.top() - m_scopeRect.top(); + QColor spectrumColor(AbstractScopeWidget::colDarkWhite); int yMax; +#ifdef DETECT_OVERMODULATION + if (colorizeFactor > 0) { + QColor col = AbstractScopeWidget::colHighlightDark; + QColor spec = spectrumColor; + float f = std::sin(M_PI_2 * colorizeFactor); + spectrumColor = QColor( + (int) (f * col.red() + (1-f) * spec.red()), + (int) (f * col.green() + (1-f) * spec.green()), + (int) (f * col.blue() + (1-f) * spec.blue()), + spec.alpha() + ); + } +#endif + #ifdef AUDIOSPEC_LINES QPainter davinci(&spectrum); - davinci.setPen(AbstractScopeWidget::penThin); + davinci.setPen(QPen(QBrush(spectrumColor.rgba()), 1, Qt::SolidLine)); #endif for (uint i = 0; i < w; i++) { @@ -221,7 +271,7 @@ QImage AudioSpectrum::renderAudioScope(uint, const QVector audioFrame, davinci.drawLine(leftDist + i, topDist + h-1, leftDist + i, topDist + h-1 - yMax); #else for (int y = 0; y < yMax && y < (int)h; y++) { - spectrum.setPixel(leftDist + i, topDist + h-y-1, qRgba(225, 182, 255, 255)); + spectrum.setPixel(leftDist + i, topDist + h-y-1, spectrumColor.rgba()); } #endif } @@ -296,13 +346,6 @@ QImage AudioSpectrum::renderHUD(uint) QPainter davinci(&hud); davinci.setPen(AbstractScopeWidget::penLight); - int _dw = m_innerScopeRect.width(); - int _dh = m_innerScopeRect.height(); - int _dld = m_innerScopeRect.width() + leftDist + textDistX; - int _dtd = topDist+ m_innerScopeRect.height() + 6; - int _fw = AbstractScopeWidget::geometry().width(); - int _fh = AbstractScopeWidget::geometry().height(); - int y; for (int db = -dbDiff; db > m_dBmin; db -= dbDiff) { y = topDist + m_innerScopeRect.height() * ((float)db)/(m_dBmin - m_dBmax); diff --git a/src/audioscopes/audiospectrum.h b/src/audioscopes/audiospectrum.h index 78d6cbc5..a0d8d294 100644 --- a/src/audioscopes/audiospectrum.h +++ b/src/audioscopes/audiospectrum.h @@ -20,6 +20,9 @@ // Enables debugging //#define DEBUG_AUDIOSPEC +// Show overmodulation +#define DETECT_OVERMODULATION + #include #include #include @@ -83,6 +86,8 @@ private: /** The user has chosen a custom frequency. */ bool m_customFreq; + float colorizeFactor; + #ifdef DEBUG_AUDIOSPEC long m_timeTotal; long m_showTotal;