Sync/play MIDI and audio files

Christopher's icon

Hi Folks,

I'm working on a CD/DVD project where I have recorded, via ProTools, the audio and MIDI from a piano performance (via the Moog Piano Bar) and now want to use them both inside a MaxMSP patch. I've exported the MIDI as a separate file from PT and exported the audio as a separate file but I can not get the two to play in sync. If I start to play the MIDI and soundfile at the same time, using [sfplay~] and [seq] the MIDI files gradually gets ahead, by several seconds, of the sound file towards the end of a 7 minute piece.

Any suggestions on how to get around this?
Also, is there a way to start the playing of a MIDI from a given point into the file?

I'm amazed I couldn't find these in the archives. Perhaps I'm not searching them correctly.

Any help appreciated,

Christopher

LP's icon

One solution is to use the seq~ object (it is sync with audio and you
can start plying at a given point into the file).
The probleme is that you must convert your midifile into the seq~
format (that is very strange).

Z.

>I'm working on a CD/DVD project where I have recorded, via ProTools,
>the audio and MIDI from a piano performance (via the Moog Piano Bar)
>and now want to use them both inside a MaxMSP patch. I've exported
>the MIDI as a separate file from PT and exported the audio as a
>separate file but I can not get the two to play in sync. If I start
>to play the MIDI and soundfile at the same time, using [sfplay~] and
>[seq] the MIDI files gradually gets ahead, by several seconds, of
>the sound file towards the end of a 7 minute piece.
>
>Any suggestions on how to get around this?
>Also, is there a way to start the playing of a MIDI from a given
>point into the file?
>
>I'm amazed I couldn't find these in the archives. Perhaps I'm not
>searching them correctly.

LP's icon
dlehrich@gmail.com's icon
seejayjames's icon

You could also try to tweak the speed of the MIDI playback in seq, as 1024 is default tempo. Perhaps 1022 or 1020 or something would slow it down to be close enough to not notice the drift. (If you're into the math angle, you could figure out the right ratio by dividing the total seconds by the # of seconds of drift evident at the end...)

This is of course a workaround, but it's simple. For more detailed playback options you should look into detonate.

--CJ

BenCello's icon

Hi there !

3 years later, I have the same problem : how to play in sync a MIDI and a audio file.
Is there a better way than loading the file in a seq~ or to tweak the speed of one of them (which btw requires quite a lot of time for testing...)

Also, why are 4 replies of this thread missing ?

Cheers

seejayjames's icon

I don't think there's an "exact" way, there would need to be info on tempo and/or some markers in both files so that they match up. I would determine the ratio as precisely as possible (the total length of audio file divided by the total playback time of [seq] at speed 1024), multiply 1024. by that, then take the reciprocal (!/ 1.) to get the right speed for [seq]. You should be able to get enough precision to make it work, even for long pieces.

pdelges's icon

I just tried to control seq's speed with tick messages generated from a signal. The timing is not very precise (i.e., the speed is not perfectly constant) , but the sync is OK after 1 hour.

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

Here is the idea:

lgabiot's icon

Hello,

I might be completely wrong, but could not Live with Max for Live solve this?

pdelges's icon

No, you're probably right. I could also use ProTools, or Logic, or Digital Performer or whatever DAW. But the idea is to keep the sync in the Max environment (and I don't want to pay for M4L to get something as fundamental as sync).

jsr_'s icon

I just tried to control seq's speed with tick messages generated from a signal. The timing is not very precise (i.e., the speed is not perfectly constant) , but the sync is OK after 1 hour.

patrick, can you expand on this? why are you dividing with 20.833332? is this related to sample rate? what is the resulting tick frequency for this patch?

pdelges's icon

sfplay~'s 3rd output gives the position in ms. So I'm dividing by 1000/48 because I need 48 ticks/s to play the seq at its original tempo. It is not related to the SR.

jsr_'s icon

i see: 1000/48 = 20.833332 :)