comparison layer/SpectrogramLayer.cpp @ 118:853a7fc542d0

* fledgling preferences stuff
author Chris Cannam
date Mon, 10 Jul 2006 13:54:49 +0000
parents 782142eaaa84
children 508276c923ba
comparison
equal deleted inserted replaced
117:782142eaaa84 118:853a7fc542d0
18 #include "base/View.h" 18 #include "base/View.h"
19 #include "base/Profiler.h" 19 #include "base/Profiler.h"
20 #include "base/AudioLevel.h" 20 #include "base/AudioLevel.h"
21 #include "base/Window.h" 21 #include "base/Window.h"
22 #include "base/Pitch.h" 22 #include "base/Pitch.h"
23 #include "base/Preferences.h"
23 #include "fileio/FFTDataServer.h" 24 #include "fileio/FFTDataServer.h"
24 25
25 #include <QPainter> 26 #include <QPainter>
26 #include <QImage> 27 #include <QImage>
27 #include <QPixmap> 28 #include <QPixmap>
1388 SpectrogramLayer::getZeroPadLevel(const View *v) const 1389 SpectrogramLayer::getZeroPadLevel(const View *v) const
1389 { 1390 {
1390 //!!! tidy all this stuff 1391 //!!! tidy all this stuff
1391 1392
1392 if (m_binDisplay != AllBins) return 0; 1393 if (m_binDisplay != AllBins) return 0;
1394 if (!Preferences::getInstance()->getSmoothSpectrogram()) return 0;
1393 if (m_frequencyScale == LogFrequencyScale) return 3; 1395 if (m_frequencyScale == LogFrequencyScale) return 3;
1394 1396
1395 int sr = m_model->getSampleRate(); 1397 int sr = m_model->getSampleRate();
1396 1398
1397 size_t bins = m_fftSize / 2; 1399 size_t bins = m_fftSize / 2;
1405 minbin = int((double(m_minFrequency) * m_fftSize) / sr + 0.1); 1407 minbin = int((double(m_minFrequency) * m_fftSize) / sr + 0.1);
1406 if (minbin < 1) minbin = 1; 1408 if (minbin < 1) minbin = 1;
1407 if (minbin >= bins) minbin = bins - 1; 1409 if (minbin >= bins) minbin = bins - 1;
1408 } 1410 }
1409 1411
1410 if (v->height() / 1.5 > (bins - minbin) / (m_zeroPadLevel + 1)) { 1412 float perPixel =
1411 return 3; 1413 float(v->height()) /
1414 float((bins - minbin) / (m_zeroPadLevel + 1));
1415
1416 if (perPixel > 2.8) {
1417 return 3; // 4x oversampling
1418 } else if (perPixel > 1.5) {
1419 return 1; // 2x
1412 } else { 1420 } else {
1413 return 0; 1421 return 0; // 1x
1414 } 1422 }
1415 } 1423 }
1416 1424
1417 size_t 1425 size_t
1418 SpectrogramLayer::getFFTSize(const View *v) const 1426 SpectrogramLayer::getFFTSize(const View *v) const