trigger vs. delay
I am having a problem trying to use a trigger together with [seq] that is driving me nuts. Basically, I want [seq] to first receive a (read file.MID) message and then receive a bang to start playing it. Simple enough, but I can’t make this work – it looks like the reading of the file takes longer than expected. The "solution" so far is to use a [delay 1] object before the bang, so the [seq] objects has time to properly load the file. This is horrible though, because the delay on my patch get accumulated, and soon every channel is out of sync with each other…. (after 100 short MIDI files are played, the delay will be of 100ms comparing to its initial position).
Is there any way to solve this? Below is a simple patch showing the problem. It uses 2 simple files named 1.mid and 2.mid. The idea is that 1.mid has to be played only once, after which 2.mid will be looped (until the user clicks on the stop message).
<code>-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 817.3oc6X0saaBCF85To9NXglztICg+g+1c64XZZxDbSbWvjgcZSW0d2msIz PaSHfRBvVVtHV9Cr8wGe3yG6mu8lINI4aXRGvmAeELYxy5HSrwLQlTEXhSFc yrkTo8EclkmkwDJmoaenhsQYevi4E+PNEjrVAVPk.JHksj9DH+N.LS9xqeWt PI4+hYZBD45UEWrNiKVxT1AAVKZ9ZUUXu5chflY6DmuTvoKeo+4o1f4I2+IL Y2nVLOw1C6FvUT0rEbw7uWvloJo.hmuq+T.TW3oKBwlBjtMfuYazuu8FSotX 5oSWo4Lo3iJfg1b0+FDFB2QFBFQpyP9dmAFJiIkz4r2yPRU9ptwJn8yJvtwJ nc5l8PA3vX6bmXKvVMBLxv.UMpbjUOshU1BGmSfczeNoxENcQD.22bxuo4ju W4BYLoZ8rZU8fyoDpX9oLuDrG0358K5Y7Ttdv1+5N9h90.JnINhPP1EbTfov 29A.BdRJ+CwA5Dm.3fn7CaACf7rL.NrGTIGL2.ZPnmnFomXnKxeWlAjMS4kK yvA4lgQ5D2rzAVOo4fQMELZJ3CPWcVlgfjvdsQ.gv1uyBIW3sVNT5GI6mmEy HnNRNv1j7IvtgaXaR9vM1ttf4fFL+I3lHJXvei9SfMl9.E+e+IZNpQ+IayZz G9STfD.eHRQ.IMy.vZ9Sz5e+1oRlVlp3eFaJMlGEEcU6RoE5mqcSJMdRQT.z 850hRaR.e1bnT1Nmkbw6thN6nadva3NY95hYUc9V.Cf6.PJSp3Bphq2wd2KY 16ETClK3ooLwq1fJkKoIKYVlv6vqlcBWdGEWA8Nt7aCt5eXYrFebbgFHfcTA Fxu+AlWaXr2xq8.vPwsBXdiTfYtgn9FXQiUFKZrxXgiUweqxu9VdcO.SaMZU td2SY08WaM6iQ1sd8i7cgn8TGhsN6L21cXU0Zf4bOYIi0UA73bWNTqLEP5cb AaUlQXWEsn35hVLA+JQ6K02JZMWAROHZgjwo1vhqiZzn+8Y.6AM61CBPWs5A VgbaWWBI8oktOuvTOXZYctnrd4Adzmk7AdUS7KCQKzmbQoO1x5hxi6rIJvQ+ D6.p+6O.ffH9o. -----------end_max5_patcher-----------
So anyone have any idea how to improve this situation? I also considered using [detonate], but I could not find a way of getting a bang when the midi file is finished (nor do I know if this situation would not be also present with [detonate]).
Thanks a lot!
stay away from [delay] in these situations, it can cause more trouble than helps, in the worst case scenario it can reverse the order of messages.
does a simple trigger not work?
"load filename.mid, start" style messages should work with all objects which can load files, as the whole loading process is in the queue.
i would probably write that
[t start l]
oh, now i see your patch.
there is a problem with the way you are using the finished flag.
from the reference:
bang: Out right outlet: Indicates that seq has finished playing the current sequence. (The bang is sent out immediately before the final event of the sequence is played.)
the current data is the problem, not the next file. :)
Thanks a lot for your reply. I totally overlook this detail about the bang being sent before the final event.
So would you or anyone else have any suggestions on how to solve my situation without using a delay?
Thanks a lot!
I would simply use multiple instances of [seq] and preload all midi files. Note that multiple instances of a patch can be created automatically with poly~.
Hi Broc, I will give it a try. Thanks a lot!
Hi Broc (and everyone else),
I finally had the time to give this solution a try, and although I think I understood well how [poly~] works (and also how it can take arguments via "args #1 #2 …"), I can’t find a way of using several [seq] objects when each single one of them should have a different MIDI file preloaded (the MIDI files I am using are named as numbers, as 1.mid, 2.mid, 3.mid etc.).
Could you or anyone else please point me in the right direction?
Thank you very much, I really appreciate your help.
you can use the flag, but introduce a [gate] after it, which waits for the next event output, then bangs once.
hint: to "delay and hold" and bang, just transform it into "1".
Now I’ve got it! Thanks a lot Roman!
Forums > MaxMSP