Public SiteDocumentation
 

Usage

Accessing a synthesizer

import net.sf.nmedit.jsynth.Synthesizer;
import javax.sound.midi.MidiDevice;
import net.sf.nmedit.jsynth.event.SynthStateListener;

public class SynthesizerUse implements SynthStateListener
{
    Synthesizer device = null;
	
    public void createSynth()
    {
    	device = SynthesizerDeviceManager.getSynthesizer("Nord Modular", "3.03");
    	if (device == null)
            throw new RuntimeException("Synthesizer implementation not found");
        device.addSynthStateListener(this);
    }
	
    public void disposeSynth()
    {
        device.removeSynthStateListener(this);
        try
        {
            device.setConnected(false);
        }
        catch(SynthException e)
        {
            e.printStackTrace();
        }
    }
	
    public boolean connect(MidiDevice.Info in, MidiDevice.Info out)
    {
        device.setMidiIn(in);
        device.setMidiOut(out);

        try
        {
            device.setConnected(true);
            return true;
        }
        catch(SynthException e)
        {
            e.printStackTrace();
            return false;
        }
    }
	
    public void synthStateChanged(SynthStateChangeEvent e)
    {
        System.out.println("Synthesizer connected:"+e.getSynthesizer().isConnected());
    }
	
}