# HG changeset patch # User gyorgyf # Date 1365856757 -3600 # Node ID 5295bdb588400e0b2d1a64604b57dfdecfcc0720 # Parent cb587575bc0d15c54b48172b488290dd0bc8f711 fixed flexi note layer and propagated model selection to analyser diff -r cb587575bc0d -r 5295bdb58840 transform/FeatureExtractionModelTransformer.cpp --- 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 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() || isOutput()) { + } else if (isOutput() || isOutput() || isOutput()) { //GF: Added Note Model int index = 0; @@ -724,8 +744,24 @@ duration = feature.values[index++]; } } - - if (isOutput()) { + + if (isOutput()) { // 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(); + 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()) { float velocity = 100; if (feature.values.size() > index) { @@ -741,6 +777,7 @@ velocity / 127.f, feature.label.c_str())); } else { + RegionModel *model = getConformingOutput(); if (!model) return; @@ -813,6 +850,12 @@ NoteModel *model = getConformingOutput(); if (!model) return; model->setCompletion(completion, true); + + } else if (isOutput()) { + + FlexiNoteModel *model = getConformingOutput(); + if (!model) return; + model->setCompletion(completion, true); } else if (isOutput()) { diff -r cb587575bc0d -r 5295bdb58840 transform/FeatureExtractionModelTransformer.h --- 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(); diff -r cb587575bc0d -r 5295bdb58840 transform/ModelTransformerFactory.cpp --- 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; diff -r cb587575bc0d -r 5295bdb58840 transform/ModelTransformerFactory.h --- 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 ; };