Question

Hi I am programming Java on Windows and am very new to working with MIDI interfaces.

I have managed to get java to play midi sounds through Synthesizer objects, natively through the computers speaker however I wish to send midi messages on the fly to a separate synthesis application, namely FLStudio. I think I have to make the java interface look like a hardware midi device but I have no idea how to do this. I also think it may have something to do with Transmitter or MidiDevice but i'm not sure.

Does anyone know how I would begin to go about this. I have looked all over Google about this but always end up at the same 2 documents,

http://www.jsresources.org/faq_midi.html and http://www.ibm.com/developerworks/library/it/it-0801art38/

Sorry if this question has been asked before but i couldn't find it.

Here's what I have so far. Any help would be greatly appreciated.

import javax.sound.midi.*;

public class Midi
{
    public static final void main(String args[]) throws Exception
    {
        //create and open synthesizer
        Synthesizer syn = MidiSystem.getSynthesizer();
        syn.open();

        //open midi channels (we'll use channel 5)
        final MidiChannel[] mc = syn.getChannels();

        //set instruments
        Instrument[] instr = syn.getDefaultSoundbank().getInstruments();

        //Possible ways to send midi to FLStudio, rather than inbuilt
        //javax.sound.midi.Transmitter?
        //javax.sound.midi.MidiDevice?

        // change instrument, using midi codes
        mc[5].programChange(instr[0].getPatch().getProgram());

        // Play note
        mc[5].noteOn(50,1000); //(noteNumber, velocity)
    }
}
Was it helpful?

Solution

You can use a program like MidiOx to create a virtual MIDI endpoint which you can send MIDI messages to. Then, in your sequencer, you just tell it to accept MIDI messages from the output of that device, and you can use it as a passthru pipe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top