Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1085:179ea8a2f650 spectrogram-minor-refactor
Add VerticalBinLayer to SpectrogramLayer
author | Chris Cannam |
---|---|
date | Fri, 01 Jul 2016 17:54:31 +0100 |
parents | ee01a4062747 |
children | 163cb9b98104 |
comparison
equal
deleted
inserted
replaced
1084:db976e9f385a | 1085:179ea8a2f650 |
---|---|
1207 q0 = (q0 * getFFTSize(v)) / sr; | 1207 q0 = (q0 * getFFTSize(v)) / sr; |
1208 q1 = (q1 * getFFTSize(v)) / sr; | 1208 q1 = (q1 * getFFTSize(v)) / sr; |
1209 | 1209 |
1210 return true; | 1210 return true; |
1211 } | 1211 } |
1212 | 1212 |
1213 double | |
1214 SpectrogramLayer::getYForBin(LayerGeometryProvider *, double bin) const { | |
1215 //!!! not implemented | |
1216 throw std::logic_error("not implemented"); | |
1217 } | |
1218 | |
1219 double | |
1220 SpectrogramLayer::getBinForY(LayerGeometryProvider *v, double y) const | |
1221 { | |
1222 //!!! overlap with range methods above (but using double arg) | |
1223 //!!! tidy this | |
1224 | |
1225 int h = v->getPaintHeight(); | |
1226 if (y < 0 || y >= h) return false; | |
1227 | |
1228 sv_samplerate_t sr = m_model->getSampleRate(); | |
1229 double minf = getEffectiveMinFrequency(); | |
1230 double maxf = getEffectiveMaxFrequency(); | |
1231 | |
1232 bool logarithmic = (m_frequencyScale == LogFrequencyScale); | |
1233 | |
1234 double q = v->getFrequencyForY(y, minf, maxf, logarithmic); | |
1235 | |
1236 // Now map on to ("proportions of") actual bins, using raw FFT | |
1237 // size (unsmoothed) | |
1238 | |
1239 q = (q * getFFTSize(v)) / sr; | |
1240 | |
1241 return q; | |
1242 } | |
1243 | |
1213 bool | 1244 bool |
1214 SpectrogramLayer::getXBinRange(LayerGeometryProvider *v, int x, double &s0, double &s1) const | 1245 SpectrogramLayer::getXBinRange(LayerGeometryProvider *v, int x, double &s0, double &s1) const |
1215 { | 1246 { |
1216 sv_frame_t modelStart = m_model->getStartFrame(); | 1247 sv_frame_t modelStart = m_model->getStartFrame(); |
1217 sv_frame_t modelEnd = m_model->getEndFrame(); | 1248 sv_frame_t modelEnd = m_model->getEndFrame(); |