# HG changeset patch # User Chris Cannam # Date 1386004347 0 # Node ID ae1eedd6951fcdb1424ff1c082f4ac789e371e1d # Parent e22642bcb07b848557db3f1048617b0bd53bf5b5 Use NoteExportable, now in svcore, to generate note data diff -r e22642bcb07b -r ae1eedd6951f audioio/AudioGenerator.cpp --- a/audioio/AudioGenerator.cpp Mon Dec 02 15:47:16 2013 +0000 +++ b/audioio/AudioGenerator.cpp Mon Dec 02 17:12:27 2013 +0000 @@ -25,6 +25,7 @@ #include "data/model/FlexiNoteModel.h" #include "data/model/DenseTimeValueModel.h" #include "data/model/SparseOneDimensionalModel.h" +#include "data/model/NoteData.h" #include "plugin/RealTimePluginFactory.h" #include "plugin/RealTimePluginInstance.h" @@ -551,9 +552,12 @@ size_t reqStart = startFrame + i * m_pluginBlockSize; - NoteList notes = getNotes(model, - reqStart + latency, - reqStart + latency + m_pluginBlockSize); + NoteList notes; + NoteExportable *exportable = dynamic_cast(model); + if (exportable) { + notes = exportable->getNotes(reqStart + latency, + reqStart + latency + m_pluginBlockSize); + } Vamp::RealTime blockTime = Vamp::RealTime::frame2RealTime (startFrame + i * m_pluginBlockSize, m_sourceSampleRate); @@ -653,112 +657,3 @@ return got; } - -AudioGenerator::NoteList -AudioGenerator::getNotes(Model *model, - size_t startFrame, - size_t endFrame) -{ - NoteList notes; - - SparseOneDimensionalModel *sodm = - qobject_cast(model); - - if (sodm) { - - SparseOneDimensionalModel::PointList points = - sodm->getPoints(startFrame, endFrame); - - for (SparseOneDimensionalModel::PointList::iterator pli = - points.begin(); pli != points.end(); ++pli) { - - notes.push_back - (NoteData(pli->frame, - m_sourceSampleRate / 6, // arbitrary short duration - 64, // default pitch - 100)); // default velocity - } - - return notes; - } - - NoteModel *nm = qobject_cast(model); - - if (nm) { - - NoteModel::PointList points = - nm->getPoints(startFrame, endFrame); - - for (NoteModel::PointList::iterator pli = - points.begin(); pli != points.end(); ++pli) { - - size_t duration = pli->duration; - if (duration == 0 || duration == 1) { - duration = m_sourceSampleRate / 20; - } - - int pitch = lrintf(pli->value); - - int velocity = 100; - if (pli->level > 0.f && pli->level <= 1.f) { - velocity = lrintf(pli->level * 127); - } - - NoteData note(pli->frame, - duration, - pitch, - velocity); - - if (nm->getScaleUnits() == "Hz") { - note.frequency = pli->value; - note.isMidiPitchQuantized = false; - } - - notes.push_back(note); - } - - return notes; - } - - FlexiNoteModel *fnm = qobject_cast(model); - - if (fnm) { - - // currently identical to NoteModel case above - - FlexiNoteModel::PointList points = - fnm->getPoints(startFrame, endFrame); - - for (FlexiNoteModel::PointList::iterator pli = - points.begin(); pli != points.end(); ++pli) { - - size_t duration = pli->duration; - if (duration == 0 || duration == 1) { - duration = m_sourceSampleRate / 20; - } - - int pitch = lrintf(pli->value); - - int velocity = 100; - if (pli->level > 0.f && pli->level <= 1.f) { - velocity = lrintf(pli->level * 127); - } - - NoteData note(pli->frame, - duration, - pitch, - velocity); - - if (fnm->getScaleUnits() == "Hz") { - note.frequency = pli->value; - note.isMidiPitchQuantized = false; - } - - notes.push_back(note); - } - - return notes; - } - - return notes; -} diff -r e22642bcb07b -r ae1eedd6951f audioio/AudioGenerator.h --- a/audioio/AudioGenerator.h Mon Dec 02 15:47:16 2013 +0000 +++ b/audioio/AudioGenerator.h Mon Dec 02 17:12:27 2013 +0000 @@ -103,22 +103,6 @@ bool m_soloing; std::set m_soloModelSet; - struct NoteData { - - NoteData(size_t _start, size_t _dur, int _mp, int _vel) : - start(_start), duration(_dur), midiPitch(_mp), frequency(0), - isMidiPitchQuantized(true), velocity(_vel) { }; - - size_t start; // audio sample frame - size_t duration; // in audio sample frames - int midiPitch; // 0-127 - int frequency; // Hz, to be used if isMidiPitchQuantized false - bool isMidiPitchQuantized; - int velocity; // MIDI-style 0-127 - }; - - typedef std::vector NoteList; - struct NoteOff { NoteOff(int _p, size_t _f) : pitch(_p), frame(_f) { } @@ -156,8 +140,6 @@ (Model *model, size_t startFrame, size_t frameCount, float **buffer, float gain, float pan, size_t fadeIn, size_t fadeOut); - NoteList getNotes(Model *model, size_t startFrame, size_t endFrame); - static const size_t m_pluginBlockSize; };