Welcome to the Music and Sound forum on GD.net. Pull up a chair, listen to some tracks by your peers and discuss all things music and sound. We're happy to have you. Please check out the FAQ link for some basic (and mostly common sense) approaches used in this forum. If you have any questions, feel free to PM me.
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:
<TimeSignature Numerator="4" LogDenominator="2" MIDIClocksPerMetronomeClick="24" ThirtySecondsPer24Clocks="8"/>
<KeySignature Fifths="251" Mode="0"/>
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:
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.
<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.
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:
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.