# HG changeset patch # User Chris Cannam # Date 1138805389 0 # Node ID 6b794a2af3d93494700495688a4292daa3a5d543 # Parent ca57f70b0e487ff3848b12ab50d7d8d51612e715 * Add Chromagram plugin, and make a number of fixes to the dense 3d model and colour 3d plot class to accommodate it * Add pitch-conversion methods in base/Pitch * Commit previously overlooked Command.cpp diff -r ca57f70b0e48 -r 6b794a2af3d9 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Tue Jan 31 17:19:45 2006 +0000 +++ b/layer/Colour3DPlotLayer.cpp Wed Feb 01 14:49:49 2006 +0000 @@ -158,6 +158,8 @@ //!!! divide-by-zero! int pixel = int(((value - min) * 256) / (max - min)); + if (pixel == 256) pixel = 255; + m_cache->setPixel(f / modelWindow, y, pixel); } } @@ -225,14 +227,18 @@ if (sx >= 0 && sx < m_cache->width() && sy >= 0 && sy < m_cache->height()) { - int dv = m_cache->pixelIndex(sx, sy); - if (dv != 0 && paint.fontMetrics().height() < (h / sh)) { - QString text = QString("%1").arg(dv); - if (paint.fontMetrics().width(text) < w - 3) { - paint.setPen(Qt::white); - paint.drawText(rx0 + 2, - ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), - QString("%1").arg(dv)); + if (w > 10) { + int dv = m_cache->pixelIndex(sx, sy); +// if (dv != 0 && paint.fontMetrics().height() < (h / sh)) { + if (paint.fontMetrics().height() < (h / sh)) { + float value = m_model->getBinValue(fx, sy); + QString text = QString("%1").arg(value); //dv); + if (paint.fontMetrics().width(text) < w - 3) { + paint.setPen(Qt::white); + paint.drawText(rx0 + 2, + ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), + QString("%1").arg(value)); + } } } } @@ -266,6 +272,23 @@ */ } +int +Colour3DPlotLayer::getNearestFeatureFrame(int frame, + size_t &resolution, + bool snapRight) const +{ + if (!m_model) { + return Layer::getNearestFeatureFrame(frame, resolution, snapRight); + } + + resolution = m_model->getWindowSize(); + + int returnFrame = (frame / resolution) * resolution; + if (snapRight) returnFrame += resolution; + + return returnFrame; +} + #ifdef INCLUDE_MOCFILES #include "Colour3DPlotLayer.moc.cpp" #endif diff -r ca57f70b0e48 -r 6b794a2af3d9 layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Tue Jan 31 17:19:45 2006 +0000 +++ b/layer/Colour3DPlotLayer.h Wed Feb 01 14:49:49 2006 +0000 @@ -43,8 +43,14 @@ virtual const Model *getModel() const { return m_model; } virtual void paint(QPainter &paint, QRect rect) const; + virtual int getNearestFeatureFrame(int frame, + size_t &resolution, + bool snapRight = true) const; + void setModel(const DenseThreeDimensionalModel *model); + virtual int getCompletion() const { return m_model->getCompletion(); } + /* virtual PropertyList getProperties() const; diff -r ca57f70b0e48 -r 6b794a2af3d9 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Jan 31 17:19:45 2006 +0000 +++ b/layer/SpectrogramLayer.cpp Wed Feb 01 14:49:49 2006 +0000 @@ -13,6 +13,7 @@ #include "base/Profiler.h" #include "base/AudioLevel.h" #include "base/Window.h" +#include "base/Pitch.h" #include #include