Subversion Repositories svn.mios

Compare Revisions

Ignore whitespace Rev 738 → Rev 739

/trunk/java/org/midibox/midi/gui/MidiDeviceManagerGUI.java
26,9 → 26,9
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
 
import javax.sound.midi.MidiDevice;
import javax.swing.JButton;
133,12 → 133,12
class MidiDeviceTableModel extends DefaultTableModel {
private String[] headers = { "Selected", "MIDI Device Name" };
 
private Vector midiDevices;
private LinkedHashMap midiDevices;
 
private Vector selectedMidiDevices;
private LinkedHashMap selectedMidiDevices;
 
public MidiDeviceTableModel(Vector midiDevices,
Vector selectedMidiDevices) {
public MidiDeviceTableModel(LinkedHashMap midiDevices,
LinkedHashMap selectedMidiDevices) {
this.midiDevices = midiDevices;
this.selectedMidiDevices = selectedMidiDevices;
}
160,11 → 160,11
 
public Object getValueAt(int row, int col) {
 
MidiDevice midiDevice = (MidiDevice) midiDevices.elementAt(row);
MidiDevice midiDevice = (MidiDevice) midiDevices.values().toArray()[row];
 
if (col == 0) {
return new Boolean(selectedMidiDevices.contains(midiDevices
.elementAt(row)));
return new Boolean(selectedMidiDevices
.containsValue(midiDevices.values().toArray()[row]));
} else if (col == 1) {
return midiDevice.getDeviceInfo().getName();
}
178,21 → 178,22
if (midiDevices == midiDeviceManager.getMidiReadDevices()) {
midiDeviceManager
.selectMidiReadDevice((MidiDevice) midiDevices
.elementAt(row));
.values().toArray()[row]);
 
} else {
midiDeviceManager
.selectMidiWriteDevice((MidiDevice) midiDevices
.elementAt(row));
.values().toArray()[row]);
}
} else {
if (midiDevices == midiDeviceManager.getMidiReadDevices()) {
midiDeviceManager
.deselectMidiReadDevice((MidiDevice) midiDevices
.elementAt(row));
.values().toArray()[row]);
} else {
midiDeviceManager
.deselectMidiWriteDevice((MidiDevice) midiDevices
.elementAt(row));
.values().toArray()[row]);
}
}
}
/trunk/java/org/midibox/midi/xml/MidiDeviceManagerXML.java
1,7 → 1,7
package org.midibox.midi.xml;
 
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
 
import javax.sound.midi.MidiDevice;
 
88,14 → 88,15
 
rootElement.appendChild(deselectedMidiReadDevicesElement);
 
Iterator it = midiDeviceManager.getMidiReadDevices().iterator();
Iterator it = midiDeviceManager.getMidiReadDevices().values()
.iterator();
 
while (it.hasNext()) {
 
MidiDevice midiDevice = (MidiDevice) it.next();
 
if (!midiDeviceManager.getSelectedMidiReadDevices().contains(
midiDevice)) {
if (!midiDeviceManager.getSelectedMidiReadDevices().values()
.contains(midiDevice)) {
 
MidiDeviceXML midiDeviceXML = new MidiDeviceXML(midiDevice,
TAG_DESELECTED_MIDI_READ_DEVICE);
109,14 → 110,14
 
rootElement.appendChild(deselectedMidiWriteDevicesElement);
 
it = midiDeviceManager.getMidiWriteDevices().iterator();
it = midiDeviceManager.getMidiWriteDevices().values().iterator();
 
while (it.hasNext()) {
 
MidiDevice midiDevice = (MidiDevice) it.next();
 
if (!midiDeviceManager.getSelectedMidiWriteDevices().contains(
midiDevice)) {
if (!midiDeviceManager.getSelectedMidiWriteDevices().values()
.contains(midiDevice)) {
 
MidiDeviceXML midiDeviceXML = new MidiDeviceXML(midiDevice,
TAG_DESELECTED_MIDI_WRITE_DEVICE);
126,20 → 127,8
}
}
 
protected MidiDevice findDeviceHash(Vector midiDevices, int hash) {
protected MidiDevice findDeviceHash(HashMap midiDevices, int hash) {
 
Iterator it = midiDevices.iterator();
 
while (it.hasNext()) {
 
MidiDevice midiDevice = (MidiDevice) it.next();
 
if (midiDevice.getDeviceInfo().toString().hashCode() == hash) {
 
return midiDevice;
}
}
 
return null;
return (MidiDevice) midiDevices.get("" + hash);
}
}
/trunk/java/org/midibox/midi/MidiDeviceManager.java
20,8 → 20,8
 
package org.midibox.midi;
 
import java.util.LinkedHashMap;
import java.util.Observable;
import java.util.Vector;
 
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
31,41 → 31,42
 
public class MidiDeviceManager extends Observable {
 
private Vector midiReadDevices;
private LinkedHashMap midiReadDevices;
 
private Vector midiWriteDevices;
private LinkedHashMap midiWriteDevices;
 
private Vector selectedMidiReadDevices;
private LinkedHashMap selectedMidiReadDevices;
 
private Vector selectedMidiWriteDevices;
private LinkedHashMap selectedMidiWriteDevices;
 
public MidiDeviceManager() {
midiReadDevices = new Vector();
midiWriteDevices = new Vector();
selectedMidiReadDevices = new Vector();
selectedMidiWriteDevices = new Vector();
midiReadDevices = new LinkedHashMap();
midiWriteDevices = new LinkedHashMap();
selectedMidiReadDevices = new LinkedHashMap();
selectedMidiWriteDevices = new LinkedHashMap();
rescanDevices();
}
 
public Vector getMidiReadDevices() {
public LinkedHashMap getMidiReadDevices() {
return midiReadDevices;
}
 
public Vector getMidiWriteDevices() {
public LinkedHashMap getMidiWriteDevices() {
return midiWriteDevices;
}
 
public Vector getSelectedMidiReadDevices() {
public LinkedHashMap getSelectedMidiReadDevices() {
return selectedMidiReadDevices;
}
 
public Vector getSelectedMidiWriteDevices() {
public LinkedHashMap getSelectedMidiWriteDevices() {
return selectedMidiWriteDevices;
}
 
public void selectMidiReadDevice(MidiDevice midiDevice) {
selectedMidiReadDevices.remove(midiDevice);
selectedMidiReadDevices.add(midiDevice);
selectedMidiReadDevices.put(""
+ midiDevice.getDeviceInfo().toString().hashCode(), midiDevice);
 
setChanged();
notifyObservers(midiDevice);
74,7 → 75,8
 
public void selectMidiWriteDevice(MidiDevice midiDevice) {
selectedMidiWriteDevices.remove(midiDevice);
selectedMidiWriteDevices.add(midiDevice);
selectedMidiWriteDevices.put(""
+ midiDevice.getDeviceInfo().toString().hashCode(), midiDevice);
 
setChanged();
notifyObservers(midiDevice);
82,7 → 84,8
}
 
public void deselectMidiReadDevice(MidiDevice midiDevice) {
selectedMidiReadDevices.remove(midiDevice);
selectedMidiReadDevices.remove(""
+ midiDevice.getDeviceInfo().toString().hashCode());
 
setChanged();
notifyObservers(midiDevice);
90,7 → 93,8
}
 
public void deselectMidiWriteDevice(MidiDevice midiDevice) {
selectedMidiWriteDevices.remove(midiDevice);
selectedMidiWriteDevices.remove(""
+ midiDevice.getDeviceInfo().toString().hashCode());
 
setChanged();
notifyObservers(midiDevice);
105,50 → 109,40
 
for (int i = 0; i < infos.length; i++) {
 
mInfo = infos[i];
try {
 
boolean different;
MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
 
if (i == 0) {
if (!(device instanceof Sequencer)
&& !(device instanceof Synthesizer)) {
 
different = true;
int noReceivers = device.getMaxReceivers();
int noTransmitters = device.getMaxTransmitters();
 
} else {
 
different = mInfo.toString().hashCode() != infos[i - 1]
.toString().hashCode();
}
 
if (different) {
 
try {
 
MidiDevice device = MidiSystem.getMidiDevice(mInfo);
 
if (!(device instanceof Sequencer)
&& !(device instanceof Synthesizer)) {
 
int noReceivers = device.getMaxReceivers();
int noTransmitters = device.getMaxTransmitters();
 
if (noReceivers != 0) {
if (!midiWriteDevices.contains(device)) {
midiWriteDevices.add(device);
selectMidiWriteDevice(device);
}
if (noReceivers != 0) {
if (!midiWriteDevices.containsKey(""
+ device.getDeviceInfo().toString().hashCode())) {
midiWriteDevices.put(""
+ device.getDeviceInfo().toString()
.hashCode(), device);
selectMidiWriteDevice(device);
}
}
 
if (noTransmitters != 0) {
if (!midiReadDevices.contains(device)) {
midiReadDevices.add(device);
selectMidiReadDevice(device);
}
if (noTransmitters != 0) {
if (!midiReadDevices.containsKey(""
+ device.getDeviceInfo().toString().hashCode())) {
midiReadDevices.put(""
+ device.getDeviceInfo().toString()
.hashCode(), device);
selectMidiReadDevice(device);
}
}
} catch (MidiUnavailableException e) {
}
} catch (MidiUnavailableException e) {
 
}
}
 
}
}
}
/trunk/java/org/midibox/apps/miosstudio/MIOSStudio.java
233,6 → 233,7
*
*
*
*
* miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessages(false);
*/
 
401,9 → 402,9
midiFilterManager.getMidiFilterDevices());
 
midiDeviceRouting.getMidiReadDevices().removeAll(
midiDeviceManager.getSelectedMidiReadDevices());
midiDeviceManager.getSelectedMidiReadDevices().values());
midiDeviceRouting.getMidiWriteDevices().removeAll(
midiDeviceManager.getSelectedMidiWriteDevices());
midiDeviceManager.getSelectedMidiWriteDevices().values());
 
/*
* midiReadDevices.removeAll(midiMapManager.getMidiMapDevices());
415,23 → 416,25
midiDeviceRouting.addMidiWriteDevices(midiFilterManager
.getMidiFilterDevices());
 
Iterator it = midiDeviceManager.getMidiReadDevices().iterator();
Iterator it = midiDeviceManager.getMidiReadDevices().values()
.iterator();
 
while (it.hasNext()) {
 
Object object = it.next();
 
if (midiDeviceManager.getSelectedMidiReadDevices().contains(object)) {
if (midiDeviceManager.getSelectedMidiReadDevices().values()
.contains(object)) {
midiDeviceRouting.addMidiReadDevice((MidiDevice) object);
}
}
 
it = midiDeviceManager.getMidiWriteDevices().iterator();
it = midiDeviceManager.getMidiWriteDevices().values().iterator();
while (it.hasNext()) {
 
Object object = it.next();
 
if (midiDeviceManager.getSelectedMidiWriteDevices()
if (midiDeviceManager.getSelectedMidiWriteDevices().values()
.contains(object)) {
midiDeviceRouting.addMidiWriteDevice((MidiDevice) object);
}
574,10 → 577,10
 
MidiDevice midiDevice = (MidiDevice) object;
 
if (!midiDeviceManager.getSelectedMidiReadDevices().contains(
midiDevice)
if (!midiDeviceManager.getSelectedMidiReadDevices().values()
.contains(midiDevice)
&& !midiDeviceManager.getSelectedMidiWriteDevices()
.contains(midiDevice)) {
.values().contains(midiDevice)) {
midiDeviceRouting.disconnectDevice(midiDevice);
}
 
/trunk/java/org/midibox/apps/virtualkeyboard/VirtualKeyboard.java
72,10 → 72,10
midiDeviceRouting.addMidiWriteDevice(virtualKeyboardInPort);
 
midiDeviceRouting.addMidiReadDevices(midiDeviceManager
.getSelectedMidiReadDevices());
.getSelectedMidiReadDevices().values());
 
midiDeviceRouting.addMidiWriteDevices(midiDeviceManager
.getSelectedMidiWriteDevices());
.getSelectedMidiWriteDevices().values());
}
 
public MidiDeviceRouting getMidiDeviceRouting() {
/trunk/java/org/midibox/apps/sidv2editor/SIDV2Editor.java
62,9 → 62,9
if (midiDeviceRouting != null) {
midiDeviceManager.rescanDevices();
midiDeviceRouting.addMidiReadDevices(midiDeviceManager
.getSelectedMidiReadDevices());
.getSelectedMidiReadDevices().values());
midiDeviceRouting.addMidiWriteDevices(midiDeviceManager
.getSelectedMidiWriteDevices());
.getSelectedMidiWriteDevices().values());
}
}