Mercurial > hg > silvet
comparison src/Silvet.cpp @ 162:03ba9b25e0d0
Add solo instrument parameter
author | Chris Cannam |
---|---|
date | Tue, 20 May 2014 15:37:03 +0100 |
parents | 6003a9af43af |
children | 6e9ddd07dc3c |
comparison
equal
deleted
inserted
replaced
161:6003a9af43af | 162:03ba9b25e0d0 |
---|---|
39 Silvet::Silvet(float inputSampleRate) : | 39 Silvet::Silvet(float inputSampleRate) : |
40 Plugin(inputSampleRate), | 40 Plugin(inputSampleRate), |
41 m_instruments(InstrumentPack::listInstrumentPacks()), | 41 m_instruments(InstrumentPack::listInstrumentPacks()), |
42 m_resampler(0), | 42 m_resampler(0), |
43 m_cq(0), | 43 m_cq(0), |
44 m_hqMode(true) | 44 m_hqMode(true), |
45 m_instrument(0) | |
45 { | 46 { |
46 } | 47 } |
47 | 48 |
48 Silvet::~Silvet() | 49 Silvet::~Silvet() |
49 { | 50 { |
144 desc.valueNames.push_back("Draft: faster"); | 145 desc.valueNames.push_back("Draft: faster"); |
145 desc.valueNames.push_back("Intensive: usually higher quality"); | 146 desc.valueNames.push_back("Intensive: usually higher quality"); |
146 list.push_back(desc); | 147 list.push_back(desc); |
147 | 148 |
148 desc.identifier = "soloinstrument"; | 149 desc.identifier = "soloinstrument"; |
149 desc.name = "The recording contains"; | 150 desc.name = "Instrument in recording"; |
150 desc.unit = ""; | 151 desc.unit = ""; |
151 desc.description = "Determines the tradeoff of processing speed against transcription quality"; | 152 desc.description = "The instrument known to be present in the recording, if there is only one"; |
152 desc.minValue = 0; | 153 desc.minValue = 0; |
153 desc.maxValue = 1; | 154 desc.maxValue = m_instruments.size()-1; |
154 desc.defaultValue = 1; | 155 desc.defaultValue = 0; |
155 desc.isQuantized = true; | 156 desc.isQuantized = true; |
156 desc.quantizeStep = 1; | 157 desc.quantizeStep = 1; |
157 desc.valueNames.clear(); | 158 desc.valueNames.clear(); |
158 desc.valueNames.push_back("Multiple or unknown instruments"); | 159 for (int i = 0; i < int(m_instruments.size()); ++i) { |
160 desc.valueNames.push_back(m_instruments[i].name); | |
161 } | |
159 | 162 |
160 list.push_back(desc); | 163 list.push_back(desc); |
161 | 164 |
162 return list; | 165 return list; |
163 } | 166 } |
165 float | 168 float |
166 Silvet::getParameter(string identifier) const | 169 Silvet::getParameter(string identifier) const |
167 { | 170 { |
168 if (identifier == "mode") { | 171 if (identifier == "mode") { |
169 return m_hqMode ? 1.f : 0.f; | 172 return m_hqMode ? 1.f : 0.f; |
173 } else if (identifier == "soloinstrument") { | |
174 return m_instrument; | |
170 } | 175 } |
171 return 0; | 176 return 0; |
172 } | 177 } |
173 | 178 |
174 void | 179 void |
175 Silvet::setParameter(string identifier, float value) | 180 Silvet::setParameter(string identifier, float value) |
176 { | 181 { |
177 if (identifier == "mode") { | 182 if (identifier == "mode") { |
178 m_hqMode = (value > 0.5); | 183 m_hqMode = (value > 0.5); |
184 } else if (identifier == "soloinstrument") { | |
185 m_instrument = lrintf(value); | |
179 } | 186 } |
180 } | 187 } |
181 | 188 |
182 Silvet::ProgramList | 189 Silvet::ProgramList |
183 Silvet::getPrograms() const | 190 Silvet::getPrograms() const |
203 OutputList list; | 210 OutputList list; |
204 | 211 |
205 OutputDescriptor d; | 212 OutputDescriptor d; |
206 d.identifier = "notes"; | 213 d.identifier = "notes"; |
207 d.name = "Note transcription"; | 214 d.name = "Note transcription"; |
208 d.description = "Overall note transcription across all instruments"; | 215 d.description = "Overall note transcription across selected instruments"; |
209 d.unit = "Hz"; | 216 d.unit = "Hz"; |
210 d.hasFixedBinCount = true; | 217 d.hasFixedBinCount = true; |
211 d.binCount = 2; | 218 d.binCount = 2; |
212 d.binNames.push_back("Frequency"); | 219 d.binNames.push_back("Frequency"); |
213 d.binNames.push_back("Velocity"); | 220 d.binNames.push_back("Velocity"); |
359 | 366 |
360 // cerr << "sum: " << sum << endl; | 367 // cerr << "sum: " << sum << endl; |
361 | 368 |
362 if (sum < 1e-5) continue; | 369 if (sum < 1e-5) continue; |
363 | 370 |
364 EM em(&m_instruments[0], m_hqMode); | 371 EM em(&m_instruments[m_instrument], m_hqMode); |
365 | 372 |
366 for (int j = 0; j < iterations; ++j) { | 373 for (int j = 0; j < iterations; ++j) { |
367 em.iterate(filtered.at(i).data()); | 374 em.iterate(filtered.at(i).data()); |
368 } | 375 } |
369 | 376 |