Returns an array of MidiDevice.Info for MIDI Synthesizer device. - Java javax.sound.midi

Java examples for javax.sound.midi:MidiDevice

Description

Returns an array of MidiDevice.Info for MIDI Synthesizer device.

Demo Code

/*//from   ww  w.  j a v  a  2  s  . c  o m
 * Copyright 2004 Hiroo Hayashi
 *
 * This file is part of JSynthLib.
 *
 * JSynthLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or(at your option) any later version.
 *
 * JSynthLib is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JSynthLib; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
//package com.java2s;

import javax.sound.midi.*;
import java.util.*;

public class Main {
    /** Returns an array of MidiDevice.Info for MIDI Synthesizer device. */
    // not used now
    private static MidiDevice.Info[] createSynthesizerMidiDeviceInfo()
            throws MidiUnavailableException {
        ArrayList list = new ArrayList();

        MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
        for (int i = 0; i < infos.length; i++) {
            // throws MidiUnavailableException
            MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
            if (device instanceof Synthesizer)
                list.add(infos[i]);
        }
        return (MidiDevice.Info[]) list.toArray(new MidiDevice.Info[0]);
    }
}

Related Tutorials