Mercurial > hg > qm-vamp-plugins
comparison plugins/SegmenterPlugin.cpp @ 49:fc88b465548a
* Normalise type option for chromagram
* Minimum segment duration option for segmenter
* Bit more documentation
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 22 Jan 2008 17:27:48 +0000 |
parents | 5d7ce1d87301 |
children | df7a0bc46592 |
comparison
equal
deleted
inserted
replaced
48:3b4572153ce3 | 49:fc88b465548a |
---|---|
22 | 22 |
23 SegmenterPlugin::SegmenterPlugin(float inputSampleRate) : | 23 SegmenterPlugin::SegmenterPlugin(float inputSampleRate) : |
24 Plugin(inputSampleRate), | 24 Plugin(inputSampleRate), |
25 segmenter(0), | 25 segmenter(0), |
26 nSegmentTypes(10), | 26 nSegmentTypes(10), |
27 neighbourhoodLimit(4), | |
27 featureType(feature_types(1)) | 28 featureType(feature_types(1)) |
28 { | 29 { |
29 | 30 |
30 } | 31 } |
31 | 32 |
141 desc2.valueNames.push_back("Hybrid (Constant-Q)"); | 142 desc2.valueNames.push_back("Hybrid (Constant-Q)"); |
142 desc2.valueNames.push_back("Chromatic (Chroma)"); | 143 desc2.valueNames.push_back("Chromatic (Chroma)"); |
143 desc2.valueNames.push_back("Timbral (MFCC)"); | 144 desc2.valueNames.push_back("Timbral (MFCC)"); |
144 list.push_back(desc2); | 145 list.push_back(desc2); |
145 | 146 |
147 ParameterDescriptor desc3; | |
148 desc3.identifier = "neighbourhoodLimit"; | |
149 desc3.name = "Minimum segment duration"; | |
150 desc3.description = "Approximate expected minimum duration for each segment"; | |
151 desc3.unit = "s"; | |
152 desc3.minValue = 1; | |
153 desc3.maxValue = 15; | |
154 desc3.defaultValue = 4; | |
155 desc3.isQuantized = true; | |
156 desc3.quantizeStep = 0.2; | |
157 list.push_back(desc3); | |
158 | |
146 return list; | 159 return list; |
147 } | 160 } |
148 | 161 |
149 float | 162 float |
150 SegmenterPlugin::getParameter(std::string param) const | 163 SegmenterPlugin::getParameter(std::string param) const |
153 return nSegmentTypes; | 166 return nSegmentTypes; |
154 } | 167 } |
155 | 168 |
156 if (param == "featureType") { | 169 if (param == "featureType") { |
157 return featureType; | 170 return featureType; |
171 } | |
172 | |
173 if (param == "neighbourhoodLimit") { | |
174 return neighbourhoodLimit; | |
158 } | 175 } |
159 | 176 |
160 std::cerr << "WARNING: SegmenterPlugin::getParameter: unknown parameter \"" | 177 std::cerr << "WARNING: SegmenterPlugin::getParameter: unknown parameter \"" |
161 << param << "\"" << std::endl; | 178 << param << "\"" << std::endl; |
162 return 0.0; | 179 return 0.0; |
166 SegmenterPlugin::setParameter(std::string param, float value) | 183 SegmenterPlugin::setParameter(std::string param, float value) |
167 { | 184 { |
168 if (param == "nSegmentTypes") { | 185 if (param == "nSegmentTypes") { |
169 | 186 |
170 nSegmentTypes = int(value + 0.0001); | 187 nSegmentTypes = int(value + 0.0001); |
171 | 188 return; |
172 } else { | 189 } |
173 | 190 |
174 if (param == "featureType") { | 191 if (param == "featureType") { |
175 if (featureType != feature_types(value)) // feature type changed, create a new segmenter | 192 if (featureType != feature_types(value)) // feature type changed, create a new segmenter |
176 { | 193 { |
177 featureType = feature_types(value); | 194 featureType = feature_types(value); |
178 makeSegmenter(); | 195 makeSegmenter(); |
179 } | |
180 } | 196 } |
181 else | 197 return; |
182 { | 198 } |
183 std::cerr << "WARNING: SegmenterPlugin::setParameter: unknown parameter \"" | 199 |
184 << param << "\"" << std::endl; | 200 if (param == "neighbourhoodLimit") { |
201 if (neighbourhoodLimit != value) { | |
202 neighbourhoodLimit = value; | |
203 makeSegmenter(); | |
185 } | 204 } |
186 } | 205 return; |
206 } | |
207 | |
208 std::cerr << "WARNING: SegmenterPlugin::setParameter: unknown parameter \"" | |
209 << param << "\"" << std::endl; | |
187 } | 210 } |
188 | 211 |
189 void | 212 void |
190 SegmenterPlugin::makeSegmenter() const | 213 SegmenterPlugin::makeSegmenter() const |
191 { | 214 { |
193 params.featureType = (feature_types) featureType; | 216 params.featureType = (feature_types) featureType; |
194 | 217 |
195 if (params.featureType == FEATURE_TYPE_CONSTQ) | 218 if (params.featureType == FEATURE_TYPE_CONSTQ) |
196 { | 219 { |
197 params.ncomponents = 20; | 220 params.ncomponents = 20; |
198 params.neighbourhoodLimit = 30; | |
199 } | 221 } |
200 if (params.featureType == FEATURE_TYPE_CHROMA) | 222 if (params.featureType == FEATURE_TYPE_CHROMA) |
201 { | 223 { |
202 params.hopSize = 0.1; | 224 params.hopSize = 0.1; |
203 params.windowSize = 0.372; | 225 params.windowSize = 0.372; |
204 params.nbins = 12; | 226 params.nbins = 12; |
205 params.histogramLength = 20; | 227 params.histogramLength = 20; |
206 params.neighbourhoodLimit = 40; | |
207 } | 228 } |
208 if (params.featureType == FEATURE_TYPE_MFCC) | 229 if (params.featureType == FEATURE_TYPE_MFCC) |
209 { | 230 { |
210 params.ncomponents = 20; | 231 params.ncomponents = 20; |
211 params.neighbourhoodLimit = 30; | |
212 } | 232 } |
213 delete segmenter; | 233 delete segmenter; |
234 | |
235 params.neighbourhoodLimit = | |
236 int(neighbourhoodLimit / params.hopSize + 0.0001); | |
214 | 237 |
215 segmenter = new ClusterMeltSegmenter(params); | 238 segmenter = new ClusterMeltSegmenter(params); |
216 segmenter->initialise(m_inputSampleRate); | 239 segmenter->initialise(m_inputSampleRate); |
217 hopsize = segmenter->getHopsize(); | 240 hopsize = segmenter->getHopsize(); |
218 windowsize = segmenter->getWindowsize(); | 241 windowsize = segmenter->getWindowsize(); |