Isn't clear with playing Midi


#1

Good day.
Could someone help me with playing MIDI?
I know that getTimeFormat() returns ticks in quarter-note. But what about seconds?
How could I play MidiMessageSequence?
I’ve read Generic information about midi devices (not about midi files).
What should I read also?
Many thanks for your attention.


#2

Maybe the convertTimestampTicksToSeconds() method is what you’re after…?

How to play a file depends on what you’re doing - to send it to a midi output, you’ll need to have a thread running that sends each note at the right time.


#3

Thanks for replying.
Yes, you right about midi output and thread.
I have a MIDI file which contain only one track. Its length is 32 seconds.
The getEndTime() returns 18829 (I don’t rembeber right numbers).
If I use the convertTimestampTicksToSeconds() it returns 188.
I can’t link 32 seconds and 18829 (188) .
Any ideas?


#4

Don’t know - probably something going wrong with the tempo information. Try playing it and see what happens.


#5

Hmm.
The algoritm is

  1. time = 0
  2. take time of first event
  3. while time < last event’s time
  4. sleep for this time
  5. send this event to out
  6. get time of next event
  7. if time is equal current time go to 5
  8. else loop

As you remember I have 188.
If I use it as milleseconds I’ll play the midi less then second.
It can’t be seconds (32 sec).
Also, I have group of events with 0 time, next group has 155 time.
Any comments?


#6

Try loading it into tracktion and see what it looks like. That uses the same class to load it.


#7

What is tracktion? I need more instructions.


#8

well googling for “tracktion”, or going to http://www.tracktion.com might be a good start!


#9