comparison plugins/ChromagramPlugin.cpp @ 52:4fe04e706839

* Add some descriptions etc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 30 Jan 2008 13:33:23 +0000
parents 64e4c8aec287
children b084e87b83e4
comparison
equal deleted inserted replaced
51:64e4c8aec287 52:4fe04e706839
96 96
97 ParameterDescriptor desc; 97 ParameterDescriptor desc;
98 desc.identifier = "minpitch"; 98 desc.identifier = "minpitch";
99 desc.name = "Minimum Pitch"; 99 desc.name = "Minimum Pitch";
100 desc.unit = "MIDI units"; 100 desc.unit = "MIDI units";
101 //!!! descriptions 101 desc.description = "MIDI pitch corresponding to the lowest frequency to be included in the chromagram";
102 desc.minValue = 0; 102 desc.minValue = 0;
103 desc.maxValue = 127; 103 desc.maxValue = 127;
104 desc.defaultValue = 12; 104 desc.defaultValue = 12;
105 desc.isQuantized = true; 105 desc.isQuantized = true;
106 desc.quantizeStep = 1; 106 desc.quantizeStep = 1;
107 list.push_back(desc); 107 list.push_back(desc);
108 108
109 desc.identifier = "maxpitch"; 109 desc.identifier = "maxpitch";
110 desc.name = "Maximum Pitch"; 110 desc.name = "Maximum Pitch";
111 desc.unit = "MIDI units"; 111 desc.unit = "MIDI units";
112 desc.description = "MIDI pitch corresponding to the highest frequency to be included in the chromagram";
112 desc.minValue = 0; 113 desc.minValue = 0;
113 desc.maxValue = 127; 114 desc.maxValue = 127;
114 desc.defaultValue = 96; 115 desc.defaultValue = 96;
115 desc.isQuantized = true; 116 desc.isQuantized = true;
116 desc.quantizeStep = 1; 117 desc.quantizeStep = 1;
117 list.push_back(desc); 118 list.push_back(desc);
118 119
119 desc.identifier = "tuning"; 120 desc.identifier = "tuning";
120 desc.name = "Tuning Frequency"; 121 desc.name = "Tuning Frequency";
121 desc.unit = "Hz"; 122 desc.unit = "Hz";
123 desc.description = "Frequency of concert A";
122 desc.minValue = 420; 124 desc.minValue = 420;
123 desc.maxValue = 460; 125 desc.maxValue = 460;
124 desc.defaultValue = 440; 126 desc.defaultValue = 440;
125 desc.isQuantized = false; 127 desc.isQuantized = false;
126 list.push_back(desc); 128 list.push_back(desc);
127 129
128 desc.identifier = "bpo"; 130 desc.identifier = "bpo";
129 desc.name = "Bins per Octave"; 131 desc.name = "Bins per Octave";
130 desc.unit = "bins"; 132 desc.unit = "bins";
133 desc.description = "Number of constant-Q transform bins per octave, and the number of bins for the chromagram outputs";
131 desc.minValue = 2; 134 desc.minValue = 2;
132 desc.maxValue = 36; 135 desc.maxValue = 36;
133 desc.defaultValue = 12; 136 desc.defaultValue = 12;
134 desc.isQuantized = true; 137 desc.isQuantized = true;
135 desc.quantizeStep = 1; 138 desc.quantizeStep = 1;
136 list.push_back(desc); 139 list.push_back(desc);
137 140
138 desc.identifier = "normalization"; 141 desc.identifier = "normalization";
139 desc.name = "Normalization"; 142 desc.name = "Normalization";
140 desc.unit = ""; 143 desc.unit = "";
144 desc.description = "Normalization for each chromagram output column";
141 desc.minValue = 0; 145 desc.minValue = 0;
142 desc.maxValue = 2; 146 desc.maxValue = 2;
143 desc.defaultValue = 2; 147 desc.defaultValue = 2;
144 desc.isQuantized = true; 148 desc.isQuantized = true;
145 desc.quantizeStep = 1; 149 desc.quantizeStep = 1;
205 } 209 }
206 210
207 if (channels < getMinChannelCount() || 211 if (channels < getMinChannelCount() ||
208 channels > getMaxChannelCount()) return false; 212 channels > getMaxChannelCount()) return false;
209 213
210 std::cerr << "ChromagramPlugin::initialise: step " << stepSize << ", block "
211 << blockSize << std::endl;
212
213 m_chromagram = new Chromagram(m_config); 214 m_chromagram = new Chromagram(m_config);
214 m_binsums = vector<double>(m_config.BPO); 215 m_binsums = vector<double>(m_config.BPO);
215 216
216 for (int i = 0; i < m_config.BPO; ++i) { 217 for (int i = 0; i < m_config.BPO; ++i) {
217 m_binsums[i] = 0.0; 218 m_binsums[i] = 0.0;
220 m_count = 0; 221 m_count = 0;
221 222
222 m_step = m_chromagram->getHopSize(); 223 m_step = m_chromagram->getHopSize();
223 m_block = m_chromagram->getFrameSize(); 224 m_block = m_chromagram->getFrameSize();
224 225
225 //!!! stepSize != m_step should not be an error 226 if (blockSize != m_block) {
226 227 std::cerr << "ChromagramPlugin::initialise: ERROR: supplied block size " << blockSize << " differs from required block size " << m_block << ", initialise failing" << std::endl;
227 if (stepSize != m_step ||
228 blockSize != m_block) {
229 delete m_chromagram; 228 delete m_chromagram;
230 m_chromagram = 0; 229 m_chromagram = 0;
231 return false; 230 return false;
231 }
232
233 if (stepSize != m_step) {
234 std::cerr << "ChromagramPlugin::initialise: NOTE: supplied step size " << stepSize << " differs from expected step size " << m_step << " (for block size = " << m_block << ")" << std::endl;
232 } 235 }
233 236
234 return true; 237 return true;
235 } 238 }
236 239
274 277
275 OutputDescriptor d; 278 OutputDescriptor d;
276 d.identifier = "chromagram"; 279 d.identifier = "chromagram";
277 d.name = "Chromagram"; 280 d.name = "Chromagram";
278 d.unit = ""; 281 d.unit = "";
282 d.description = "Output of chromagram, as a single vector per process block";
279 d.hasFixedBinCount = true; 283 d.hasFixedBinCount = true;
280 d.binCount = m_config.BPO; 284 d.binCount = m_config.BPO;
281 285
282 const char *names[] = 286 const char *names[] =
283 { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; 287 { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
302 d.sampleType = OutputDescriptor::OneSamplePerStep; 306 d.sampleType = OutputDescriptor::OneSamplePerStep;
303 list.push_back(d); 307 list.push_back(d);
304 308
305 d.identifier = "chromameans"; 309 d.identifier = "chromameans";
306 d.name = "Chroma Means"; 310 d.name = "Chroma Means";
307 //!!! descriptions 311 d.description = "Mean values of chromagram bins across the duration of the input audio";
308 d.sampleType = OutputDescriptor::FixedSampleRate; 312 d.sampleType = OutputDescriptor::FixedSampleRate;
309 d.sampleRate = 1; 313 d.sampleRate = 1;
310 list.push_back(d); 314 list.push_back(d);
311 315
312 return list; 316 return list;