Order of events in MidiList::createDefaultPlaybackMidiSequence

Hi,

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…)

Erik

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!