comparison layer/SpectrogramLayer.cpp @ 1125:50324fca1328 spectrogram-minor-refactor

Scale range matching
author Chris Cannam
date Mon, 01 Aug 2016 15:06:16 +0100
parents 343887ac6766
children 9fb8dfd7ce4c
comparison
equal deleted inserted replaced
1124:b71a0491d287 1125:50324fca1328
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 cparams.threshold = m_threshold;
1460 cparams.gain = m_gain; 1460 cparams.gain = m_gain;
1461 1461
1462 if (m_colourScale != ColourScaleType::Phase && 1462 if (m_colourScale == ColourScaleType::Linear &&
1463 m_normalization == ColumnNormalization::None) { 1463 m_normalization == ColumnNormalization::None) {
1464 cparams.gain *= 2.f / float(getFFTSize()); 1464 //!!! This should not be necessary -- what is the actual range
1465 cparams.maxValue = 0.1;
1465 } 1466 }
1466 1467
1467 Colour3DPlotRenderer::Parameters params; 1468 Colour3DPlotRenderer::Parameters params;
1468 params.colourScale = ColourScale(cparams); 1469 params.colourScale = ColourScale(cparams);
1469 params.normalization = m_normalization; 1470 params.normalization = m_normalization;
1470 params.binDisplay = m_binDisplay; 1471 params.binDisplay = m_binDisplay;
1471 params.binScale = m_binScale; 1472 params.binScale = m_binScale;
1472 params.alwaysOpaque = false; 1473 params.alwaysOpaque = false; //!!! should be true though
1473 params.invertVertical = false; 1474 params.invertVertical = false;
1475 params.scaleFactor = 1.0;
1474 params.colourRotation = m_colourRotation; 1476 params.colourRotation = m_colourRotation;
1477
1478 if (m_colourScale != ColourScaleType::Phase &&
1479 m_normalization == ColumnNormalization::None) {
1480 params.scaleFactor *= 2.f / float(getFFTSize());
1481 }
1475 1482
1476 Preferences::SpectrogramSmoothing smoothing = 1483 Preferences::SpectrogramSmoothing smoothing =
1477 Preferences::getInstance()->getSpectrogramSmoothing(); 1484 Preferences::getInstance()->getSpectrogramSmoothing();
1478 params.interpolate = 1485 params.interpolate =
1479 (smoothing == Preferences::SpectrogramInterpolated || 1486 (smoothing == Preferences::SpectrogramInterpolated ||
2061 else top = QString("%1").arg(lrint(dBmax)); 2068 else top = QString("%1").arg(lrint(dBmax));
2062 2069
2063 if (dBmin < dBmax - 60.f) dBmin = dBmax - 60.f; 2070 if (dBmin < dBmax - 60.f) dBmin = dBmax - 60.f;
2064 bottom = QString("%1").arg(lrint(dBmin)); 2071 bottom = QString("%1").arg(lrint(dBmin));
2065 2072
2073 #ifdef DEBUG_SPECTROGRAM_REPAINT
2074 cerr << "adjusted dB range to min = " << dBmin << ", max = " << dBmax
2075 << endl;
2076 #endif
2077
2066 //!!! & phase etc 2078 //!!! & phase etc
2067 2079
2068 if (m_colourScale != ColourScaleType::Phase) { 2080 if (m_colourScale != ColourScaleType::Phase) {
2069 paint.drawText((cw + 6 - paint.fontMetrics().width("dBFS")) / 2, 2081 paint.drawText((cw + 6 - paint.fontMetrics().width("dBFS")) / 2,
2070 2 + textHeight + toff, "dBFS"); 2082 2 + textHeight + toff, "dBFS");
2086 for (int i = 0; i < ch; ++i) { 2098 for (int i = 0; i < ch; ++i) {
2087 2099
2088 double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1)); 2100 double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1));
2089 int idb = int(dBval); 2101 int idb = int(dBval);
2090 2102
2091 //!!! replace this 2103 //!!!
2092 // double value = AudioLevel::dB_to_multiplier(dBval); 2104 double value = AudioLevel::dB_to_multiplier(dBval);
2093 // int colour = getDisplayValue(v, value * m_gain); 2105 cerr << "dBval = " << dBval << ", value = " << value << endl;
2094 // paint.setPen(m_palette.getColour((unsigned char)colour)); 2106 paint.setPen(getRenderer(v)->getColour(value));
2095 2107
2096 int y = textHeight * topLines + 4 + ch - i; 2108 int y = textHeight * topLines + 4 + ch - i;
2097 2109
2098 paint.drawLine(5 + cw - cbw, y, cw + 2, y); 2110 paint.drawLine(5 + cw - cbw, y, cw + 2, y);
2099 2111