Skip to content Skip to sidebar Skip to footer

Android Javax Midi Sequencer Not Playing Mid File

Hi i'm using javax midi lib with Android and it works very well handling midi messages, but when i open and try to play a midi file it does not perform any sound. I've verified all

Solution 1:

From the java side, you have to connect to a synthesizer so you do the following -if your sequencer is tied up or you cant get the default you should check all others available in your system. Check the tutorials at oracle for further info

static void play(Sequence sequence)
    throws MidiUnavailableException, InvalidMidiDataException, IOException
{
      Sequencer sequencer=MidiSystem.getSequencer( );
        sequencer.open();
        Synthesizer synthesizer = MidiSystem.getSynthesizer();
        synthesizer.open();
        sequencer.getTransmitter().setReceiver(synthesizer.getReceiver( ));
        sequencer.setSequence(sequence);
        sequencer.addMetaEventListener(new MetaEventListener( ) {
                public void meta(MetaMessage m) {
                    if (m.getType( ) == END_OF_TRACK) {
                      System.out.println("end of track");
                      return;
                    }
                }
            });
        sequencer.start( );

}

Post a Comment for "Android Javax Midi Sequencer Not Playing Mid File"