Convert MidiEvent.AbsoluteTime to milliseconds

Dec 8, 2010 at 12:05 PM

Hello.

I need to conver midi to my own format.

How can i convert MidiEvent.AbsoluteTime to milliseconds?

Coordinator
Dec 10, 2010 at 1:51 PM

you need to work it out based on the tempo and the delta ticks per quarter note. I can't remember the formula off-hand, but you should be able to find one on google

Mark

Jan 19, 2011 at 7:24 AM
markheath wrote:

you need to work it out based on the tempo and the delta ticks per quarter note. I can't remember the formula off-hand, but you should be able to find one on google

Mark

Hello Mark,
first off all let me say, your naudio library is great.
I try to use it, for my own programmed Database in C# to analyize midi-File collections. I made some changes, like Yamaha XG Sysex a.s.o, but I didn't find the solution to calculate the length of a midifile.
I tried to compare the length-value from mci-api, absoluteTime, Tempo and deltaTicksPerQuarterNote (from class MidiFile) but it seems that here is no relation.

Please, could you post how the midifile length (in ms) can be calculated?

Thanks of all midibase:)

Apr 30, 2011 at 6:02 PM
Edited Apr 30, 2011 at 6:04 PM

I used this method to calculate how many micro second for a quater note within a precise BPM. So maybe it will help.


/// Méthod to calculate how many micro second for each quater note at a precise BPM.

public static int Calculator_micro_second_4th_for_bpm(double bpm)
{
  //one micro second = 0,000001 second
  //So, multiplication by 1000000 (1 million)
  const int microsecond= 1000000;
  int answer = 0;
  double temp=60;
  temp = temp / ((double)bpm);
  temp = temp * microsecond;
  answer = (int)temp;
  return answer;
}