1
package org.herac.tuxguitar.player.impl.midiport.winmm;
3
import java.util.ArrayList;
6
public class MidiSystem{
8
private static final String JNI_LIBRARY_NAME = new String("tuxguitar-winmm-jni");
11
System.loadLibrary(JNI_LIBRARY_NAME);
14
private long instance;
16
private MidiPortImpl connection;
19
this.instance = malloc();
20
this.ports = new ArrayList();
21
this.connection = null;
24
public void finalize(){
25
if(this.instance != 0 ){
26
this.free(this.instance);
31
public List findPorts(){
33
if(this.instance != 0){
34
this.findPorts(this.instance);
39
public void openPort(MidiPortImpl port){
40
if(this.instance != 0){
41
this.openPort(this.instance, port.getDevice());
42
this.connection = port;
46
public void closePort(){
47
if(this.instance != 0){
48
this.closePort(this.instance);
49
this.connection = null;
53
public void noteOn(int channel,int note,int velocity){
54
if(this.instance != 0){
55
this.noteOn(this.instance, channel, note, velocity);
59
public void noteOff(int channel,int note,int velocity){
60
if(this.instance != 0){
61
this.noteOff(this.instance, channel, note, velocity);
65
public void controlChange(int channel,int control,int value){
66
if(this.instance != 0){
67
this.controlChange(this.instance, channel, control, value);
71
public void programChange(int channel,int program){
72
if(this.instance != 0){
73
this.programChange(this.instance, channel, program);
77
public void pitchBend(int channel,int value){
78
if(this.instance != 0){
79
this.pitchBend(this.instance, channel, value);
83
public MidiPortImpl getConnection(){
84
return this.connection;
87
protected void addPort(String name,int device){
88
this.ports.add(new MidiPortImpl(this,name,device));
91
private native long malloc();
93
private native void free(long instance);
95
protected native void open(long instance,String device);
97
protected native void close(long instance);
99
protected native void findPorts(long instance);
101
protected native void openPort(long instance,int device);
103
protected native void closePort(long instance);
105
protected native void noteOn(long instance,int channel,int note,int velocity);
107
protected native void noteOff(long instance,int channel,int note,int velocity);
109
protected native void controlChange(long instance,int channel,int control,int value);
111
protected native void programChange(long instance,int channel,int program);
113
protected native void pitchBend(long instance,int channel,int value);