Mercurial > hg > svcore
changeset 786:5295bdb58840 tonioni
fixed flexi note layer and propagated model selection to analyser
author | gyorgyf |
---|---|
date | Sat, 13 Apr 2013 13:39:17 +0100 |
parents | cb587575bc0d |
children | 4faea021b5c1 |
files | transform/FeatureExtractionModelTransformer.cpp transform/FeatureExtractionModelTransformer.h transform/ModelTransformerFactory.cpp transform/ModelTransformerFactory.h |
diffstat | 4 files changed, 75 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Tue Mar 26 20:15:04 2013 +0000 +++ b/transform/FeatureExtractionModelTransformer.cpp Sat Apr 13 13:39:17 2013 +0100 @@ -27,6 +27,7 @@ #include "data/model/EditableDenseThreeDimensionalModel.h" #include "data/model/DenseTimeValueModel.h" #include "data/model/NoteModel.h" +#include "data/model/FlexiNoteModel.h" #include "data/model/RegionModel.h" #include "data/model/FFTModel.h" #include "data/model/WaveFileModel.h" @@ -37,11 +38,13 @@ #include <iostream> FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, - const Transform &transform) : + const Transform &transform, + const PreferredOutputModel outputmodel) : ModelTransformer(in, transform), m_plugin(0), m_descriptor(0), - m_outputFeatureNo(0) + m_outputFeatureNo(0), + m_preferredOutputModel(outputmodel) { // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; @@ -286,15 +289,32 @@ // problem of determining whether to use that here (if bin // count > 1). But we don't. - if (isNoteModel) { + if (isNoteModel && m_preferredOutputModel == NoteOutputModel) { NoteModel *model; + // FlexiNoteModel *model; if (haveExtents) { - model = new NoteModel - (modelRate, modelResolution, minValue, maxValue, false); + // GF: hard coding FlexiNoteModel + model = new NoteModel (modelRate, modelResolution, minValue, maxValue, false); + // model = new FlexiNoteModel (modelRate, modelResolution, minValue, maxValue, false); } else { - model = new NoteModel - (modelRate, modelResolution, false); + model = new NoteModel (modelRate, modelResolution, false); + // model = new FlexiNoteModel (modelRate, modelResolution, false); + } + model->setScaleUnits(m_descriptor->unit.c_str()); + m_output = model; + + } else if (isNoteModel && m_preferredOutputModel == FlexiNoteOutputModel) { + + // NoteModel *model; + FlexiNoteModel *model; + if (haveExtents) { + // GF: hard coding FlexiNoteModel + // model = new NoteModel (modelRate, modelResolution, minValue, maxValue, false); + model = new FlexiNoteModel (modelRate, modelResolution, minValue, maxValue, false); + } else { + // model = new NoteModel (modelRate, modelResolution, false); + model = new FlexiNoteModel (modelRate, modelResolution, false); } model->setScaleUnits(m_descriptor->unit.c_str()); m_output = model; @@ -707,7 +727,7 @@ model->addPoint(SparseTimeValueModel::Point(frame, value, label)); } - } else if (isOutput<NoteModel>() || isOutput<RegionModel>()) { + } else if (isOutput<FlexiNoteModel>() || isOutput<NoteModel>() || isOutput<RegionModel>()) { //GF: Added Note Model int index = 0; @@ -724,8 +744,24 @@ duration = feature.values[index++]; } } - - if (isOutput<NoteModel>()) { + + if (isOutput<FlexiNoteModel>()) { // GF: added for flexi note model + + float velocity = 100; + if (feature.values.size() > index) { + velocity = feature.values[index++]; + } + if (velocity < 0) velocity = 127; + if (velocity > 127) velocity = 127; + + FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>(); + if (!model) return; + model->addPoint(FlexiNoteModel::Point(frame, value, // value is pitch + lrintf(duration), + velocity / 127.f, + feature.label.c_str())); + // GF: end -- added for flexi note model + } else if (isOutput<NoteModel>()) { float velocity = 100; if (feature.values.size() > index) { @@ -741,6 +777,7 @@ velocity / 127.f, feature.label.c_str())); } else { + RegionModel *model = getConformingOutput<RegionModel>(); if (!model) return; @@ -813,6 +850,12 @@ NoteModel *model = getConformingOutput<NoteModel>(); if (!model) return; model->setCompletion(completion, true); + + } else if (isOutput<FlexiNoteModel>()) { + + FlexiNoteModel *model = getConformingOutput<FlexiNoteModel>(); + if (!model) return; + model->setCompletion(completion, true); } else if (isOutput<RegionModel>()) {
--- a/transform/FeatureExtractionModelTransformer.h Tue Mar 26 20:15:04 2013 +0000 +++ b/transform/FeatureExtractionModelTransformer.h Sat Apr 13 13:39:17 2013 +0100 @@ -31,8 +31,16 @@ Q_OBJECT public: + enum PreferredOutputModel { + NoteOutputModel, + FlexiNoteOutputModel, + UndefinedOutputModel = 255 + }; + FeatureExtractionModelTransformer(Input input, - const Transform &transform); + const Transform &transform, + const PreferredOutputModel outputmodel); + virtual ~FeatureExtractionModelTransformer(); protected: @@ -41,6 +49,7 @@ Vamp::Plugin *m_plugin; Vamp::Plugin::OutputDescriptor *m_descriptor; int m_outputFeatureNo; + PreferredOutputModel m_preferredOutputModel; void createOutputModel();
--- a/transform/ModelTransformerFactory.cpp Tue Mar 26 20:15:04 2013 +0000 +++ b/transform/ModelTransformerFactory.cpp Sat Apr 13 13:39:17 2013 +0100 @@ -173,7 +173,8 @@ if (FeatureExtractionPluginFactory::instanceFor(id)) { transformer = - new FeatureExtractionModelTransformer(input, transform); + // new FeatureExtractionModelTransformer(input, transform, FeatureExtractionModelTransformer::NoteOutputModel); + new FeatureExtractionModelTransformer(input, transform, m_preferredOutputModel); } else if (RealTimePluginFactory::instanceFor(id)) { @@ -193,10 +194,13 @@ Model * ModelTransformerFactory::transform(const Transform &transform, const ModelTransformer::Input &input, - QString &message) + QString &message, + // outputmodel default value = FeatureExtractionModelTransformer::NoteOutputModel + FeatureExtractionModelTransformer::PreferredOutputModel outputmodel) { SVDEBUG << "ModelTransformerFactory::transform: Constructing transformer with input model " << input.getModel() << endl; + m_preferredOutputModel = outputmodel; ModelTransformer *t = createTransformer(transform, input); if (!t) return 0;
--- a/transform/ModelTransformerFactory.h Tue Mar 26 20:15:04 2013 +0000 +++ b/transform/ModelTransformerFactory.h Sat Apr 13 13:39:17 2013 +0100 @@ -18,6 +18,7 @@ #include "Transform.h" #include "TransformDescription.h" +#include "FeatureExtractionModelTransformer.h" #include "ModelTransformer.h" @@ -83,9 +84,10 @@ * The returned model is owned by the caller and must be deleted * when no longer needed. */ - Model *transform(const Transform &transform, - const ModelTransformer::Input &input, - QString &message); + Model *transform(const Transform &transform, + const ModelTransformer::Input &input, + QString &message, + const FeatureExtractionModelTransformer::PreferredOutputModel outputmodel = FeatureExtractionModelTransformer::NoteOutputModel); protected slots: void transformerFinished(); @@ -103,6 +105,7 @@ TransformerSet m_runningTransformers; static ModelTransformerFactory *m_instance; + FeatureExtractionModelTransformer::PreferredOutputModel m_preferredOutputModel ; };