/* For License see bottom */
/*
* MidiThreadRunner.java
*
* Created on 28. Juli 2007, 18:21
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jrackattack.midi;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import jonkoshare.util.VersionInformation;
import org.apache.log4j.Logger;
/**
*
* @author methke01
*/
@VersionInformation(//
lastChanged = "$LastChangedDate: 2009-07-25 04:59:33 -0500 (Sat, 25 Jul 2009) $", //
authors = { "Alexander Methke" }, //
revision = "$LastChangedRevision: 11 $", //
lastEditor = "$LastChangedBy: onkobu $", //
id = "$Id")
public class MidiThreadRunner {
private static final Logger log = Logger.getLogger(MidiThreadRunner.class);
/** Creates a new instance of MidiThreadRunner */
public MidiThreadRunner() {
}
public static void main(String[] args) {
MidiThread mt = new MidiThread();
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
MidiDevice outDevice = null;
try {
for (MidiDevice.Info info : infos) {
MidiDevice dev;
dev = MidiSystem.getMidiDevice(info);
if (info.toString().contains("hw:1,0")
&& dev.getMaxReceivers() == -1) {
outDevice = dev;
break;
} else {
System.out.println("failed, checking " + info + " holding "
+ dev.getMaxReceivers() + " receiver");
}
}
} catch (MidiUnavailableException e) {
log.error("error", e);
}
if (outDevice == null) {
System.out.println("device is null");
System.exit(23);
}
System.out.println("connection to " + outDevice.getDeviceInfo());
try {
outDevice.open();
} catch (MidiUnavailableException ex) {
log.error("error", ex);
}
mt.setMidiOutDevice(outDevice);
mt.loadSoundParameter(0, true);
outDevice.close();
System.exit(0);
}
}
/*
* Copyright (C) 2008 Alexander Methke
*
* This program 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 3 of the License, or (at your option) any later
* version.
*
* This program 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
* this program (gplv3.txt).
*/