Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Midi Out through 5 channels #50

Open
billyjoker opened this issue Dec 2, 2015 · 2 comments
Open

Send Midi Out through 5 channels #50

billyjoker opened this issue Dec 2, 2015 · 2 comments

Comments

@billyjoker
Copy link

Hi i'm starting with your midi library, my issues are if i can load a midi file from assets and send thorugh usb/otg 5 midi channels ?

@kshoji
Copy link
Owner

kshoji commented Dec 22, 2015

Yes. This library can play MIDI files.
This library includes javax.sound.midi porting library.
There is a MidiSystem.getSequencer() method, to get a MIDI sequencer instance.
The sequencer can play SMF files on the app's asset, or on the external directory.

Regards,
Kaoru

@billyjoker
Copy link
Author

Hi kshoji i've got send midi out as i wanted, it works fine, but i have another 2 issues:

1- When i open and play a midi file it does not perform any sound. I've verified all this steps:

  • No exception handling the midi file.

  • Previously i've got play the midi file with winamp and with a DAW.

  • I've placed soundbank.gm to directory C:\Program Files\Java\jdk1.7.0_45\lib\audio and C:\Program Files (x86)\Java\jre1.8.0_66\lib\audio

  • MidiSystem.getSynthesizer() returns null (i do not know if it is something related with this...)

  • I've got play it successfully with MediaPlayer class

  • My code:

     private Sequencer openMidiFile()
     {
       try {
        Sequencer mSeqr = MidiSystem.getSequencer();
    
        InputStream in = getAssets().open(MIDI_FILE);
        Sequence mSeq = MidiSystem.getSequence(in);
    
        mSeqr.open();
        mSeqr.setSequence(mSeq);
        mSeqr.start(); //it is supposed this execution will perform the play of the file
    
        return mSeqr;
    } catch (MidiUnavailableException e) {
        e.printStackTrace();
    } catch (InvalidMidiDataException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    
    return null;
    }
    

2- Second issue: i0ve implemented a timertask to catch the midievents from the sequencer, but it seems that it is not 100% accurated, i'm using 1ms period, What's the best way to achieve this?

Thanks and happy new year!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants