Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 153:aaa3a53dbb10
* Some work on SpectrumLayer properties etc
author | Chris Cannam |
---|---|
date | Wed, 27 Sep 2006 14:56:31 +0000 |
parents | 40a47de69559 |
children | e68cc314deb7 |
comparison
equal
deleted
inserted
replaced
152:6a3f3c13173f | 153:aaa3a53dbb10 |
---|---|
129 SpectrogramLayer::getProperties() const | 129 SpectrogramLayer::getProperties() const |
130 { | 130 { |
131 PropertyList list; | 131 PropertyList list; |
132 list.push_back("Colour"); | 132 list.push_back("Colour"); |
133 list.push_back("Colour Scale"); | 133 list.push_back("Colour Scale"); |
134 // list.push_back("Window Type"); | |
135 list.push_back("Window Size"); | 134 list.push_back("Window Size"); |
136 list.push_back("Window Increment"); | 135 list.push_back("Window Increment"); |
137 list.push_back("Normalize Columns"); | 136 list.push_back("Normalize Columns"); |
138 list.push_back("Normalize Visible Area"); | 137 list.push_back("Normalize Visible Area"); |
139 list.push_back("Bin Display"); | 138 list.push_back("Bin Display"); |
140 list.push_back("Threshold"); | 139 list.push_back("Threshold"); |
141 list.push_back("Gain"); | 140 list.push_back("Gain"); |
142 list.push_back("Colour Rotation"); | 141 list.push_back("Colour Rotation"); |
143 list.push_back("Min Frequency"); | 142 // list.push_back("Min Frequency"); |
144 list.push_back("Max Frequency"); | 143 // list.push_back("Max Frequency"); |
145 list.push_back("Frequency Scale"); | 144 list.push_back("Frequency Scale"); |
146 // list.push_back("Zero Padding"); | 145 //// list.push_back("Zero Padding"); |
147 return list; | 146 return list; |
148 } | 147 } |
149 | 148 |
150 QString | 149 QString |
151 SpectrogramLayer::getPropertyLabel(const PropertyName &name) const | 150 SpectrogramLayer::getPropertyLabel(const PropertyName &name) const |
152 { | 151 { |
153 if (name == "Colour") return tr("Colour"); | 152 if (name == "Colour") return tr("Colour"); |
154 if (name == "Colour Scale") return tr("Colour Scale"); | 153 if (name == "Colour Scale") return tr("Colour Scale"); |
155 if (name == "Window Type") return tr("Window Type"); | |
156 if (name == "Window Size") return tr("Window Size"); | 154 if (name == "Window Size") return tr("Window Size"); |
157 if (name == "Window Increment") return tr("Window Overlap"); | 155 if (name == "Window Increment") return tr("Window Overlap"); |
158 if (name == "Normalize Columns") return tr("Normalize Columns"); | 156 if (name == "Normalize Columns") return tr("Normalize Columns"); |
159 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); | 157 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); |
160 if (name == "Bin Display") return tr("Bin Display"); | 158 if (name == "Bin Display") return tr("Bin Display"); |
181 } | 179 } |
182 | 180 |
183 QString | 181 QString |
184 SpectrogramLayer::getPropertyGroupName(const PropertyName &name) const | 182 SpectrogramLayer::getPropertyGroupName(const PropertyName &name) const |
185 { | 183 { |
184 if (name == "Bin Display" || | |
185 name == "Frequency Scale") return tr("Bins"); | |
186 if (name == "Window Size" || | 186 if (name == "Window Size" || |
187 name == "Window Type" || | |
188 name == "Window Increment" || | 187 name == "Window Increment" || |
189 name == "Zero Padding") return tr("Window"); | 188 name == "Zero Padding") return tr("Window"); |
190 if (name == "Colour" || | 189 if (name == "Colour" || |
191 name == "Gain" || | 190 // name == "Gain" || |
192 name == "Threshold" || | 191 name == "Threshold" || |
193 name == "Colour Rotation") return tr("Colour"); | 192 name == "Colour Rotation") return tr("Colour"); |
194 if (name == "Normalize Columns" || | 193 if (name == "Normalize Columns" || |
195 name == "Normalize Visible Area" || | 194 name == "Normalize Visible Area" || |
196 name == "Bin Display" || | 195 // name == "Bin Display" || |
196 name == "Gain" || | |
197 name == "Colour Scale") return tr("Scale"); | 197 name == "Colour Scale") return tr("Scale"); |
198 if (name == "Max Frequency" || | 198 // if (name == "Max Frequency" || |
199 name == "Min Frequency" || | 199 // name == "Min Frequency" || |
200 name == "Frequency Scale" || | 200 // name == "Frequency Scale" || |
201 name == "Frequency Adjustment") return tr("Range"); | 201 // name == "Frequency Adjustment") return tr("Range"); |
202 return QString(); | 202 return QString(); |
203 } | 203 } |
204 | 204 |
205 int | 205 int |
206 SpectrogramLayer::getPropertyRangeAndValue(const PropertyName &name, | 206 SpectrogramLayer::getPropertyRangeAndValue(const PropertyName &name, |
248 | 248 |
249 *min = 0; | 249 *min = 0; |
250 *max = 6; | 250 *max = 6; |
251 | 251 |
252 deft = (int)m_colourScheme; | 252 deft = (int)m_colourScheme; |
253 | |
254 } else if (name == "Window Type") { | |
255 | |
256 *min = 0; | |
257 *max = 6; | |
258 | |
259 deft = (int)m_windowType; | |
260 | 253 |
261 } else if (name == "Window Size") { | 254 } else if (name == "Window Size") { |
262 | 255 |
263 *min = 0; | 256 *min = 0; |
264 *max = 10; | 257 *max = 10; |
366 case 0: return tr("Linear"); | 359 case 0: return tr("Linear"); |
367 case 1: return tr("Meter"); | 360 case 1: return tr("Meter"); |
368 case 2: return tr("dB"); | 361 case 2: return tr("dB"); |
369 case 3: return tr("Other"); | 362 case 3: return tr("Other"); |
370 case 4: return tr("Phase"); | 363 case 4: return tr("Phase"); |
371 } | |
372 } | |
373 if (name == "Window Type") { | |
374 switch ((WindowType)value) { | |
375 default: | |
376 case RectangularWindow: return tr("Rectangle"); | |
377 case BartlettWindow: return tr("Bartlett"); | |
378 case HammingWindow: return tr("Hamming"); | |
379 case HanningWindow: return tr("Hanning"); | |
380 case BlackmanWindow: return tr("Blackman"); | |
381 case GaussianWindow: return tr("Gaussian"); | |
382 case ParzenWindow: return tr("Parzen"); | |
383 } | 364 } |
384 } | 365 } |
385 if (name == "Window Size") { | 366 if (name == "Window Size") { |
386 return QString("%1").arg(32 << value); | 367 return QString("%1").arg(32 << value); |
387 } | 368 } |
467 case 3: setColourScheme(RedOnBlue); break; | 448 case 3: setColourScheme(RedOnBlue); break; |
468 case 4: setColourScheme(YellowOnBlack); break; | 449 case 4: setColourScheme(YellowOnBlack); break; |
469 case 5: setColourScheme(BlueOnBlack); break; | 450 case 5: setColourScheme(BlueOnBlack); break; |
470 case 6: setColourScheme(Rainbow); break; | 451 case 6: setColourScheme(Rainbow); break; |
471 } | 452 } |
472 } else if (name == "Window Type") { | |
473 setWindowType(WindowType(value)); | |
474 } else if (name == "Window Size") { | 453 } else if (name == "Window Size") { |
475 setWindowSize(32 << value); | 454 setWindowSize(32 << value); |
476 } else if (name == "Window Increment") { | 455 } else if (name == "Window Increment") { |
477 setWindowHopLevel(value); | 456 setWindowHopLevel(value); |
478 } else if (name == "Zero Padding") { | 457 } else if (name == "Zero Padding") { |
1229 } | 1208 } |
1230 | 1209 |
1231 float | 1210 float |
1232 SpectrogramLayer::getInputForDisplayValue(unsigned char uc) const | 1211 SpectrogramLayer::getInputForDisplayValue(unsigned char uc) const |
1233 { | 1212 { |
1213 //!!! unused | |
1214 | |
1234 int value = uc; | 1215 int value = uc; |
1235 float input; | 1216 float input; |
1236 | 1217 |
1237 //!!! incorrect for normalizing visible area (and also out of date) | 1218 //!!! incorrect for normalizing visible area (and also out of date) |
1238 | 1219 |
1590 } | 1571 } |
1591 | 1572 |
1592 if (m_fftModels.find(v) == m_fftModels.end()) { | 1573 if (m_fftModels.find(v) == m_fftModels.end()) { |
1593 m_fftModels[v] = FFTFillPair | 1574 m_fftModels[v] = FFTFillPair |
1594 (new FFTModel(m_model, | 1575 (new FFTModel(m_model, |
1595 m_channel, | 1576 m_channel, |
1596 m_windowType, | 1577 m_windowType, |
1597 m_windowSize, | 1578 m_windowSize, |
1598 getWindowIncrement(), | 1579 getWindowIncrement(), |
1599 fftSize, | 1580 fftSize, |
1600 true, | 1581 true, |
1601 m_candidateFillStartFrame), | 1582 m_candidateFillStartFrame), |
1602 0); | 1583 0); |
1603 | 1584 |
1604 delete m_updateTimer; | 1585 delete m_updateTimer; |
1605 m_updateTimer = new QTimer((SpectrogramLayer *)this); | 1586 m_updateTimer = new QTimer((SpectrogramLayer *)this); |
1606 connect(m_updateTimer, SIGNAL(timeout()), | 1587 connect(m_updateTimer, SIGNAL(timeout()), |
2874 { | 2855 { |
2875 QString s; | 2856 QString s; |
2876 | 2857 |
2877 s += QString("channel=\"%1\" " | 2858 s += QString("channel=\"%1\" " |
2878 "windowSize=\"%2\" " | 2859 "windowSize=\"%2\" " |
2879 "windowType=\"%3\" " | 2860 "windowHopLevel=\"%3\" " |
2880 "windowHopLevel=\"%4\" " | 2861 "gain=\"%4\" " |
2881 "gain=\"%5\" " | 2862 "threshold=\"%5\" ") |
2882 "threshold=\"%6\" ") | |
2883 .arg(m_channel) | 2863 .arg(m_channel) |
2884 .arg(m_windowSize) | 2864 .arg(m_windowSize) |
2885 .arg(m_windowType) | |
2886 .arg(m_windowHopLevel) | 2865 .arg(m_windowHopLevel) |
2887 .arg(m_gain) | 2866 .arg(m_gain) |
2888 .arg(m_threshold); | 2867 .arg(m_threshold); |
2889 | 2868 |
2890 s += QString("minFrequency=\"%1\" " | 2869 s += QString("minFrequency=\"%1\" " |
2892 "colourScale=\"%3\" " | 2871 "colourScale=\"%3\" " |
2893 "colourScheme=\"%4\" " | 2872 "colourScheme=\"%4\" " |
2894 "colourRotation=\"%5\" " | 2873 "colourRotation=\"%5\" " |
2895 "frequencyScale=\"%6\" " | 2874 "frequencyScale=\"%6\" " |
2896 "binDisplay=\"%7\" " | 2875 "binDisplay=\"%7\" " |
2897 "normalizeColumns=\"%8\"") | 2876 "normalizeColumns=\"%8\" " |
2877 "normalizeVisibleArea=\"%9\"") | |
2898 .arg(m_minFrequency) | 2878 .arg(m_minFrequency) |
2899 .arg(m_maxFrequency) | 2879 .arg(m_maxFrequency) |
2900 .arg(m_colourScale) | 2880 .arg(m_colourScale) |
2901 .arg(m_colourScheme) | 2881 .arg(m_colourScheme) |
2902 .arg(m_colourRotation) | 2882 .arg(m_colourRotation) |
2903 .arg(m_frequencyScale) | 2883 .arg(m_frequencyScale) |
2904 .arg(m_binDisplay) | 2884 .arg(m_binDisplay) |
2905 .arg(m_normalizeColumns ? "true" : "false"); | 2885 .arg(m_normalizeColumns ? "true" : "false") |
2886 .arg(m_normalizeVisibleArea ? "true" : "false"); | |
2906 | 2887 |
2907 return Layer::toXmlString(indent, extraAttributes + " " + s); | 2888 return Layer::toXmlString(indent, extraAttributes + " " + s); |
2908 } | 2889 } |
2909 | 2890 |
2910 void | 2891 void |
2915 int channel = attributes.value("channel").toInt(&ok); | 2896 int channel = attributes.value("channel").toInt(&ok); |
2916 if (ok) setChannel(channel); | 2897 if (ok) setChannel(channel); |
2917 | 2898 |
2918 size_t windowSize = attributes.value("windowSize").toUInt(&ok); | 2899 size_t windowSize = attributes.value("windowSize").toUInt(&ok); |
2919 if (ok) setWindowSize(windowSize); | 2900 if (ok) setWindowSize(windowSize); |
2920 | |
2921 WindowType windowType = (WindowType) | |
2922 attributes.value("windowType").toInt(&ok); | |
2923 if (ok) setWindowType(windowType); | |
2924 | 2901 |
2925 size_t windowHopLevel = attributes.value("windowHopLevel").toUInt(&ok); | 2902 size_t windowHopLevel = attributes.value("windowHopLevel").toUInt(&ok); |
2926 if (ok) setWindowHopLevel(windowHopLevel); | 2903 if (ok) setWindowHopLevel(windowHopLevel); |
2927 else { | 2904 else { |
2928 size_t windowOverlap = attributes.value("windowOverlap").toUInt(&ok); | 2905 size_t windowOverlap = attributes.value("windowOverlap").toUInt(&ok); |
2968 if (ok) setBinDisplay(binDisplay); | 2945 if (ok) setBinDisplay(binDisplay); |
2969 | 2946 |
2970 bool normalizeColumns = | 2947 bool normalizeColumns = |
2971 (attributes.value("normalizeColumns").trimmed() == "true"); | 2948 (attributes.value("normalizeColumns").trimmed() == "true"); |
2972 setNormalizeColumns(normalizeColumns); | 2949 setNormalizeColumns(normalizeColumns); |
2973 } | 2950 |
2974 | 2951 bool normalizeVisibleArea = |
2952 (attributes.value("normalizeVisibleArea").trimmed() == "true"); | |
2953 setNormalizeVisibleArea(normalizeVisibleArea); | |
2954 } | |
2955 |