Order of events in MidiList::createDefaultPlaybackMidiSequence


I’m been having trouble with a synth changing sound after the first note rather than before it. Logging the output of MidiList::createDefaultPlaybackMidiSequence, it looks like it adds the first note before the controller events (if they are at the same position).

Changing the order of the blocks so that controller events and SysEx messages are added before the notes seem to solve my problems.

Is this a bug in Tracktion Engine or is there something that I haven’t understood? (Quite likely…)


After further investigation, I’m not sure that this is the problem, or at least not the only problem.

Logging the contents of bufferForMidiMessages in applyToBuffer shows that sometimes some of the control messages are not scheduled at position 0:

*** MIDI messages in buffer *** 
  + 0  Controller Volume (coarse): 65 Channel 1
  + 0  Controller Pan position (coarse): 64 Channel 1
  + 0  Controller Volume (fine): 0 Channel 1
  + 0  Controller Pan position (fine): 0 Channel 1
  + 511  Controller Bank Select: 0 Channel 1
  + 511  Controller Bank Select (fine): 0 Channel 1
  + 511  Program change 48 Channel 1
  + 4  Note on A2 Velocity 70 Channel 1
  + 4  Note on C#3 Velocity 70 Channel 1
  + 4  Note on E3 Velocity 70 Channel 1

When these messages are sorted, obviously the first noteOn ends up before the Bank Select.

So why the offset?

It appears that createControllerUpdatesForTime is called with a time of 0.0106667. I don’t know why but that seems strange to me when I start playback from the start of the Edit!

Sorry, I’ve been on vacation for the past week, just getting caught up on things.

Are all of these messages CC events that you’ve put in the MidiList or are some of them automatically generated?

If you put a breakpoint in createControllerUpdatesForTime, can you see where the timestamp of 0.0106667 is coming from?

It’s a bit hard for me to debug this right now as I’m deep in the engine_2_0 branch which has diverged a bit from develop. I really want to get this 2.0 stuff cleaned up and pushed so everyone is looking at the same code soon.