comparison layer/SpectrogramLayer.cpp @ 1129:371320c9f8d9 spectrogram-minor-refactor

A threshold fix
author Chris Cannam
date Tue, 02 Aug 2016 09:09:58 +0100
parents 4e022a3e567b
children ee98d587cd1a
comparison
equal deleted inserted replaced
1128:4e022a3e567b 1129:371320c9f8d9
1454 sources.peaks = getPeakCache(); 1454 sources.peaks = getPeakCache();
1455 1455
1456 ColourScale::Parameters cparams; 1456 ColourScale::Parameters cparams;
1457 cparams.colourMap = m_colourMap; 1457 cparams.colourMap = m_colourMap;
1458 cparams.scale = m_colourScale; 1458 cparams.scale = m_colourScale;
1459 cparams.threshold = m_threshold; 1459
1460 cparams.gain = m_gain; 1460 if (m_colourScale != ColourScaleType::Phase) {
1461 cparams.gain = m_gain;
1462 cparams.threshold = m_threshold;
1463 }
1461 1464
1462 if (m_colourScale == ColourScaleType::Linear && 1465 if (m_colourScale == ColourScaleType::Linear &&
1463 m_normalization == ColumnNormalization::None) { 1466 m_normalization == ColumnNormalization::None) {
1464 //!!! This should not be necessary -- what is the actual range 1467 //!!! This should not be necessary -- what is the actual range
1465 cparams.maxValue = 0.1; 1468 cparams.maxValue = 0.1;
1469 if (cparams.maxValue <= m_threshold) {
1470 cparams.maxValue = m_threshold + 0.1;
1471 }
1466 } 1472 }
1467 1473
1468 Colour3DPlotRenderer::Parameters params; 1474 Colour3DPlotRenderer::Parameters params;
1469 params.colourScale = ColourScale(cparams); 1475 params.colourScale = ColourScale(cparams);
1470 params.normalization = m_normalization; 1476 params.normalization = m_normalization;
1471 params.binDisplay = m_binDisplay; 1477 params.binDisplay = m_binDisplay;
1472 params.binScale = m_binScale; 1478 params.binScale = m_binScale;
1473 params.alwaysOpaque = false; //!!! should be true though 1479 params.alwaysOpaque = false; //!!! should be true though
1474 params.invertVertical = false; 1480 params.invertVertical = false;
1475 params.scaleFactor = 1.0; 1481 params.scaleFactor = 1.0;
1476 params.colourRotation = m_colourRotation; 1482 params.colourRotation = m_colourRotation;
1477 1483
1478 if (m_colourScale != ColourScaleType::Phase && 1484 if (m_colourScale != ColourScaleType::Phase) {
1479 m_normalization == ColumnNormalization::None) {
1480 params.scaleFactor *= 2.f / float(getFFTSize()); 1485 params.scaleFactor *= 2.f / float(getFFTSize());
1481 } 1486 }
1482 1487
1483 Preferences::SpectrogramSmoothing smoothing = 1488 Preferences::SpectrogramSmoothing smoothing =
1484 Preferences::getInstance()->getSpectrogramSmoothing(); 1489 Preferences::getInstance()->getSpectrogramSmoothing();
2101 for (int i = 0; i < ch; ++i) { 2106 for (int i = 0; i < ch; ++i) {
2102 2107
2103 double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1)); 2108 double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1));
2104 int idb = int(dBval); 2109 int idb = int(dBval);
2105 2110
2106 //!!!
2107 double value = AudioLevel::dB_to_multiplier(dBval); 2111 double value = AudioLevel::dB_to_multiplier(dBval);
2108 cerr << "dBval = " << dBval << ", value = " << value << endl;
2109 paint.setPen(getRenderer(v)->getColour(value)); 2112 paint.setPen(getRenderer(v)->getColour(value));
2110 2113
2111 int y = textHeight * topLines + 4 + ch - i; 2114 int y = textHeight * topLines + 4 + ch - i;
2112 2115
2113 paint.drawLine(5 + cw - cbw, y, cw + 2, y); 2116 paint.drawLine(5 + cw - cbw, y, cw + 2, y);