jump in time during midi playback

robin tournemenne's icon

Hello all,

I am desperately trying to implement a +5sec and -5sec during midi playback.

I know I can do +5sec using the (ticks) of [seq] object, but I don't think there is anything to go back in time... Meaning I cannot create a -5sec feature...

I've looked also extensively into the detonate object... unfruitfully.

One terrible Idea would be to get the tick number requested from start to the current time - 5sec and replay the midi file atrociously fast to that specific position (I could mute the operation maybe).

Some help would be welcome!

Source Audio's icon

there is no real midi playback in max.
All available objects are not capable of simplest
playback functions, like to start from bar 10 or
loop from - to.
Just dumb play from beginning , only tempo can be set.
It would be easier to run sequencer in the background
and control it from max using beat clock and song position pointer.
Another option is to convert midi to text, ms based timing and
import it into coll.

Roman Thilenius's icon


like so...

open with detonate
read out everything using uzi 1000000
accumulate all delta times to relative time
but leave delta time in, too
write the result to coll or text

...now you have almost the same than before, but you can jump to a certain position in the timeline.

(as for coll, you would write the accumulated time values as index - then followed by the "normal" midi data - it could not be easier)

broc's icon

Here is a patch using [detonate] for setting the start time within a midi file (just skipping all earlier notes). I think it could be expanded for your needs by calculating a new start time at each jump.

Max Patch
Copy patch and select New From Clipboard in Max.


robin tournemenne's icon

Woaw thanks all for your thoughts, very nice! I took a path similar to what @romanthilenius suggested memorizing positions but I only used the [seq] object. I may look into @broc solution which seems also very nice to me.

I made the following patch which does what I want using seq and the tick system. My computer is quite capable and I have no problem running it (some cracks on some files while jumping in it but nothing major). I am wondering if it could create difficulty to other users because of the uzi object?

Max Patch
Copy patch and select New From Clipboard in Max.

robin tournemenne's icon

(I made a presentation mode for the sake of simplicity)

Roman Thilenius's icon


brocs idea to calculate the time when needed and skip the objects before the time is reached is not the worst idea. then one can keep using detonate. should work with end point and looping, too.

"my" uzi would only be used once when reading the midi file.

the midifile in brocs search and ignore method can be stopped by the "break" message (and then must be reset to some number), after the given time is reached.

so no problem i think.

Source Audio's icon

I digged out this old patch I tried some years ago and pimped it up a bit.

Max Patch
Copy patch and select New From Clipboard in Max.

It reads midi file, exports it as text and dumps
into coll, merging time indexes for ms based playback.
Speed adjustable and playback offset as well.