comparison base/Preferences.cpp @ 140:a35098a9c814

* start work on prefs dialog * some work on highlighting local points in spectrogram
author Chris Cannam
date Thu, 20 Jul 2006 16:51:20 +0000
parents 6332e41c1619
children 4f26f623a8bc
comparison
equal deleted inserted replaced
139:8ce30801f39a 140:a35098a9c814
18 Preferences * 18 Preferences *
19 Preferences::m_instance = new Preferences(); 19 Preferences::m_instance = new Preferences();
20 20
21 Preferences::Preferences() : 21 Preferences::Preferences() :
22 m_smoothSpectrogram(true), 22 m_smoothSpectrogram(true),
23 m_tuningFrequency(440) 23 m_tuningFrequency(440),
24 m_propertyBoxLayout(VerticallyStacked),
25 m_windowType(HanningWindow)
24 { 26 {
25 } 27 }
26 28
27 Preferences::PropertyList 29 Preferences::PropertyList
28 Preferences::getProperties() const 30 Preferences::getProperties() const
29 { 31 {
30 PropertyList props; 32 PropertyList props;
31 props.push_back("Smooth Spectrogram"); 33 props.push_back("Smooth Spectrogram");
32 props.push_back("Tuning Frequency"); 34 props.push_back("Tuning Frequency");
33 props.push_back("Property Box Layout"); 35 props.push_back("Property Box Layout");
36 props.push_back("Window Type");
34 return props; 37 return props;
35 } 38 }
36 39
37 QString 40 QString
38 Preferences::getPropertyLabel(const PropertyName &name) const 41 Preferences::getPropertyLabel(const PropertyName &name) const
44 return tr("Tuning Frequency (concert A)"); 47 return tr("Tuning Frequency (concert A)");
45 } 48 }
46 if (name == "Property Box Layout") { 49 if (name == "Property Box Layout") {
47 return tr("Arrangement of Layer Properties"); 50 return tr("Arrangement of Layer Properties");
48 } 51 }
52 if (name == "Window Type") {
53 return tr("Spectral Analysis Window Shape");
54 }
49 return name; 55 return name;
50 } 56 }
51 57
52 Preferences::PropertyType 58 Preferences::PropertyType
53 Preferences::getPropertyType(const PropertyName &name) const 59 Preferences::getPropertyType(const PropertyName &name) const
57 } 63 }
58 if (name == "Tuning Frequency") { 64 if (name == "Tuning Frequency") {
59 return RangeProperty; 65 return RangeProperty;
60 } 66 }
61 if (name == "Property Box Layout") { 67 if (name == "Property Box Layout") {
68 return ValueProperty;
69 }
70 if (name == "Window Type") {
62 return ValueProperty; 71 return ValueProperty;
63 } 72 }
64 return InvalidProperty; 73 return InvalidProperty;
65 } 74 }
66 75
80 if (min) *min = 0; 89 if (min) *min = 0;
81 if (max) *max = 1; 90 if (max) *max = 1;
82 return m_propertyBoxLayout == Layered ? 1 : 0; 91 return m_propertyBoxLayout == Layered ? 1 : 0;
83 } 92 }
84 93
94 if (name == "Window Type") {
95 if (min) *min = int(RectangularWindow);
96 if (max) *max = int(ParzenWindow);
97 return int(m_windowType);
98 }
99
85 return 0; 100 return 0;
86 } 101 }
87 102
88 QString 103 QString
89 Preferences::getPropertyValueLabel(const PropertyName &name, 104 Preferences::getPropertyValueLabel(const PropertyName &name,
90 int value) const 105 int value) const
91 { 106 {
92 if (name == "Property Box Layout") { 107 if (name == "Property Box Layout") {
93 if (value == 0) return tr("Vertically Stacked"); 108 if (value == 0) return tr("Vertically Stacked");
94 else return tr("Layered"); 109 else return tr("Layered");
110 }
111 if (name == "Window Type") {
112 switch (WindowType(value)) {
113 case RectangularWindow: return tr("Rectangular");
114 case BartlettWindow: return tr("Bartlett");
115 case HammingWindow: return tr("Hamming");
116 case HanningWindow: return tr("Hanning");
117 case BlackmanWindow: return tr("Blackman");
118 case GaussianWindow: return tr("Gaussian");
119 case ParzenWindow: return tr("Parzen");
120 }
95 } 121 }
96 return ""; 122 return "";
97 } 123 }
98 124
99 QString 125 QString
115 setSmoothSpectrogram(value > 0.1); 141 setSmoothSpectrogram(value > 0.1);
116 } else if (name == "Tuning Frequency") { 142 } else if (name == "Tuning Frequency") {
117 //!!! 143 //!!!
118 } else if (name == "Property Box Layout") { 144 } else if (name == "Property Box Layout") {
119 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered); 145 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
146 } else if (name == "Window Type") {
147 setWindowType(WindowType(value));
120 } 148 }
121 } 149 }
122 150
123 void 151 void
124 Preferences::setSmoothSpectrogram(bool smooth) 152 Preferences::setSmoothSpectrogram(bool smooth)
145 m_propertyBoxLayout = layout; 173 m_propertyBoxLayout = layout;
146 //!!! emit 174 //!!! emit
147 } 175 }
148 } 176 }
149 177
178 void
179 Preferences::setWindowType(WindowType type)
180 {
181 if (m_windowType != type) {
182 m_windowType = type;
183 //!!! emit
184 }
185 }
186