[jmsl] Playing Through An External Midi Device

jmsl at music.columbia.edu jmsl at music.columbia.edu
Tue Apr 14 11:50:05 EDT 2009


Hi Chi

Please help me out here, I don't have a lot of resources currently to 
work on this.  If you can do the following in a few lines of pure Java 
(no JMSL at all), then I will implement it in JMSL's JavaSound support

If someone already knows how to do this, please share it here.

You already know how to enumerate through midi device info.

You can create a MidiDevice using minfo like this:
MidiDevice mdev = MidiSystem.getMidiDevice(infos[i]);

Your challenge is to open the mdev you want, get the transmitter or 
receiver or whatever it is one needs to do to send a midi message out to 
it, and send it a simple MidiMessage like a noteon. 

I've tried it but cannot get a receiver or a transmitter for these midi 
devices, I just get nulls or exceptions.  Something's missing and I 
don't know what it is.

My code follows...
MidiDevice.Info[] minfo= MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < minfo.length; i++) {
                MidiDevice mdev = MidiSystem.getMidiDevice(minfo[i]);
                String info = minfo[i].getDescription() + ", " +
                minfo[i].getName() + ", " +
                minfo[i].getVendor() + ", " +
                minfo[i].getVersion();
                System.out.println("\nDevice " + i + " = " + minfo[i] + 
" ... " + mdev.toString());
                System.out.println("CLASS: " + mdev.getClass());
                mdev.open();
                try {
                    System.out.println("transmitter for this: " + 
mdev.getTransmitter());
                    System.out.println("receiver for this : " + 
mdev.getReceiver());
                } catch (MidiUnavailableException e) {
                    System.out.println("can't get transmitter or 
receiver for this");
                }               
                mdev.close();
}

Thanks
Nick

jmsl at music.columbia.edu wrote:
> How can I hookup JavaSound ports to JMSL? If I do this I can see all 
> the external midi devices I have on my computer.
>
> MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
> for (int i = 0; i < infos.length; i++) {
>    System.out.println(infos[i]);
> }
>
> /*
> Result:
> USB Audio Device
> Microsoft MIDI Mapper
> USB Audio Device
> SB X-Fi Synth A [BC00]
> SB X-Fi Synth B [BC00]
> Microsoft GS Wavetable SW Synth
> Real Time Sequencer
> Java Sound Synthesizer
> */
>
> If I do this, I get an error.
> JMSL.midi = MidiIO_JavaSound.instance();
> String[] deviceNames = JMSL.midi.getOutputDeviceNames();
> System.out.println("There are " + deviceNames.length + "midi devices.");
> for (int i=0; i<deviceNames.length; i++) {
> System.out.println(deviceNames[i]);
> }
>
> /*
> Result:
> There are 1midi devices.
> Unimplemented
> */
>
> _______________________________________________
> jmsl mailing list
> jmsl at music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/jmsl


More information about the jmsl mailing list