How can I extrack the Tempo from a Track chunk? #201
-
I'm creating a rhythm game for Unity, and I'd like to extract some information from the MidiEvents that have been triggered. If I loop through the track chunks in the midi file, I can find the midiEvents that are being triggered. The thing is, I actually find the SetTempo event, and if I print it with ToString() method, the following thing get in the output:
Question is: how do I get this number? Isn't there any function like GetTempo to extract it from the chunk? Or is there a way to loop through the midi events to extract the data? There is actually no pointer in the documentation to know how to extract the information from the TempoMap. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
First of all, with var tempoMap = midiFile.GetTempoMap(); you can get tempo map - an object containing information about all tempo and time signature changes (please read the article in the documentation - https://melanchall.github.io/drywetmidi/articles/high-level-managing/Tempo-map.html). Then you can get tempo at any point in the time: var startTempo = tempoMap.GetTempoAtTime((MidiTimeSpan)0); or you can get all tempo changes: var tempoChanges = tempoMap.GetTempoChanges(); |
Beta Was this translation helpful? Give feedback.
First of all, with
you can get tempo map - an object containing information about all tempo and time signature changes (please read the article in the documentation - https://melanchall.github.io/drywetmidi/articles/high-level-managing/Tempo-map.html).
Then you can get tempo at any point in the time:
or you can get all tempo changes: