Is there a way to prevent Midi files resetting their tempo on repeat; as this doesn't happen to the volume.
So far I tried listening for meta messages like the END_OF_TRACK message (0x2f) but it only gets sent whenever the track finishes looping instead of in-between looping too.
My SimpleMidiPlayer.java play() method
public void play(SimpleMidi midi) throws InvalidMidiDataException{
sequencer.setSequence(midi.getMidiSequence());
sequencer.setLoopCount(midi.getLoopAmount());
this.setVolume(midi.getVolume());
if(midi.tempoSet){
if(midi.tempoBPM != 0){
this.setTempoBPM(midi.tempoBPM);
}else if(midi.tempoFactor != 0){
this.setTempoFactor(midi.tempoFactor);
}else if(midi.tempoMPQ != 0){
this.setTempoMPQ(midi.tempoMPQ);
}else{
this.setTempoBPM(0);
}
}
sequencer.start();
state = SimpleMidiPlayer.PLAY;
}
Here is how I tried to listen for the end of the track http://ift.tt/1rLRhma
protected void setupMeta(){
sequencer.addMetaEventListener(new MetaEventListener(){
@Override
public void meta(MetaMessage e) {
if(e.getType() == 0x2f){ //TODO Find when the track loops again to reset the tempo
System.out.println("END");
}
}
});
}
Aucun commentaire:
Enregistrer un commentaire