so it work like that :
for every midi channel, a poly patch handle incoming notes, with a call to the root patch (gtab object), the note is computed.
in gtab object (edit and go to localdata) , the processNote function store the transition : for a pair of notes n-2, n-1, the current note is stored.
Later, if a note transformation is required, the function return a note randomly chosen in the relative transition stored (if any).
For only a 16 step loop, it may not give good results as it's unlikely that a least two different transitions will be found.
It will work better with more notes (longer sequence or more than one channel).
Anyway, here is a better version of the patch, that handle chords in a better way : only one note of a chord may be changed, that give better musical results ( the transformations are triggered only once in a time slot of 40 ms).
markov14.axp (170.4 KB)