comparison layer/SpectrogramLayer.cpp @ 101:0f36cdf407a6 sv1-v0.9rc1

* Make vertical scale alignment modes work in note layer as well as time-value layer, and several significant fixes to it * Make it possible to draw notes properly on the note layer * Show units (and frequencies etc in note layer's case) in the time-value and note layer description boxes * Minor fix to item edit dialog layout * Some minor menu rearrangement * Comment out a lot of debug output * Add SV website and reference URLs to Help menu, and add code to (attempt to) open them in the user's preferred browser
author Chris Cannam
date Fri, 12 May 2006 14:40:43 +0000
parents a0e7edf9703a
children 8ce53683d0d7
comparison
equal deleted inserted replaced
100:0db5e7492ce8 101:0f36cdf407a6
32 #include <iostream> 32 #include <iostream>
33 33
34 #include <cassert> 34 #include <cassert>
35 #include <cmath> 35 #include <cmath>
36 36
37 #define DEBUG_SPECTROGRAM_REPAINT 1 37 //#define DEBUG_SPECTROGRAM_REPAINT 1
38 38
39 static double mod(double x, double y) 39 static double mod(double x, double y)
40 { 40 {
41 double a = floor(x / y); 41 double a = floor(x / y);
42 double b = x - (y * a); 42 double b = x - (y * a);
109 } 109 }
110 110
111 void 111 void
112 SpectrogramLayer::setModel(const DenseTimeValueModel *model) 112 SpectrogramLayer::setModel(const DenseTimeValueModel *model)
113 { 113 {
114 std::cerr << "SpectrogramLayer(" << this << "): setModel(" << model << ")" << std::endl; 114 // std::cerr << "SpectrogramLayer(" << this << "): setModel(" << model << ")" << std::endl;
115 115
116 m_mutex.lock(); 116 m_mutex.lock();
117 m_cacheInvalid = true; 117 m_cacheInvalid = true;
118 m_model = model; 118 m_model = model;
119 m_mutex.unlock(); 119 m_mutex.unlock();
635 } 635 }
636 636
637 void 637 void
638 SpectrogramLayer::setGain(float gain) 638 SpectrogramLayer::setGain(float gain)
639 { 639 {
640 std::cerr << "SpectrogramLayer::setGain(" << gain << ") (my gain is now " 640 // std::cerr << "SpectrogramLayer::setGain(" << gain << ") (my gain is now "
641 << m_gain << ")" << std::endl; 641 // << m_gain << ")" << std::endl;
642 642
643 if (m_gain == gain) return; 643 if (m_gain == gain) return;
644 644
645 m_mutex.lock(); 645 m_mutex.lock();
646 invalidatePixmapCaches(); 646 invalidatePixmapCaches();
1290 1290
1291 m_layer.m_cacheInvalid = false; 1291 m_layer.m_cacheInvalid = false;
1292 m_fillExtent = 0; 1292 m_fillExtent = 0;
1293 m_fillCompletion = 0; 1293 m_fillCompletion = 0;
1294 1294
1295 std::cerr << "SpectrogramLayer::CacheFillThread::run: model is ready" << std::endl; 1295 // std::cerr << "SpectrogramLayer::CacheFillThread::run: model is ready" << std::endl;
1296 1296
1297 size_t start = m_layer.m_model->getStartFrame(); 1297 size_t start = m_layer.m_model->getStartFrame();
1298 size_t end = m_layer.m_model->getEndFrame(); 1298 size_t end = m_layer.m_model->getEndFrame();
1299 1299
1300 std::cerr << "start = " << start << ", end = " << end << std::endl; 1300 // std::cerr << "start = " << start << ", end = " << end << std::endl;
1301 1301
1302 WindowType windowType = m_layer.m_windowType; 1302 WindowType windowType = m_layer.m_windowType;
1303 size_t windowSize = m_layer.m_windowSize; 1303 size_t windowSize = m_layer.m_windowSize;
1304 size_t windowIncrement = m_layer.getWindowIncrement(); 1304 size_t windowIncrement = m_layer.getWindowIncrement();
1305 1305
1306 std::cerr << "\nWINDOW INCREMENT: " << windowIncrement << " (for hop level " << m_layer.m_windowHopLevel << ")\n" << std::endl; 1306 // std::cerr << "\nWINDOW INCREMENT: " << windowIncrement << " (for hop level " << m_layer.m_windowHopLevel << ")\n" << std::endl;
1307 1307
1308 size_t visibleStart = m_layer.m_candidateFillStartFrame; 1308 size_t visibleStart = m_layer.m_candidateFillStartFrame;
1309 visibleStart = (visibleStart / windowIncrement) * windowIncrement; 1309 visibleStart = (visibleStart / windowIncrement) * windowIncrement;
1310 1310
1311 size_t width = (end - start) / windowIncrement + 1; 1311 size_t width = (end - start) / windowIncrement + 1;
2172 // std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl; 2172 // std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl;
2173 return completion; 2173 return completion;
2174 } 2174 }
2175 2175
2176 bool 2176 bool
2177 SpectrogramLayer::getValueExtents(float &min, float &max, QString &unit) const 2177 SpectrogramLayer::getValueExtents(float &min, float &max,
2178 bool &logarithmic, QString &unit) const
2178 { 2179 {
2179 min = getEffectiveMinFrequency(); 2180 min = getEffectiveMinFrequency();
2180 max = getEffectiveMaxFrequency(); 2181 max = getEffectiveMaxFrequency();
2182 logarithmic = (m_frequencyScale == LogFrequencyScale);
2181 unit = "Hz"; 2183 unit = "Hz";
2182 return true; 2184 return true;
2183 } 2185 }
2186
2187 bool
2188 SpectrogramLayer::getDisplayExtents(float &min, float &max) const
2189 {
2190 min = getEffectiveMinFrequency();
2191 max = getEffectiveMaxFrequency();
2192 return true;
2193 }
2184 2194
2185 bool 2195 bool
2186 SpectrogramLayer::snapToFeatureFrame(View *v, int &frame, 2196 SpectrogramLayer::snapToFeatureFrame(View *v, int &frame,
2187 size_t &resolution, 2197 size_t &resolution,
2188 SnapType snap) const 2198 SnapType snap) const