bwall
May 29, 2021, 8:03pm
1
I was expecting to find a similar mechanism for editing midi controller events as for automation curves. But I am only finding—
te::MidiList& midiList{ midiClip->getSequence() };
midiList.getControllerEvents();
midiList.addControllerEvent(0.0, 64, 0, &undoManager);
midiList.getControllerEvent(0);
midiList.setControllerValueAt(64, 0.0, 0, &undoManager);
// etc.
This seems tedious, and we need a function like automationCurve.movePoint(selectedPoint, mouseTime, mouseValue, false);
.
I feel like I am not fiinding the right approach here. What is the correct way to access controller events for editing?
You can use SelectedMidiEvents::moveControllerData
. It’s actually designed for moving controller data along with notes. Example:
for (int i = 0; i < numSelectedNotes; ++i)
{
auto op = originalPositions.getUnchecked (i);
jassert (op != nullptr);
auto note = selected.getUnchecked (i);
note->setStartAndLength (op->start + deltaBeats, op->length, undoManager);
note->setNoteNumber (shiftNote (op->noteNumber, deltaRow), undoManager);
startTime = std::min (startTime, selectedClips[i]->getTimeOfContentBeat (op->start));
endTime = std::max (endTime, selectedClips[i]->getTimeOfContentBeat (op->start + op->length));
}
SelectedMidiEvents::moveControllerData (uniqueSelectedClips, nullptr, deltaBeats, startTime, endTime, originalNoteDragBehaviour == Copying);
bwall
May 30, 2021, 4:09pm
3
My use case is for specifically editing the controller events, like the sustain pedal (64) data, for example. For this I do not need to move the notes. I will investigate to see if this works for that.