Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1395:32bbb86094c3
Merge from branch spectrogramparam
author | Chris Cannam |
---|---|
date | Wed, 14 Nov 2018 14:23:17 +0000 |
parents | 2df1af7ac752 |
children | ba1f0234efa7 |
comparison
equal
deleted
inserted
replaced
1380:78eecb19e688 | 1395:32bbb86094c3 |
---|---|
59 m_model(0), | 59 m_model(0), |
60 m_channel(0), | 60 m_channel(0), |
61 m_windowSize(1024), | 61 m_windowSize(1024), |
62 m_windowType(HanningWindow), | 62 m_windowType(HanningWindow), |
63 m_windowHopLevel(2), | 63 m_windowHopLevel(2), |
64 m_oversampling(1), | |
64 m_gain(1.0), | 65 m_gain(1.0), |
65 m_initialGain(1.0), | 66 m_initialGain(1.0), |
66 m_threshold(1.0e-8f), | 67 m_threshold(1.0e-8f), |
67 m_initialThreshold(1.0e-8f), | 68 m_initialThreshold(1.0e-8f), |
68 m_colourRotation(0), | 69 m_colourRotation(0), |
234 PropertyList list; | 235 PropertyList list; |
235 list.push_back("Colour"); | 236 list.push_back("Colour"); |
236 list.push_back("Colour Scale"); | 237 list.push_back("Colour Scale"); |
237 list.push_back("Window Size"); | 238 list.push_back("Window Size"); |
238 list.push_back("Window Increment"); | 239 list.push_back("Window Increment"); |
240 list.push_back("Oversampling"); | |
239 list.push_back("Normalization"); | 241 list.push_back("Normalization"); |
240 list.push_back("Bin Display"); | 242 list.push_back("Bin Display"); |
241 list.push_back("Threshold"); | 243 list.push_back("Threshold"); |
242 list.push_back("Gain"); | 244 list.push_back("Gain"); |
243 list.push_back("Colour Rotation"); | 245 list.push_back("Colour Rotation"); |
252 { | 254 { |
253 if (name == "Colour") return tr("Colour"); | 255 if (name == "Colour") return tr("Colour"); |
254 if (name == "Colour Scale") return tr("Colour Scale"); | 256 if (name == "Colour Scale") return tr("Colour Scale"); |
255 if (name == "Window Size") return tr("Window Size"); | 257 if (name == "Window Size") return tr("Window Size"); |
256 if (name == "Window Increment") return tr("Window Overlap"); | 258 if (name == "Window Increment") return tr("Window Overlap"); |
259 if (name == "Oversampling") return tr("Oversampling"); | |
257 if (name == "Normalization") return tr("Normalization"); | 260 if (name == "Normalization") return tr("Normalization"); |
258 if (name == "Bin Display") return tr("Bin Display"); | 261 if (name == "Bin Display") return tr("Bin Display"); |
259 if (name == "Threshold") return tr("Threshold"); | 262 if (name == "Threshold") return tr("Threshold"); |
260 if (name == "Gain") return tr("Gain"); | 263 if (name == "Gain") return tr("Gain"); |
261 if (name == "Colour Rotation") return tr("Colour Rotation"); | 264 if (name == "Colour Rotation") return tr("Colour Rotation"); |
285 SpectrogramLayer::getPropertyGroupName(const PropertyName &name) const | 288 SpectrogramLayer::getPropertyGroupName(const PropertyName &name) const |
286 { | 289 { |
287 if (name == "Bin Display" || | 290 if (name == "Bin Display" || |
288 name == "Frequency Scale") return tr("Bins"); | 291 name == "Frequency Scale") return tr("Bins"); |
289 if (name == "Window Size" || | 292 if (name == "Window Size" || |
290 name == "Window Increment") return tr("Window"); | 293 name == "Window Increment" || |
294 name == "Oversampling") return tr("Window"); | |
291 if (name == "Colour" || | 295 if (name == "Colour" || |
292 name == "Threshold" || | 296 name == "Threshold" || |
293 name == "Colour Rotation") return tr("Colour"); | 297 name == "Colour Rotation") return tr("Colour"); |
294 if (name == "Normalization" || | 298 if (name == "Normalization" || |
295 name == "Gain" || | 299 name == "Gain" || |
374 *min = 0; | 378 *min = 0; |
375 *max = 5; | 379 *max = 5; |
376 *deflt = 2; | 380 *deflt = 2; |
377 | 381 |
378 val = m_windowHopLevel; | 382 val = m_windowHopLevel; |
379 | 383 |
384 } else if (name == "Oversampling") { | |
385 | |
386 *min = 0; | |
387 *max = 3; | |
388 *deflt = 0; | |
389 | |
390 val = 0; | |
391 int ov = m_oversampling; | |
392 while (ov > 1) { ov >>= 1; val ++; } | |
393 | |
380 } else if (name == "Min Frequency") { | 394 } else if (name == "Min Frequency") { |
381 | 395 |
382 *min = 0; | 396 *min = 0; |
383 *max = 9; | 397 *max = 9; |
384 *deflt = 1; | 398 *deflt = 1; |
481 case 1: return tr("25 %"); | 495 case 1: return tr("25 %"); |
482 case 2: return tr("50 %"); | 496 case 2: return tr("50 %"); |
483 case 3: return tr("75 %"); | 497 case 3: return tr("75 %"); |
484 case 4: return tr("87.5 %"); | 498 case 4: return tr("87.5 %"); |
485 case 5: return tr("93.75 %"); | 499 case 5: return tr("93.75 %"); |
500 } | |
501 } | |
502 if (name == "Oversampling") { | |
503 switch (value) { | |
504 default: | |
505 case 0: return tr("1x"); | |
506 case 1: return tr("2x"); | |
507 case 2: return tr("4x"); | |
508 case 3: return tr("8x"); | |
486 } | 509 } |
487 } | 510 } |
488 if (name == "Min Frequency") { | 511 if (name == "Min Frequency") { |
489 switch (value) { | 512 switch (value) { |
490 default: | 513 default: |
576 setColourMap(value); | 599 setColourMap(value); |
577 } else if (name == "Window Size") { | 600 } else if (name == "Window Size") { |
578 setWindowSize(32 << value); | 601 setWindowSize(32 << value); |
579 } else if (name == "Window Increment") { | 602 } else if (name == "Window Increment") { |
580 setWindowHopLevel(value); | 603 setWindowHopLevel(value); |
604 } else if (name == "Oversampling") { | |
605 setOversampling(1 << value); | |
581 } else if (name == "Min Frequency") { | 606 } else if (name == "Min Frequency") { |
582 switch (value) { | 607 switch (value) { |
583 default: | 608 default: |
584 case 0: setMinFrequency(0); break; | 609 case 0: setMinFrequency(0); break; |
585 case 1: setMinFrequency(10); break; | 610 case 1: setMinFrequency(10); break; |
705 { | 730 { |
706 return m_channel; | 731 return m_channel; |
707 } | 732 } |
708 | 733 |
709 int | 734 int |
710 SpectrogramLayer::getFFTOversampling() const | 735 SpectrogramLayer::getFFTSize() const |
711 { | 736 { |
737 return m_windowSize * m_oversampling; | |
738 } | |
739 | |
740 void | |
741 SpectrogramLayer::setWindowSize(int ws) | |
742 { | |
743 if (m_windowSize == ws) return; | |
744 invalidateRenderers(); | |
745 m_windowSize = ws; | |
746 recreateFFTModel(); | |
747 emit layerParametersChanged(); | |
748 } | |
749 | |
750 int | |
751 SpectrogramLayer::getWindowSize() const | |
752 { | |
753 return m_windowSize; | |
754 } | |
755 | |
756 void | |
757 SpectrogramLayer::setWindowHopLevel(int v) | |
758 { | |
759 if (m_windowHopLevel == v) return; | |
760 invalidateRenderers(); | |
761 m_windowHopLevel = v; | |
762 recreateFFTModel(); | |
763 emit layerParametersChanged(); | |
764 } | |
765 | |
766 int | |
767 SpectrogramLayer::getWindowHopLevel() const | |
768 { | |
769 return m_windowHopLevel; | |
770 } | |
771 | |
772 void | |
773 SpectrogramLayer::setOversampling(int oversampling) | |
774 { | |
775 if (m_oversampling == oversampling) return; | |
776 invalidateRenderers(); | |
777 m_oversampling = oversampling; | |
778 recreateFFTModel(); | |
779 emit layerParametersChanged(); | |
780 } | |
781 | |
782 int | |
783 SpectrogramLayer::getOversampling() const | |
784 { | |
785 return m_oversampling; | |
786 /*!!! | |
712 if (m_binDisplay != BinDisplay::AllBins) { | 787 if (m_binDisplay != BinDisplay::AllBins) { |
713 return 1; | 788 return 1; |
714 } | 789 } |
715 | 790 |
716 Preferences::SpectrogramSmoothing smoothing = | 791 Preferences::SpectrogramSmoothing smoothing = |
720 smoothing == Preferences::SpectrogramInterpolated) { | 795 smoothing == Preferences::SpectrogramInterpolated) { |
721 return 1; | 796 return 1; |
722 } | 797 } |
723 | 798 |
724 return 4; | 799 return 4; |
725 } | 800 */ |
726 | |
727 int | |
728 SpectrogramLayer::getFFTSize() const | |
729 { | |
730 return m_windowSize * getFFTOversampling(); | |
731 } | |
732 | |
733 void | |
734 SpectrogramLayer::setWindowSize(int ws) | |
735 { | |
736 if (m_windowSize == ws) return; | |
737 | |
738 invalidateRenderers(); | |
739 | |
740 m_windowSize = ws; | |
741 | |
742 recreateFFTModel(); | |
743 | |
744 emit layerParametersChanged(); | |
745 } | |
746 | |
747 int | |
748 SpectrogramLayer::getWindowSize() const | |
749 { | |
750 return m_windowSize; | |
751 } | |
752 | |
753 void | |
754 SpectrogramLayer::setWindowHopLevel(int v) | |
755 { | |
756 if (m_windowHopLevel == v) return; | |
757 | |
758 invalidateRenderers(); | |
759 | |
760 m_windowHopLevel = v; | |
761 | |
762 recreateFFTModel(); | |
763 | |
764 emit layerParametersChanged(); | |
765 } | |
766 | |
767 int | |
768 SpectrogramLayer::getWindowHopLevel() const | |
769 { | |
770 return m_windowHopLevel; | |
771 } | 801 } |
772 | 802 |
773 void | 803 void |
774 SpectrogramLayer::setWindowType(WindowType w) | 804 SpectrogramLayer::setWindowType(WindowType w) |
775 { | 805 { |
2498 QString s; | 2528 QString s; |
2499 | 2529 |
2500 s += QString("channel=\"%1\" " | 2530 s += QString("channel=\"%1\" " |
2501 "windowSize=\"%2\" " | 2531 "windowSize=\"%2\" " |
2502 "windowHopLevel=\"%3\" " | 2532 "windowHopLevel=\"%3\" " |
2503 "gain=\"%4\" " | 2533 "oversampling=\"%4\" " |
2504 "threshold=\"%5\" ") | 2534 "gain=\"%5\" " |
2535 "threshold=\"%6\" ") | |
2505 .arg(m_channel) | 2536 .arg(m_channel) |
2506 .arg(m_windowSize) | 2537 .arg(m_windowSize) |
2507 .arg(m_windowHopLevel) | 2538 .arg(m_windowHopLevel) |
2539 .arg(m_oversampling) | |
2508 .arg(m_gain) | 2540 .arg(m_gain) |
2509 .arg(m_threshold); | 2541 .arg(m_threshold); |
2510 | 2542 |
2511 s += QString("minFrequency=\"%1\" " | 2543 s += QString("minFrequency=\"%1\" " |
2512 "maxFrequency=\"%2\" " | 2544 "maxFrequency=\"%2\" " |
2581 else if (windowOverlap == 75) setWindowHopLevel(3); | 2613 else if (windowOverlap == 75) setWindowHopLevel(3); |
2582 else if (windowOverlap == 90) setWindowHopLevel(4); | 2614 else if (windowOverlap == 90) setWindowHopLevel(4); |
2583 } | 2615 } |
2584 } | 2616 } |
2585 | 2617 |
2618 int oversampling = attributes.value("oversampling").toUInt(&ok); | |
2619 if (ok) setOversampling(oversampling); | |
2620 | |
2586 float gain = attributes.value("gain").toFloat(&ok); | 2621 float gain = attributes.value("gain").toFloat(&ok); |
2587 if (ok) setGain(gain); | 2622 if (ok) setGain(gain); |
2588 | 2623 |
2589 float threshold = attributes.value("threshold").toFloat(&ok); | 2624 float threshold = attributes.value("threshold").toFloat(&ok); |
2590 if (ok) setThreshold(threshold); | 2625 if (ok) setThreshold(threshold); |