comparison layer/SpectrogramLayer.cpp @ 1379:b6cca362bbf4 spectrogramparam

Experimental oversampling param
author Chris Cannam
date Tue, 06 Nov 2018 13:36:04 +0000
parents d79e21855aef
children 2df1af7ac752
comparison
equal deleted inserted replaced
1378:f08a3b8cdb9d 1379:b6cca362bbf4
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
745 invalidateRenderers();
746
747 m_windowSize = ws;
748
749 recreateFFTModel();
750
751 emit layerParametersChanged();
752 }
753
754 int
755 SpectrogramLayer::getWindowSize() const
756 {
757 return m_windowSize;
758 }
759
760 void
761 SpectrogramLayer::setWindowHopLevel(int v)
762 {
763 if (m_windowHopLevel == v) return;
764
765 invalidateRenderers();
766
767 m_windowHopLevel = v;
768
769 recreateFFTModel();
770
771 emit layerParametersChanged();
772 }
773
774 int
775 SpectrogramLayer::getWindowHopLevel() const
776 {
777 return m_windowHopLevel;
778 }
779
780 void
781 SpectrogramLayer::setOversampling(int oversampling)
782 {
783 if (m_oversampling == oversampling) return;
784 invalidateRenderers();
785 m_oversampling = oversampling;
786 recreateFFTModel();
787 emit layerParametersChanged();
788 }
789
790 int
791 SpectrogramLayer::getOversampling() const
792 {
793 return m_oversampling;
794 /*!!!
712 if (m_binDisplay != BinDisplay::AllBins) { 795 if (m_binDisplay != BinDisplay::AllBins) {
713 return 1; 796 return 1;
714 } 797 }
715 798
716 Preferences::SpectrogramSmoothing smoothing = 799 Preferences::SpectrogramSmoothing smoothing =
720 smoothing == Preferences::SpectrogramInterpolated) { 803 smoothing == Preferences::SpectrogramInterpolated) {
721 return 1; 804 return 1;
722 } 805 }
723 806
724 return 4; 807 return 4;
725 } 808 */
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 } 809 }
772 810
773 void 811 void
774 SpectrogramLayer::setWindowType(WindowType w) 812 SpectrogramLayer::setWindowType(WindowType w)
775 { 813 {