Mercurial > hg > silvet
comparison src/Silvet.cpp @ 52:22553e7b2a63 preshift
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 07 Apr 2014 17:07:51 +0100 |
parents | ce1d88759557 782ca0d9ff3e |
children | 384338fa460d |
comparison
equal
deleted
inserted
replaced
50:ce1d88759557 | 52:22553e7b2a63 |
---|---|
166 Silvet::getOutputDescriptors() const | 166 Silvet::getOutputDescriptors() const |
167 { | 167 { |
168 OutputList list; | 168 OutputList list; |
169 | 169 |
170 OutputDescriptor d; | 170 OutputDescriptor d; |
171 d.identifier = "transcription"; | 171 d.identifier = "notes"; |
172 d.name = "Transcription"; | 172 d.name = "Note transcription"; |
173 d.description = ""; //!!! | 173 d.description = "Overall note transcription across all instruments"; |
174 d.unit = "Hz"; | 174 d.unit = "Hz"; |
175 d.hasFixedBinCount = true; | 175 d.hasFixedBinCount = true; |
176 d.binCount = 2; | 176 d.binCount = 2; |
177 d.binNames.push_back("Frequency"); | 177 d.binNames.push_back("Frequency"); |
178 d.binNames.push_back("Velocity"); | 178 d.binNames.push_back("Velocity"); |
179 d.hasKnownExtents = false; | 179 d.hasKnownExtents = false; |
180 d.isQuantized = false; | 180 d.isQuantized = false; |
181 d.sampleType = OutputDescriptor::VariableSampleRate; | 181 d.sampleType = OutputDescriptor::VariableSampleRate; |
182 d.sampleRate = m_inputSampleRate / (m_cq ? m_cq->getColumnHop() : 256); | 182 d.sampleRate = m_inputSampleRate / (m_cq ? m_cq->getColumnHop() : 62); |
183 d.hasDuration = true; | 183 d.hasDuration = true; |
184 m_notesOutputNo = list.size(); | 184 m_notesOutputNo = list.size(); |
185 list.push_back(d); | 185 list.push_back(d); |
186 | 186 |
187 d.identifier = "cq"; | |
188 d.name = "Raw constant-Q"; | |
189 d.description = "Unfiltered constant-Q time-frequency distribution"; | |
190 d.unit = ""; | |
191 d.hasFixedBinCount = true; | |
192 d.binCount = processingHeight + 55; | |
193 d.binNames.clear(); | |
194 if (m_cq) { | |
195 char name[20]; | |
196 for (int i = 0; i < processingHeight + 55; ++i) { | |
197 float freq = m_cq->getBinFrequency(i); | |
198 sprintf(name, "%.1f Hz", freq); | |
199 d.binNames.push_back(name); | |
200 } | |
201 } | |
202 d.hasKnownExtents = false; | |
203 d.isQuantized = false; | |
204 d.sampleType = OutputDescriptor::FixedSampleRate; | |
205 d.sampleRate = m_inputSampleRate / (m_cq ? m_cq->getColumnHop() : 62); | |
206 d.hasDuration = false; | |
207 m_cqOutputNo = list.size(); | |
208 list.push_back(d); | |
209 | |
187 d.identifier = "inputgrid"; | 210 d.identifier = "inputgrid"; |
188 d.name = "Filtered time-frequency grid"; | 211 d.name = "Filtered constant-Q"; |
189 d.description = "The pre-processed constant-Q time-frequency distribution used as input to the PLCA step"; | 212 d.description = "Filtered constant-Q time-frequency distribution used as input to the PLCA step"; |
190 d.unit = ""; | 213 d.unit = ""; |
191 d.hasFixedBinCount = true; | 214 d.hasFixedBinCount = true; |
192 d.binCount = processingHeight; | 215 d.binCount = processingHeight; |
193 d.binNames.clear(); | 216 d.binNames.clear(); |
194 if (m_cq) { | 217 if (m_cq) { |
202 d.hasKnownExtents = false; | 225 d.hasKnownExtents = false; |
203 d.isQuantized = false; | 226 d.isQuantized = false; |
204 d.sampleType = OutputDescriptor::FixedSampleRate; | 227 d.sampleType = OutputDescriptor::FixedSampleRate; |
205 d.sampleRate = 25; | 228 d.sampleRate = 25; |
206 d.hasDuration = false; | 229 d.hasDuration = false; |
207 m_cqOutputNo = list.size(); | 230 m_fcqOutputNo = list.size(); |
208 list.push_back(d); | 231 list.push_back(d); |
209 | 232 |
210 d.identifier = "pitchdistribution"; | 233 d.identifier = "pitches"; |
211 d.name = "Pitch distribution"; | 234 d.name = "Pitch activation"; |
212 d.description = "The estimated pitch contribution matrix"; | 235 d.description = "Estimated pitch activation matrix"; |
213 d.unit = ""; | 236 d.unit = ""; |
214 d.hasFixedBinCount = true; | 237 d.hasFixedBinCount = true; |
215 d.binCount = processingPitches; | 238 d.binCount = processingPitches; |
216 d.binNames.clear(); | 239 d.binNames.clear(); |
217 for (int i = 0; i < processingPitches; ++i) { | 240 for (int i = 0; i < processingPitches; ++i) { |
314 if (m_resampler) { | 337 if (m_resampler) { |
315 data = m_resampler->process(data.data(), data.size()); | 338 data = m_resampler->process(data.data(), data.size()); |
316 } | 339 } |
317 | 340 |
318 Grid cqout = m_cq->process(data); | 341 Grid cqout = m_cq->process(data); |
319 return transcribe(cqout); | 342 FeatureSet fs = transcribe(cqout); |
343 | |
344 for (int i = 0; i < (int)cqout.size(); ++i) { | |
345 Feature f; | |
346 for (int j = 0; j < (int)cqout[i].size(); ++j) { | |
347 f.values.push_back(float(cqout[i][j])); | |
348 } | |
349 fs[m_cqOutputNo].push_back(f); | |
350 } | |
351 | |
352 return fs; | |
320 } | 353 } |
321 | 354 |
322 Silvet::FeatureSet | 355 Silvet::FeatureSet |
323 Silvet::getRemainingFeatures() | 356 Silvet::getRemainingFeatures() |
324 { | 357 { |
325 Grid cqout = m_cq->getRemainingBlocks(); | 358 Grid cqout = m_cq->getRemainingBlocks(); |
326 return transcribe(cqout); | 359 FeatureSet fs = transcribe(cqout); |
360 | |
361 for (int i = 0; i < (int)cqout.size(); ++i) { | |
362 Feature f; | |
363 for (int j = 0; j < (int)cqout[i].size(); ++j) { | |
364 f.values.push_back(float(cqout[i][j])); | |
365 } | |
366 fs[m_cqOutputNo].push_back(f); | |
367 } | |
368 | |
369 return fs; | |
327 } | 370 } |
328 | 371 |
329 Silvet::FeatureSet | 372 Silvet::FeatureSet |
330 Silvet::transcribe(const Grid &cqout) | 373 Silvet::transcribe(const Grid &cqout) |
331 { | 374 { |
336 for (int i = 0; i < (int)filtered.size(); ++i) { | 379 for (int i = 0; i < (int)filtered.size(); ++i) { |
337 Feature f; | 380 Feature f; |
338 for (int j = 0; j < processingHeight; ++j) { | 381 for (int j = 0; j < processingHeight; ++j) { |
339 f.values.push_back(float(filtered[i][j])); | 382 f.values.push_back(float(filtered[i][j])); |
340 } | 383 } |
341 fs[m_cqOutputNo].push_back(f); | 384 fs[m_fcqOutputNo].push_back(f); |
342 } | 385 } |
343 | 386 |
344 int width = filtered.size(); | 387 int width = filtered.size(); |
345 | 388 |
346 int iterations = 12; | 389 int iterations = 12; |