Mercurial > hg > svapp
changeset 299:ae1eedd6951f tonioni
Use NoteExportable, now in svcore, to generate note data
author | Chris Cannam |
---|---|
date | Mon, 02 Dec 2013 17:12:27 +0000 |
parents | e22642bcb07b |
children | 055ff09f7a08 |
files | audioio/AudioGenerator.cpp audioio/AudioGenerator.h |
diffstat | 2 files changed, 7 insertions(+), 130 deletions(-) [+] |
line wrap: on
line diff
--- 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<NoteExportable *>(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<SparseOneDimensionalModel *>(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<NoteModel *>(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<FlexiNoteModel *>(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; -}
--- 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<Model *> 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<NoteData> 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; };