[detonate] timing question
Hi, I’m having difficulty getting [detonate] to store and/or report timing correctly. I’m including a patch below that demonstrates the problem. Basically, when I store events (using delta time in ticks), write a MIDI or text file, read the file back into [detonate], then report the events using the nth message, the timing of the reported events is different from the originally input time.
I’m assuming there is something going on with a milliseconds conversion somewhere. I’m also aware of the arguments for the read and write messages to [detonate], but I’ve tried them and just can’t get it to save the timing correctly. If someone could tell me what I am doing wrong, please let me know. Thanks!
----------begin_max5_patcher---------- 1055.3ocyX00iSiCE84hD+GrBu.RkJam37A7zJ3Ed.1UqPHjPHjahYpgTmrI Nvvh3+NWamzlYXZlzRyPpTyM1wW6iO43q8Me+92ag25hKE0dnmfdGZwhuC0r vVmolEcUrvaK+xzbdssgdoEa2JTZuksOTKtTaef+Jze2nKazH8FARUnE0HtJ CUrtVT8Egs1JQYQkVjgzxsh5knutQltAUuonIOCsVfnX7RDkAWLdRSfapD0k hTs7Kh7usaPykJQZQixNxAc0Vx0oajpK9PE3faVwH3UPm3isFRHwXBoqvn22 4kpYqTkKz1oGoq1OVnzJ9Vgcp8WURdtWOGJZzcdf66Qs7+sdPfQnqdYlsOJV +oGG5Yq6G2+dFKXVNZZeciVWn7FXpFDamiz.mY20aald0oytpc0o+Vov08dq 4pK712Y8lVrSeZcP0DcE5eE7Lqp4ku34u.8QYt.slm9YjTcy5.5sqCZIGByo JB9CoCBl.B6gYhbM2tvBXHvl945GgdXoD3hGMjtoasQBysDgMVgyjPM9S.0P VgdVNvGHcADNIsnJCwQ9O1DhBUK9uFgJUrznzTnZNDoRpQbH10dc2Mq27uc8 VRe4VP7eHNkb5bJDktleg3F3zX5PhJJ0JiBbggBRrzvgm+zid9e33T8hQMFt gFcGDTlfY20AkIj3I30dstnD11tRBKcvCJ.hbyUmNHhMeE.jnIfmbgYFSXWe 2Bk4LAENIDDOaL5Gmwe9ROISA6nzaPCFeMvsMsuuidhluzSvDQOjwPOD1bmd vSD8fGC8fm6pm3oXOLHISjIESFXHPnWvL7YYhai93BXSIyV5h9anlThuBcwu xVYB3HNbsXPFh4zSsG2k3uhM3wbhOZFJ9fLjzbh+i0bba.FsCTlzCZG2G7JS msmcf2Uv+mZt7f2ZtVKzk7J9V3dfT7dMjXl6VSdA1e1aIX627.6dvA5.Pl58 OlL4f68ctQiVhBs2.R3g7Edt2aD46FammAivSXj7ddSkqOHsntEqwi.0Pm68 rMbkanIljKslX60C6GyPWUPp96bzmNJGgt26sj9rr0Fag5PNFYbjNVGqDvwf qDW88MjPzRaXEK0l3fJoqG60Plocj11gOXy7CcM0zLJ1+fsydjbGTPu+Zq9c xbaVqW+q7YWEadv0hITWzTk1ow6T+ndKjyfIuDj7RHwmdshZZFYey1HyxDpq jo5VYVYAr5qEJ+BZWdJnCxxYLvCNC6UZ1sCuf3DSTLBbBKlYqx8ktaAdzIBb JwYh1W5tD3vVQmHgG4aO3eRvtRmIbONg7Qy2cLr6ibPCC1U5Lg6voA2cRZVe baKcVvcR3zR2ItCYzR2lRmEXGGOMv97vo34L3BlwfiMFrkbpaRPa+n4Q6KcV PMchde2FbENVQ+0P3aZMjoBv7S.r.v7J -----------end_max5_patcher-----------
First, keep in mind that delta time is given in milliseconds, not ticks.
1 quarter note (qn) at 120 BPM (default) is 500 ms.
So, 200 ms means 200/500 = 0.4 qn.
Within MIDI files the timing must be represented by ticks. I’ve looked into the generated file and found that it uses a resolution of 96 ticks per quarter note (ppqn).
So in this case, 200 ms corresponds to 96*0.4 = 38.4 ticks.
But unfortunately, MIDI files can represent ticks only as integer values.
So some rounding takes place which explains the differences you observe.
Detonate is especially problematic due to the low tick resolution.
Most programs export MIDI files at much higher resolution, eg. 480ppqn.
(For example, 480*0.4 gives 192 exactly.)
BTW, when converting the generated MIDI file to readable text, it looks like this.
NoteOn Ch1 d2 64
NoteOn Ch1 d#2 64
NoteOn Ch1 e2 64
NoteOn Ch1 d2 0
NoteOn Ch1 d#2 0
NoteOn Ch1 e2 0
Thanks broc, that’s very helpful. What about when [detonate] reads a higher tick resolution MIDI file? Does it automatically scale the resolution down?
Yes. Imported MIDI files are converted to the internal representation of [detonate] and then exported as usual, i.e. with tick resolution of 96.
I just noticed from the help file that [detonate] seems to support also millisecond-based timing of MIDI files. It conforms to the MIDI standard, but I’ve never seen such files in practice.
I’m using a Java program which was written as part of a student project back in 2000. The basic functionality is provided in the attached .jar file. It can be launched by double-click like any other application. Help files are not included but I think the usage is simple and self-explanatory.
Thanks for your help broc.
There seems to be another [detonate] timing problem. When I send it three notes with the same note-on time, save a MIDI file, and read it back into [detonate], the duration of one of the notes gets messed up, and not due to a rounding error. In the example below, I’m sending it three notes with the same note-on time, with durations of 100, 125, and 150. After writing and reading a MIDI file, the resulting durations are 99, 10, and 151. I can see that the 99 and 151 are rounding errors, but what about the 10?
----------begin_max5_patcher---------- 909.3ocyX90aSCCD.+4hDeGrLuVphc9WK7DBdgG.wCHDRHDxMwa0rD6pDW5. De2474j1pttsRRXKSZ0wm84b9Wu67496m9jIzklqk0TxKHegLYxuAISPYNIS ZELgVJtNqPTiSjlYJKkZKcZyfV40VbfnYjWWnxthXWIqkDgNmTXLWQ1tRXIq DqWK00jkxByVPjTS9oYCIqUARoJOuPRLZ4tUtPokYlMZb4CakdgQa0hRI9Ne UkRTrSAUNJzr76OOLldnB0pegJv3yBZkuVXyVozW9sJYl0yfEIAv3jn4XCKN w2aV.4qsZo2TpzERKBC1ARMarshCPo+4oOw0BMS6ObCmQpjhbDUu6su4sjKT ER5+HSh5CS3MLAabcdzYBeFYakxBtZcGIg8.IgKFcHgMirTnujXMf6RloJmn MVYMYqxthjuoRXUFHJzbAgE3Lcd7TLPE1CCSXGuG7jyiejB6Jk00hKkmfmwr ywixaD1etV52PT5dK+P5DzE5j5i7RCP53c1X2Nb3mFNrgGNZvmhOj3oS9NAH PhY9PxzQEcFRmmndPmnEwiL5vCB.WYWVHelHnGy2ykRB5w88hCFPD1oZBR7Y 4CC84nhFOLDO7a.wSRO7vZNKLLYzPGW4RCHbR6S3mOCdX7CMbzxsfseS1XI0 VyZxxlhD5Dlbq.cJg5p2v01rTmDdrNUVPRDBL9bO2BVzsxrB6L9VtwZM5aGA 3V+za3EzyXi4q2g2wxG+Ocl0Plvk2mTJM2B6g+PqaKpIWBdChNlxU4JW+es4 zPMsGASwo95GYgyhuSmt4mlp6DWK9Q6V6Yu2Yu6oC3M.++R2GO6ytOqk10hJ QI7L7toeTU5lEC6s.+CeDNvGCDB7S6zK.nE8CJX6AOy8pwSmRRvG.ml6RWXb 5mjvWRv0Z1qYzYnILe5a1TQwowZr5Fac9YX0fVzWuRn8D.V.VB1LuEC2hdwN bUIxtZmhg7yRQX4oel40xSYrcNZp2khoNE4mqhUR3XfJ4wee2bzvKAG3ihB8 da3cLO92cBcZcCbTrYsYSUVquV6oID9d+1bvHTZ7psGLKWXB4.u6Up7bINgc gIkp70FHNqwRRihbAEgLrHlj388tw1XZWM6fg2rGDiCesg2mw4t.Kg8vabIi XxkNhsswL2hFw1V3H11h++XaIKVfo6RXtl1jetdCWxO18Y1wOJD0Ur98iziS e2AiyI.Z9K.up7I6 -----------end_max5_patcher-----------
I’m able to reproduce the issue here.
The written MIDI file appears to be correct.
NoteOn Ch1 d2 100
NoteOn Ch1 d#2 100
NoteOn Ch1 e2 100
NoteOn Ch1 d2 0
NoteOn Ch1 d#2 0
NoteOn Ch1 e2 0
So there seems to be a bug with reading the file.
I’ve also noticed that reading takes ages (~ 1 minute) which is highly suspect.
Thanks for the report. There are definitely some timing issues with detonate, some of which we are aware of.
This last one regarding the duration has been fixed but I’m not entirely sure when it will be incorporated into a build.
Apologies for the inconvenience in the meantime.
Forums > MaxMSP