|
How to determine the duration of a Midi audio file |
|
|
This Java tip illustrates a method of determining the duration of a Midi audio file.
Developer may use this in gaming applications where there is a need for
playing different audios. Further this may also be used in your own media player. Here
in this tip a sequencer fires a meta message event when a midi file has finished playing.
// From file
Sequence sequence = MidiSystem.getSequence(new File("midiaudiofile"));
// From URL
sequence = MidiSystem.getSequence(new URL("http://hostname/midiaudiofile"));
// Create a sequencer for the sequence
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(sequence);
double durationInSecs = sequencer.getMicrosecondLength() / 1000000.0;
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.