Jump to content

  • Log In with Google      Sign In   
  • Create Account


Midi timing, ticks to milliseconds


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 blutgeld   Members   -  Reputation: 122

Like
0Likes
Like

Posted 20 April 2008 - 08:55 PM

Hoping someone might be able to make me understand the way midi timing works. I've tried the usual google routine in trying to get a hang of how it works and basically the closest I got to wrapping my head around it was in this post: http://www.gamedev.net/community/forums/topic.asp?topic_id=489452 but I'm still not sure how to get to the values in the post? I'm trying to make a karaoke player for flash for a school project and time the words properly. To do this I've utilized a php class that converts the midi file into MXML or midi xml which is easy to import into flash. That file contains a number of values which I'm not entirely sure how to use to calculate a correct timing! When creating the file you can choose either absolute or delta timing, I've chosen absolute, just because I figured that would be easier for me to read. this is some of the information I can get from the XML: <TicksPerBeat>192</TicksPerBeat> .... <Event> <Absolute>0</Absolute> <TimeSignature Numerator="4" LogDenominator="2" MIDIClocksPerMetronomeClick="24" ThirtySecondsPer24Clocks="8"/> </Event> <Event> <Absolute>0</Absolute> <KeySignature Fifths="251" Mode="0"/> </Event> <Event> <Absolute>0</Absolute> <SetTempo Value="1034482"/> </Event> Now, when i check the file in a midi utility application, the number with the label TicksPerBeat is the same as resolution, only with the inclusion of the following formula (1/768), which I don't know what that means. I'm also presented with the "initial BPM", which in this song is: 58, and it changes to 56 a bit into the song. I've tried the following formula to convert Ticks to milliseconds, with no success. Resolution * BPM / Ticks * 1000 = Milliseconds If this is actually right and I'm doing something else wrong, is there a way to calculate the BPM from the number in the SetTempo node? Am I also right in thinking that the absolute label contains the amount of ticks? It looks like this with lyrics: <Event> <Absolute>2304</Absolute> <TextEvent>\How</TextEvent> </Event> <Event> <Absolute>2352</Absolute> <TextEvent> can</TextEvent> </Event> <Event> <Absolute>2400</Absolute> <TextEvent> I</TextEvent> </Event> <Event> <Absolute>2448</Absolute> <TextEvent> just</TextEvent> </Event> <Event> <Absolute>2496</Absolute> <TextEvent> let</TextEvent> </Event> Would really appreciate it if someone could help me with this, I've got no past experience in dealing with midis so this is all really confusing to me. Thanks!

Sponsor:

#2 Jaap1978   Members   -  Reputation: 252

Like
0Likes
Like

Posted 21 April 2008 - 11:48 AM

<SetTempo Value="1034482"/> = the amount of milliseconds
The formula 1/768 = 1 tick is 768 milliseconds
If you do: 1034482/768 = 1346,98 (=amount of ticks)
To get the midi tempo you have to take the following formula
1346/56(BPM)*8=192

All the answers and calculation is already in the midi programming that is included in the XML.

If you don't have the midi info extracted from the XML you can calculate the amount of milliseconds per beat as follow:

There are 1000 milliseconds in one second. 60 seconds in one minute, so 60000 milliseconds in one minute. So if you want to figure out the value of a beat at a specific BPM, the formula would be 60,000/ x. X would be your BPM, so if I wanted to know the value in milliseconds of one beat at say 56 BPM, the math would be 60000 / 56 which would be 1071 milliseconds
The total amount of milliseconds, you can only figure out if you know how many bars or beats a song has.
If you know the amount of bars and the midi tempo you can use the calculation as described in the other post.

If you know only the total length you can calculate how many milliseconds there are in the total time. I am not very familiar with XML or midi programming like this, but I hope these calculations helps a bit to get you going.

Good luck!
-----------Jaap VisserComposer/Sound DesignerJaap Visser Music Productions3 Peak Audio

#3 blutgeld   Members   -  Reputation: 122

Like
0Likes
Like

Posted 22 April 2008 - 01:34 AM

Hi!

Thank you so much for your reply, I've been hard at work trying to implement it somehow, although I think that there's still pieces of the puzzle missing for me.

For instance, the value from which you derive the amount of milliseconds:

<SetTempo Value="1034482"/>

I'm fairly certain that this is what changes the BPM. What I didn't include was this snippet that appears later in the track that says:

<Event>
<Absolute>2304</Absolute>
<SetTempo Value="1071428"/>
</Event>

And if I input the unit number 2304 into the midi calculator of the utility application GNMIDI, the returned BPM is 56, when I input 2303 the BPM is 58.

btw, is what in that program calls a unit the same thing as a tick or am I mistaken in that?

Also I can only access the 1/768 calculation from the GNMIDI app and I don't know how to get that from any of the other numbers, but if I only need the Tempo/resolution, BPM and ticks I'm fine without that I guess.

In the end this is what I want to be able to do:

In the song I'm using as an example, the first lyric is sung at approximately 12 seconds into the song, so basically I want the calculation, using the number from this snippet:

<Event>
<Absolute>2304</Absolute>
<TextEvent>\How</TextEvent>
</Event>

to somehow be:

? * 2304 = 12000

and seeing as the tempo sees a change mid-song, the ? should be able to be updated with that in consideration.

Thanks



#4 Jaap1978   Members   -  Reputation: 252

Like
0Likes
Like

Posted 22 April 2008 - 02:45 AM

yeah the "?" should be the BPM indeed. If the song changes you should have a sort of <absolute> from point A till B with BPM 58 and then an <absolute> from point B till point C with BPM 56 (as you gave as example in the first post) and then an overall <absolute>. How to manage that I have no clue haha

A unit would be indeed a tick

The absolute value is indeed the amount of ticks as it seems. Did some calcullation and that seems to be correct indeed.
-----------Jaap VisserComposer/Sound DesignerJaap Visser Music Productions3 Peak Audio

#5 blutgeld   Members   -  Reputation: 122

Like
0Likes
Like

Posted 22 April 2008 - 04:24 AM

Breakthrough time!

<SetTempo Value="1034482"/>

60 000 000 / 1034482 = 58 (BPM!)

Thanks a bunch! Now I just hope this'll work out and using the BPM this way works too!


#6 Jaap1978   Members   -  Reputation: 252

Like
0Likes
Like

Posted 22 April 2008 - 05:48 AM

Ok :) that is nice!

I hope this all is going to work for you. Keep us updated!
-----------Jaap VisserComposer/Sound DesignerJaap Visser Music Productions3 Peak Audio

#7 blutgeld   Members   -  Reputation: 122

Like
0Likes
Like

Posted 23 April 2008 - 04:41 AM

Will do!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS