Strange midiclip behaviour

I’m attempting to playback a midi sequence with the engine and as far as I understand the requirement goes as follows: Track->Clip->Sequence(MidiList)

So I add a clip to the first track:

const te::EditTimeRange editTimeRange(0, rp.edit->tempoSequence.barsBeatsToTime({ 1, 0.0 }));
track->insertNewClip(te::TrackItem::Type::midi, name, editTimeRange, nullptr);

I create a MidiMessageSequence using a midi editor component.

Each time a note is changed I do this just for testing:

if (auto midiClip = dynamic_cast<te::MidiClip*> (track->getClips()[0]))
	if (auto seq = &midiClip->getSequence())
			seq->importMidiSequence(ms, edit.get(), 0.0, nullptr);													

The clip seems to only update before I start the transport. After I hit play and move some notes around, the clip still plays the original notes that were entered before playback was started. However, the MidiList correctly reflects the changes made in the midi editor!

Is it not possible to reuse a MidiClip this way? I hope this makes sense.

So jumping head first down the rabbit hole…do I really need to freePlaybackContext() and ensureContextAllocated() each time I make a sequence edit?

Edit: That’s ridiculous. But I see that the MidiAudioNode is created when the playback context is allocated. And the MidiMessageSequence is initialized with a move constructor? :confused:

Ok- Thou shall not create an additional TransportControl. The edit has already created one!
Problem solved!

Yes, you should only ever use the TransportControl you get from the Edit otherwise you’ll be creating multiple EditPlaybackContexts for the Edit which isn’t good…