0

I need to get the information of a midi file before it is played which I can do, but I need to do this with alternative bpms of the files' bpm.

So is there a way to set the bpm of a midi file and therefore affect it's corresponding time events?

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
JavaTime
  • 15
  • 6

1 Answers1

0

You can read the MIDI file in with this library and then filter out the Tempo events and apply your own if need be. It sounds like you're interested in the real time of each event (as opposed to their MIDI tick), so you'll still have to calculate that yourself. (But I assume you were doing that already anyways, since MIDI files don't keep track of real event times.)

http://code.google.com/p/android-midi-lib/

LeffelMania
  • 12,765
  • 4
  • 32
  • 34
  • Well the problem is that I don't know the formula to work out the new timestamps based on a new tempo value. Anyone have a formula on that? – JavaTime Feb 05 '12 at 11:22
  • This link has the formula: http://stackoverflow.com/questions/2038313/midi-ticks-to-actual-playback-seconds-midi-music However, if the MIDI file has several tempo changes it becomes more difficult to calculate real times. There are several strategies for doing so, but you'll basically have to keep track of time intervals for each section of constant tempo and work backwards from the note you're interested in. Not trivial. – LeffelMania Feb 05 '12 at 21:12
  • yeah i thought it would involve a lot of work but doesn't matter at the moment, I probably won't be dealing with midi files with a lot of tempo changes at the moment. Thanks for the link, how do I find out the ppq value? – JavaTime Feb 05 '12 at 21:18
  • It's the resolution of the MIDI file. Common values are 480 and 960. – LeffelMania Feb 05 '12 at 22:39
  • Are yes found it! Thank you very much!!! Solved me the problem and a lot of head aches!!! – JavaTime Feb 05 '12 at 23:00