Subversion Repositories svn.mios

Rev

Rev 800 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 800 Rev 808
Line 18... Line 18...
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
19
 */
20
20
21
package org.midibox.apps.miosstudio;
21
package org.midibox.apps.miosstudio;
22
22
-
 
23
import java.util.Collection;
23
import java.util.Iterator;
24
import java.util.Iterator;
-
 
25
import java.util.LinkedHashMap;
24
import java.util.Observable;
26
import java.util.Observable;
25
import java.util.Observer;
27
import java.util.Observer;
26
28
27
import javax.sound.midi.MidiDevice;
29
import javax.sound.midi.MidiDevice;
28
30
29
import org.midibox.midi.MidiDeviceManager;
31
import org.midibox.midi.MidiDeviceManager;
30
import org.midibox.midi.MidiDeviceRouting;
32
import org.midibox.midi.MidiDeviceRouting;
31
import org.midibox.midi.MidiFilterDevice;
33
import org.midibox.midi.MidiFilter;
32
import org.midibox.midi.MidiFilterDeviceManager;
34
import org.midibox.midi.MidiFilterManager;
33
import org.midibox.midi.MidiKeyboardControllerDevice;
35
import org.midibox.midi.MidiKeyboardController;
34
import org.midibox.midi.MidiMonitorFiltered;
36
import org.midibox.midi.MidiMonitorFiltered;
35
import org.midibox.midi.MidiMonitorFilteredDevice;
-
 
36
import org.midibox.midi.MidiRouterDevice;
37
import org.midibox.midi.SysexSendReceive;
37
import org.midibox.midi.SysexSendReceiveDevice;
38
import org.midibox.midi.SysexSendReceiveManager;
38
import org.midibox.midi.SysexSendReceiveDeviceManager;
39
import org.midibox.midi.VirtualMidiDevice;
39
import org.midibox.mios.DebugFunctionDevice;
40
import org.midibox.mios.DebugFunction;
40
import org.midibox.mios.HexFileUploadDevice;
41
import org.midibox.mios.HexFileUpload;
41
import org.midibox.mios.HexFileUploadDeviceManager;
42
import org.midibox.mios.HexFileUploadManager;
42
import org.midibox.mios.LCDMessageDevice;
43
import org.midibox.mios.LCDMessage;
43
import org.midibox.mios.MIOSTerminal;
44
import org.midibox.mios.MIOSTerminal;
44
45
45
public class MIOSStudio extends Observable implements Observer {
46
public class MIOSStudio extends Observable implements Observer {
46
47
47
    public static Object MIDI_THRU_OUT_PORT = new Object();
48
    public static Object MIDI_THRU_OUT_PORT = new Object();
48
49
49
    public static Object ROUTE_INDIVIDUAL_DEVICES = new Object();
50
    public static Object ROUTE_INDIVIDUAL_DEVICES = new Object();
50
51
51
    protected MidiDeviceRouting midiDeviceRouting;
52
    protected MidiDeviceRouting midiDeviceRouting;
52
53
53
    protected MidiRouterDevice miosStudioInPort;
54
    protected VirtualMidiDevice miosStudioInPort;
54
55
55
    protected MidiFilterDevice midiThruFilterDevice;
56
    protected MidiFilter midiThruFilter;
56
57
57
    // TODO: implement a map for MIDI thru
58
    protected VirtualMidiDevice midiThruFilterDevice;
58
59
59
    /*
-
 
60
     * private MidiMapDevice midiThruMapDevice;
60
    protected VirtualMidiDevice miosStudioThruPort;
61
     */
-
 
62
61
63
    protected MidiRouterDevice miosStudioThruPort;
-
 
64
-
 
65
    protected MidiRouterDevice miosStudioOutPort;
62
    protected VirtualMidiDevice miosStudioOutPort;
66
63
67
    private MidiDeviceManager midiDeviceManager;
64
    private MidiDeviceManager midiDeviceManager;
68
65
69
    private MidiFilterDeviceManager midiFilterManager;
66
    private MidiFilterManager midiFilterManager;
70
67
71
    /*
-
 
72
     * private MidiMapDeviceManager midiMapManager;
68
    private MidiMonitorFiltered midiInPortMonitor;
73
     */
-
 
74
69
75
    private MidiMonitorFilteredDevice midiInPortMonitorDevice;
70
    private VirtualMidiDevice midiInPortMonitorDevice;
76
71
77
    private MidiMonitorFilteredDevice midiOutPortMonitorDevice;
72
    private MidiMonitorFiltered midiOutPortMonitor;
78
73
79
    // Debuging for command line
74
    private VirtualMidiDevice midiOutPortMonitorDevice;
80
75
81
    /*
-
 
82
     * private DumpReceiverDevice inDumpReceiverDevice;
-
 
83
     *
-
 
84
     * private DumpReceiverDevice outDumpReceiverDevice;
76
    private MidiKeyboardController midiKeyboardController;
85
     */
-
 
86
77
87
    private MidiKeyboardControllerDevice midiKeyboardControllerDevice;
78
    private VirtualMidiDevice midiKeyboardControllerDevice;
88
79
89
    // TODO: implement a manager for sysex sending and receing tasks
80
    private SysexSendReceiveManager sysexSendReceiveManager;
90
81
91
    private SysexSendReceiveDeviceManager sysexSendReceiveDeviceManager;
82
    private HexFileUploadManager hexFileUploadManager;
92
83
93
    private HexFileUploadDeviceManager hexFileUploadDeviceManager;
84
    private LCDMessage lcdMessage;
94
85
95
    // TODO: implement a device for reading and writing to MIOS
86
    private VirtualMidiDevice lcdMessageDevice;
96
87
97
    /*
-
 
98
     * private MemoryReadWriteDevice memoryReadWriteDevice;
88
    private DebugFunction debugFunction;
99
     */
-
 
100
89
101
    private LCDMessageDevice lcdMessageDevice;
90
    private VirtualMidiDevice debugFunctionDevice;
102
91
103
    private DebugFunctionDevice debugFunctionDevice;
92
    private MidiMonitorFiltered miosTerminal;
104
93
105
    private MidiMonitorFilteredDevice miosTerminalDevice;
94
    private VirtualMidiDevice miosTerminalDevice;
106
95
107
    private boolean routeIndividualDevices;
96
    private boolean routeIndividualDevices;
108
97
109
    private boolean midiThruOutPort = false;
98
    private boolean midiThruOutPort = false;
-
 
99
-
 
100
    private LinkedHashMap midiFilterDevices;
-
 
101
-
 
102
    private LinkedHashMap sysexSendReceiveDevices;
-
 
103
-
 
104
    private LinkedHashMap hexFileUploadDevices;
110
105
111
    public MIOSStudio() {
106
    public MIOSStudio() {
112
107
113
        createDevices();
108
        createDevices();
114
109
Line 119... Line 114...
119
114
120
    protected void createDevices() {
115
    protected void createDevices() {
121
116
122
        midiDeviceRouting = new MidiDeviceRouting();
117
        midiDeviceRouting = new MidiDeviceRouting();
123
118
124
        miosStudioInPort = new MidiRouterDevice("MIOS Studio In Port");
119
        miosStudioInPort = new VirtualMidiDevice("MIOS Studio In Port", -1, -1);
125
-
 
126
        midiThruFilterDevice = new MidiFilterDevice("MIOS Studio Thru Filter");
120
        miosStudioInPort.setMidiInReceiver(miosStudioInPort
-
 
121
                .getMidiOutReceiver());
127
122
128
        /*
-
 
129
         * midiThruMapDevice = new MidiMapDevice("MIOS Studio Thru Map");
123
        midiThruFilterDevice = new VirtualMidiDevice("MIOS Studio Thru Filter",
130
         */
124
                -1, -1);
-
 
125
        midiThruFilter = new MidiFilter(midiThruFilterDevice
-
 
126
                .getMidiOutReceiver());
-
 
127
        midiThruFilterDevice.setMidiInReceiver(midiThruFilter);
131
128
132
        miosStudioThruPort = new MidiRouterDevice("MIOS Studio Thru Port");
129
        miosStudioThruPort = new VirtualMidiDevice("MIOS Studio Thru Port", -1,
-
 
130
                -1);
-
 
131
        miosStudioThruPort.setMidiInReceiver(miosStudioThruPort
-
 
132
                .getMidiOutReceiver());
133
133
134
        miosStudioOutPort = new MidiRouterDevice("MIOS Studio Out Port");
134
        miosStudioOutPort = new VirtualMidiDevice("MIOS Studio Out Port", -1,
-
 
135
                -1);
-
 
136
        miosStudioOutPort.setMidiInReceiver(miosStudioOutPort
-
 
137
                .getMidiOutReceiver());
135
138
136
        midiDeviceManager = new MidiDeviceManager();
139
        midiDeviceManager = new MidiDeviceManager();
137
        midiDeviceManager.addObserver(this);
140
        midiDeviceManager.addObserver(this);
138
141
139
        midiFilterManager = new MidiFilterDeviceManager();
142
        midiFilterManager = new MidiFilterManager();
140
        midiFilterManager.addObserver(this);
143
        midiFilterManager.addObserver(this);
141
144
142
        /*
-
 
143
         * midiMapManager = new MidiMapDeviceManager();
145
        midiFilterDevices = new LinkedHashMap();
144
         * midiMapManager.addObserver(this);
-
 
145
         */
-
 
146
146
-
 
147
        midiInPortMonitorDevice = new VirtualMidiDevice("MIDI Monitor: IN", 0,
-
 
148
                -1);
147
        midiInPortMonitorDevice = new MidiMonitorFilteredDevice(
149
        midiInPortMonitor = new MidiMonitorFiltered();
148
                "MIDI Monitor: IN");
150
        midiInPortMonitorDevice.setMidiInReceiver(midiInPortMonitor);
149
151
-
 
152
        midiOutPortMonitorDevice = new VirtualMidiDevice("MIDI Monitor: OUT",
-
 
153
                0, -1);
150
        midiOutPortMonitorDevice = new MidiMonitorFilteredDevice(
154
        midiOutPortMonitor = new MidiMonitorFiltered();
151
                "MIDI Monitor: OUT");
155
        midiOutPortMonitorDevice.setMidiInReceiver(midiOutPortMonitor);
152
156
153
        /*
-
 
154
         * inDumpReceiverDevice = new DumpReceiverDevice("Dump Receiver: IN");
157
        midiKeyboardControllerDevice = new VirtualMidiDevice(
155
         *
158
                "MIDI Keyboard Controller", -1, -1);
-
 
159
        midiKeyboardController = new MidiKeyboardController(
-
 
160
                midiKeyboardControllerDevice.getMidiOutReceiver(), 0);
156
         * outDumpReceiverDevice = new DumpReceiverDevice("Dump Receiver: OUT");
161
        midiKeyboardControllerDevice.setMidiInReceiver(midiKeyboardController);
157
         */
-
 
158
162
159
        midiKeyboardControllerDevice = new MidiKeyboardControllerDevice(
163
        sysexSendReceiveManager = new SysexSendReceiveManager();
160
                "MIDI Keyboard Controller", 0);
-
 
161
164
162
        sysexSendReceiveDeviceManager = new SysexSendReceiveDeviceManager();
165
        sysexSendReceiveManager.addObserver(this);
163
166
164
        sysexSendReceiveDeviceManager.addObserver(this);
167
        sysexSendReceiveDevices = new LinkedHashMap();
165
168
166
        hexFileUploadDeviceManager = new HexFileUploadDeviceManager();
169
        hexFileUploadManager = new HexFileUploadManager();
167
170
168
        hexFileUploadDeviceManager.addObserver(this);
171
        hexFileUploadManager.addObserver(this);
169
172
170
        /*
-
 
171
         * memoryReadWriteDevice = new MemoryReadWriteDevice( "MIOS Memory
173
        hexFileUploadDevices = new LinkedHashMap();
172
         * Read/Write");
-
 
173
         */
-
 
174
174
175
        lcdMessageDevice = new LCDMessageDevice("MIOS LCD Message");
175
        lcdMessageDevice = new VirtualMidiDevice("MIOS LCD Message", -1, -1);
-
 
176
        lcdMessage = new LCDMessage(lcdMessageDevice.getMidiOutReceiver());
-
 
177
        lcdMessageDevice.setMidiInReceiver(lcdMessage);
176
178
177
        debugFunctionDevice = new DebugFunctionDevice("MIOS Debug Function");
179
        debugFunctionDevice = new VirtualMidiDevice("MIOS Debug Function", -1,
-
 
180
                -1);
-
 
181
        debugFunction = new DebugFunction(debugFunctionDevice
-
 
182
                .getMidiOutReceiver());
-
 
183
        debugFunctionDevice.setMidiInReceiver(debugFunction);
178
184
179
        MidiMonitorFiltered miosTerminalFiltered = new MidiMonitorFiltered(
185
        miosTerminalDevice = new VirtualMidiDevice("MIOS Terminal", 0, -1);
180
                new MIOSTerminal());
-
 
181
-
 
182
        miosTerminalDevice = new MidiMonitorFilteredDevice("MIOS Terminal",
186
        miosTerminal = new MidiMonitorFiltered(new MIOSTerminal());
183
                miosTerminalFiltered);
187
        miosTerminalDevice.setMidiInReceiver(miosTerminal);
184
188
185
        // special for MIOS Terminal:
189
        // special for MIOS Terminal:
186
        // disable all messages by default, only allow pass SysEx
190
        // disable all messages by default, only allow pass SysEx
187
        // user can enable other MIDI events again if required
191
        // user can enable other MIDI events again if required
188
192
189
        miosTerminalFiltered.getMidiFilter().setVoiceMessages(false);
193
        miosTerminal.getMidiFilter().setVoiceMessages(false);
190
194
191
        miosTerminalFiltered.getMidiFilter().setSystemCommonMessages(false);
195
        miosTerminal.getMidiFilter().setSystemCommonMessages(false);
192
196
193
        miosTerminalFiltered.getMidiFilter().setSystemRealtimeMessages(false);
197
        miosTerminal.getMidiFilter().setSystemRealtimeMessages(false);
194
198
195
        miosTerminalFiltered.getMidiFilter().setSysexMessages(true);
199
        miosTerminal.getMidiFilter().setSysexMessages(true);
196
200
197
        miosTerminalFiltered.getMidiFilter().setMetaMessages(false);
201
        miosTerminal.getMidiFilter().setMetaMessages(false);
198
    }
202
    }
199
203
200
    public MidiDeviceManager getMidiDeviceManager() {
204
    public MidiDeviceManager getMidiDeviceManager() {
201
        return midiDeviceManager;
205
        return midiDeviceManager;
202
    }
206
    }
203
207
204
    public MidiFilterDeviceManager getMidiFilterManager() {
208
    public MidiFilterManager getMidiFilterManager() {
205
        return midiFilterManager;
209
        return midiFilterManager;
206
    }
210
    }
207
-
 
208
    /*
-
 
209
     * public MidiMapDeviceManager getMidiMapManager() { return midiMapManager;
-
 
210
     * }
-
 
211
     */
-
 
212
211
213
    public MidiDeviceRouting getMidiDeviceRouting() {
212
    public MidiDeviceRouting getMidiDeviceRouting() {
214
        return midiDeviceRouting;
213
        return midiDeviceRouting;
215
    }
214
    }
216
215
217
    public MidiMonitorFilteredDevice getMidiOutPortMonitorDevice() {
216
    public MidiMonitorFiltered getMidiOutPortMonitor() {
218
        return midiOutPortMonitorDevice;
217
        return midiOutPortMonitor;
219
    }
218
    }
220
219
221
    public MidiMonitorFilteredDevice getMidiInPortMonitorDevice() {
220
    public MidiMonitorFiltered getMidiInPortMonitor() {
222
        return midiInPortMonitorDevice;
221
        return midiInPortMonitor;
223
    }
222
    }
224
223
225
    public MidiKeyboardControllerDevice getMidiKeyboardControllerDevice() {
224
    public MidiKeyboardController getMidiKeyboardController() {
226
        return midiKeyboardControllerDevice;
225
        return midiKeyboardController;
227
    }
226
    }
228
227
229
    public SysexSendReceiveDeviceManager getSysexSendReceiveDeviceManager() {
228
    public SysexSendReceiveManager getSysexSendReceiveManager() {
230
        return sysexSendReceiveDeviceManager;
229
        return sysexSendReceiveManager;
231
    }
230
    }
232
231
233
    public HexFileUploadDeviceManager getHexFileUploadDeviceManager() {
232
    public HexFileUploadManager getHexFileUploadManager() {
234
        return hexFileUploadDeviceManager;
233
        return hexFileUploadManager;
235
    }
234
    }
236
235
237
    public DebugFunctionDevice getDebugFunctionDevice() {
236
    public DebugFunction getDebugFunction() {
238
        return debugFunctionDevice;
237
        return debugFunction;
239
    }
238
    }
240
239
241
    /*
-
 
242
     * public MemoryReadWriteDevice getMemoryReadWriteDevice() { return
-
 
243
     * memoryReadWriteDevice; }
-
 
244
     */
-
 
245
-
 
246
    public LCDMessageDevice getLcdMessageDevice() {
240
    public LCDMessage getLcdMessage() {
247
        return lcdMessageDevice;
241
        return lcdMessage;
248
    }
242
    }
249
243
250
    public MidiMonitorFilteredDevice getMIOSTerminalDevice() {
244
    public MidiMonitorFiltered getMIOSTerminal() {
251
        return miosTerminalDevice;
245
        return miosTerminal;
252
    }
246
    }
253
247
254
    public boolean isMidiThruOutPort() {
248
    public boolean isMidiThruOutPort() {
255
        return midiThruOutPort;
249
        return midiThruOutPort;
256
    }
250
    }
Line 260... Line 254...
260
254
261
        midiDeviceRouting
255
        midiDeviceRouting
262
                .connectDevices(miosStudioInPort, midiThruFilterDevice);
256
                .connectDevices(miosStudioInPort, midiThruFilterDevice);
263
257
264
        if (midiThru) {
258
        if (midiThru) {
265
-
 
266
            /*
-
 
267
             * midiDeviceRouting.connectDevices(midiThruFilterDevice,
-
 
268
             * midiThruMapDevice);
-
 
269
             */
-
 
270
259
271
            midiDeviceRouting.disconnectDevice(miosStudioThruPort);
260
            midiDeviceRouting.disconnectDevice(miosStudioThruPort);
272
261
273
            midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
262
            midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
274
                    miosStudioThruPort);
263
                    miosStudioThruPort);
275
264
276
            midiDeviceRouting.connectDevices(midiThruFilterDevice,
265
            midiDeviceRouting.connectDevices(midiThruFilterDevice,
277
                    miosStudioOutPort);
266
                    miosStudioOutPort);
278
        } else {
267
        } else {
279
-
 
280
            /*
-
 
281
             * midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
-
 
282
             * midiThruMapDevice);
-
 
283
             */
-
 
284
268
285
            midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
269
            midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
286
                    miosStudioOutPort);
270
                    miosStudioOutPort);
287
271
288
            midiDeviceRouting.connectDevices(midiThruFilterDevice,
272
            midiDeviceRouting.connectDevices(midiThruFilterDevice,
Line 296... Line 280...
296
        notifyObservers(MIDI_THRU_OUT_PORT);
280
        notifyObservers(MIDI_THRU_OUT_PORT);
297
281
298
        clearChanged();
282
        clearChanged();
299
    }
283
    }
300
284
301
    public MidiRouterDevice getMiosStudioInPort() {
285
    public VirtualMidiDevice getMiosStudioInPort() {
302
        return miosStudioInPort;
286
        return miosStudioInPort;
303
    }
287
    }
304
288
305
    public MidiRouterDevice getMiosStudioOutPort() {
289
    public VirtualMidiDevice getMiosStudioOutPort() {
306
        return miosStudioOutPort;
290
        return miosStudioOutPort;
307
    }
291
    }
308
292
309
    public MidiFilterDevice getMidiThruFilterDevice() {
293
    public MidiFilter getMidiThruFilter() {
310
        return midiThruFilterDevice;
294
        return midiThruFilter;
311
    }
295
    }
312
-
 
313
    /*
-
 
314
     * public MidiMapDevice getMidiThruMapDevice() { return midiThruMapDevice; }
-
 
315
     */
-
 
316
296
317
    public boolean isRouteIndividualDevices() {
297
    public boolean isRouteIndividualDevices() {
318
        return routeIndividualDevices;
298
        return routeIndividualDevices;
319
    }
299
    }
320
300
321
    public void setRouteIndividualDevices(boolean routeIndividualDevices) {
301
    public void setRouteIndividualDevices(boolean routeIndividualDevices) {
-
 
302
322
        this.routeIndividualDevices = routeIndividualDevices;
303
        this.routeIndividualDevices = routeIndividualDevices;
323
304
324
        // remove all devices
305
        // remove all devices
325
        midiDeviceRouting.removeAllMidiReadDevices();
306
        midiDeviceRouting.removeAllMidiReadDevices();
326
        midiDeviceRouting.removeAllMidiWriteDevices();
307
        midiDeviceRouting.removeAllMidiWriteDevices();
Line 337... Line 318...
337
            if (!midiThruOutPort) {
318
            if (!midiThruOutPort) {
338
                midiDeviceRouting.addMidiReadDevice(miosStudioThruPort);
319
                midiDeviceRouting.addMidiReadDevice(miosStudioThruPort);
339
            }
320
            }
340
        }
321
        }
341
322
342
        reorder();
323
        midiDeviceRouting.addMidiReadDevices(midiFilterDevices.values());
343
324
344
        setChanged();
-
 
345
-
 
346
        notifyObservers(ROUTE_INDIVIDUAL_DEVICES);
-
 
347
-
 
348
        clearChanged();
-
 
349
    }
-
 
350
-
 
351
    public void reorder() {
-
 
352
-
 
353
        midiDeviceRouting.getMidiReadDevices().removeAll(
-
 
354
                midiFilterManager.getMidiFilterDevices());
-
 
355
        midiDeviceRouting.getMidiWriteDevices().removeAll(
-
 
356
                midiFilterManager.getMidiFilterDevices());
-
 
357
-
 
358
        midiDeviceRouting.getMidiReadDevices().removeAll(
-
 
359
                midiDeviceManager.getSelectedMidiReadDevices().values());
-
 
360
        midiDeviceRouting.getMidiWriteDevices().removeAll(
-
 
361
                midiDeviceManager.getSelectedMidiWriteDevices().values());
-
 
362
-
 
363
        /*
-
 
364
         * midiReadDevices.removeAll(midiMapManager.getMidiMapDevices());
-
 
365
         * midiWriteDevices.removeAll(midiMapManager.getMidiMapDevices());
-
 
366
         */
-
 
367
-
 
368
        midiDeviceRouting.addMidiReadDevices(midiFilterManager
-
 
369
                .getMidiFilterDevices());
-
 
370
        midiDeviceRouting.addMidiWriteDevices(midiFilterManager
325
        midiDeviceRouting.addMidiWriteDevices(midiFilterDevices.values());
371
                .getMidiFilterDevices());
-
 
372
326
373
        Iterator it = midiDeviceManager.getMidiReadDevices().values()
327
        Iterator it = midiDeviceManager.getMidiReadDevices().values()
374
                .iterator();
328
                .iterator();
375
329
376
        while (it.hasNext()) {
330
        while (it.hasNext()) {
Line 382... Line 336...
382
                midiDeviceRouting.addMidiReadDevice((MidiDevice) object);
336
                midiDeviceRouting.addMidiReadDevice((MidiDevice) object);
383
            }
337
            }
384
        }
338
        }
385
339
386
        it = midiDeviceManager.getMidiWriteDevices().values().iterator();
340
        it = midiDeviceManager.getMidiWriteDevices().values().iterator();
-
 
341
387
        while (it.hasNext()) {
342
        while (it.hasNext()) {
388
343
389
            Object object = it.next();
344
            Object object = it.next();
390
345
391
            if (midiDeviceManager.getSelectedMidiWriteDevices().values()
346
            if (midiDeviceManager.getSelectedMidiWriteDevices().values()
392
                    .contains(object)) {
347
                    .contains(object)) {
393
                midiDeviceRouting.addMidiWriteDevice((MidiDevice) object);
348
                midiDeviceRouting.addMidiWriteDevice((MidiDevice) object);
394
            }
349
            }
395
        }
350
        }
396
351
-
 
352
        setChanged();
397
        /*
353
398
         * midiReadDevices.addAll(midiMapManager.getMidiMapDevices());
-
 
399
         * midiWriteDevices.addAll(midiMapManager.getMidiMapDevices());
354
        notifyObservers(ROUTE_INDIVIDUAL_DEVICES);
400
         */
355
-
 
356
        clearChanged();
401
    }
357
    }
402
358
403
    protected void routeIndividualDevices() {
359
    protected void routeIndividualDevices() {
404
360
405
        midiDeviceRouting.addMidiWriteDevice(miosStudioInPort);
361
        midiDeviceRouting.addMidiWriteDevice(miosStudioInPort);
406
        midiDeviceRouting.addMidiReadDevice(miosStudioInPort);
362
        midiDeviceRouting.addMidiReadDevice(miosStudioInPort);
407
363
408
        midiDeviceRouting.addMidiWriteDevice(midiThruFilterDevice);
364
        midiDeviceRouting.addMidiWriteDevice(midiThruFilterDevice);
409
        midiDeviceRouting.addMidiReadDevice(midiThruFilterDevice);
365
        midiDeviceRouting.addMidiReadDevice(midiThruFilterDevice);
410
-
 
411
        /*
-
 
412
         * midiDeviceRouting.addMidiWriteDevice(midiThruMapDevice);
-
 
413
         * midiDeviceRouting.addMidiReadDevice(midiThruMapDevice);
-
 
414
         */
-
 
415
366
416
        if (!midiThruOutPort) {
367
        if (!midiThruOutPort) {
417
368
418
            midiDeviceRouting.addMidiWriteDevice(miosStudioThruPort);
369
            midiDeviceRouting.addMidiWriteDevice(miosStudioThruPort);
419
            midiDeviceRouting.addMidiReadDevice(miosStudioThruPort);
370
            midiDeviceRouting.addMidiReadDevice(miosStudioThruPort);
420
        }
371
        }
-
 
372
421
        midiDeviceRouting.addMidiWriteDevice(miosStudioOutPort);
373
        midiDeviceRouting.addMidiWriteDevice(miosStudioOutPort);
422
        midiDeviceRouting.addMidiReadDevice(miosStudioOutPort);
374
        midiDeviceRouting.addMidiReadDevice(miosStudioOutPort);
423
375
424
        midiDeviceRouting.addMidiWriteDevice(midiOutPortMonitorDevice);
376
        midiDeviceRouting.addMidiWriteDevice(midiOutPortMonitorDevice);
425
377
426
        midiDeviceRouting.addMidiWriteDevice(midiInPortMonitorDevice);
378
        midiDeviceRouting.addMidiWriteDevice(midiInPortMonitorDevice);
427
-
 
428
        /*
-
 
429
         * midiDeviceRouting.addMidiWriteDevice(inDumpReceiverDevice);
-
 
430
         *
-
 
431
         * midiDeviceRouting.addMidiWriteDevice(outDumpReceiverDevice);
-
 
432
         */
-
 
433
379
434
        midiDeviceRouting.addMidiWriteDevice(midiKeyboardControllerDevice);
380
        midiDeviceRouting.addMidiWriteDevice(midiKeyboardControllerDevice);
435
        midiDeviceRouting.addMidiReadDevice(midiKeyboardControllerDevice);
381
        midiDeviceRouting.addMidiReadDevice(midiKeyboardControllerDevice);
436
382
-
 
383
        Collection virtualMidiDevices = sysexSendReceiveDevices.values();
-
 
384
437
        midiDeviceRouting.addMidiReadDevices(sysexSendReceiveDeviceManager
385
        midiDeviceRouting.addMidiReadDevices(virtualMidiDevices);
-
 
386
-
 
387
        midiDeviceRouting.addMidiWriteDevices(virtualMidiDevices);
-
 
388
438
                .getSysexSendReceiveDevices());
389
        virtualMidiDevices = hexFileUploadDevices.values();
439
390
440
        midiDeviceRouting.addMidiWriteDevices(sysexSendReceiveDeviceManager
391
        midiDeviceRouting.addMidiReadDevices(virtualMidiDevices);
441
                .getSysexSendReceiveDevices());
-
 
442
392
443
        midiDeviceRouting.addMidiReadDevices(hexFileUploadDeviceManager
-
 
444
                .getHexFileUploadDevices());
-
 
445
        midiDeviceRouting.addMidiWriteDevices(hexFileUploadDeviceManager
-
 
446
                .getHexFileUploadDevices());
-
 
447
        /*
-
 
448
         * midiDeviceRouting.addMidiWriteDevice(memoryReadWriteDevice);
393
        midiDeviceRouting.addMidiWriteDevices(virtualMidiDevices);
449
         * midiDeviceRouting.addMidiReadDevice(memoryReadWriteDevice);
-
 
450
         */
-
 
451
394
452
        midiDeviceRouting.addMidiReadDevice(lcdMessageDevice);
395
        midiDeviceRouting.addMidiReadDevice(lcdMessageDevice);
453
396
454
        midiDeviceRouting.addMidiWriteDevice(debugFunctionDevice);
397
        midiDeviceRouting.addMidiWriteDevice(debugFunctionDevice);
455
        midiDeviceRouting.addMidiReadDevice(debugFunctionDevice);
398
        midiDeviceRouting.addMidiReadDevice(debugFunctionDevice);
Line 464... Line 407...
464
        midiDeviceRouting.connectDevices(miosStudioInPort,
407
        midiDeviceRouting.connectDevices(miosStudioInPort,
465
                midiInPortMonitorDevice);
408
                midiInPortMonitorDevice);
466
409
467
        midiDeviceRouting.connectDevices(miosStudioOutPort,
410
        midiDeviceRouting.connectDevices(miosStudioOutPort,
468
                midiOutPortMonitorDevice);
411
                midiOutPortMonitorDevice);
469
-
 
470
        /*
-
 
471
         * midiDeviceRouting.connectDevices(inVirtualMidiPortDevice,
-
 
472
         * inDumpReceiverDevice);
-
 
473
         * midiDeviceRouting.connectDevices(outVirtualMidiPortDevice,
-
 
474
         * outDumpReceiverDevice);
-
 
475
         */
-
 
476
412
477
        midiDeviceRouting.connectDevices(miosStudioInPort,
413
        midiDeviceRouting.connectDevices(miosStudioInPort,
478
                midiKeyboardControllerDevice);
414
                midiKeyboardControllerDevice);
479
        midiDeviceRouting.connectDevices(midiKeyboardControllerDevice,
415
        midiDeviceRouting.connectDevices(midiKeyboardControllerDevice,
480
                miosStudioOutPort);
416
                miosStudioOutPort);
481
417
482
        Iterator it = sysexSendReceiveDeviceManager
418
        Iterator it = sysexSendReceiveDevices.values().iterator();
483
                .getSysexSendReceiveDevices().iterator();
-
 
484
419
485
        while (it.hasNext()) {
420
        while (it.hasNext()) {
-
 
421
486
            SysexSendReceiveDevice sysexSendReceiveDevice = (SysexSendReceiveDevice) it
422
            VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) it.next();
487
                    .next();
423
488
            midiDeviceRouting.connectDevices(miosStudioInPort,
424
            midiDeviceRouting.connectDevices(miosStudioInPort,
489
                    sysexSendReceiveDevice);
425
                    virtualMidiDevice);
-
 
426
490
            midiDeviceRouting.connectDevices(sysexSendReceiveDevice,
427
            midiDeviceRouting.connectDevices(virtualMidiDevice,
491
                    miosStudioOutPort);
428
                    miosStudioOutPort);
492
        }
429
        }
493
430
494
        it = hexFileUploadDeviceManager.getHexFileUploadDevices().iterator();
431
        it = hexFileUploadDevices.values().iterator();
495
432
496
        while (it.hasNext()) {
433
        while (it.hasNext()) {
-
 
434
497
            HexFileUploadDevice hexFileUploadDevice = (HexFileUploadDevice) it
435
            VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) it.next();
498
                    .next();
436
499
            midiDeviceRouting.connectDevices(miosStudioInPort,
437
            midiDeviceRouting.connectDevices(miosStudioInPort,
500
                    hexFileUploadDevice);
438
                    virtualMidiDevice);
501
            midiDeviceRouting.connectDevices(hexFileUploadDevice,
439
            midiDeviceRouting.connectDevices(virtualMidiDevice,
502
                    miosStudioOutPort);
440
                    miosStudioOutPort);
503
        }
441
        }
504
-
 
505
        /*
-
 
506
         * midiDeviceRouting.connectDevices(miosStudioInPort,
-
 
507
         * memoryReadWriteDevice);
-
 
508
         * midiDeviceRouting.connectDevices(memoryReadWriteDevice,
-
 
509
         * miosStudioOutPort);
-
 
510
         */
-
 
511
442
512
        midiDeviceRouting.connectDevices(lcdMessageDevice, miosStudioOutPort);
443
        midiDeviceRouting.connectDevices(lcdMessageDevice, miosStudioOutPort);
513
        midiDeviceRouting.connectDevices(miosStudioInPort, debugFunctionDevice);
444
        midiDeviceRouting.connectDevices(miosStudioInPort, debugFunctionDevice);
514
        midiDeviceRouting
445
        midiDeviceRouting
515
                .connectDevices(debugFunctionDevice, miosStudioOutPort);
446
                .connectDevices(debugFunctionDevice, miosStudioOutPort);
Line 517... Line 448...
517
        midiDeviceRouting.connectDevices(miosStudioInPort, miosTerminalDevice);
448
        midiDeviceRouting.connectDevices(miosStudioInPort, miosTerminalDevice);
518
    }
449
    }
519
450
520
    public void update(Observable observable, Object object) {
451
    public void update(Observable observable, Object object) {
521
452
522
        if (observable == hexFileUploadDeviceManager) {
453
        if (observable == hexFileUploadManager) {
523
454
524
            HexFileUploadDevice hexFileUploadDevice = (HexFileUploadDevice) object;
455
            HexFileUpload hexFileUpload = (HexFileUpload) object;
525
456
526
            if (hexFileUploadDeviceManager.getHexFileUploadDevices().contains(
457
            if (hexFileUploadDevices.containsKey(hexFileUpload)) {
-
 
458
-
 
459
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) hexFileUploadDevices
527
                    hexFileUploadDevice)) {
460
                        .get(hexFileUpload);
-
 
461
-
 
462
                midiDeviceRouting.disconnectDevice(virtualMidiDevice);
-
 
463
-
 
464
                hexFileUploadDevices.remove(hexFileUpload);
-
 
465
-
 
466
            } else {
-
 
467
-
 
468
                VirtualMidiDevice virtualMidiDevice = new VirtualMidiDevice("",
-
 
469
                        -1, -1);
-
 
470
-
 
471
                virtualMidiDevice.setMidiInReceiver(hexFileUpload);
-
 
472
-
 
473
                hexFileUpload.setReceiver(virtualMidiDevice
-
 
474
                        .getMidiOutReceiver());
528
475
529
                midiDeviceRouting.connectDevices(miosStudioInPort,
476
                midiDeviceRouting.connectDevices(miosStudioInPort,
530
                        hexFileUploadDevice);
477
                        virtualMidiDevice);
531
                midiDeviceRouting.connectDevices(hexFileUploadDevice,
478
                midiDeviceRouting.connectDevices(virtualMidiDevice,
532
                        miosStudioOutPort);
479
                        miosStudioOutPort);
-
 
480
-
 
481
                hexFileUploadDevices.put(hexFileUpload, virtualMidiDevice);
533
            } else {
482
            }
-
 
483
534
                midiDeviceRouting.disconnectDevice(hexFileUploadDevice);
484
            Collection virtualMidiDevices = hexFileUploadDevices.values();
-
 
485
-
 
486
            for (int i = 0; i < virtualMidiDevices.size(); i++) {
-
 
487
-
 
488
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) virtualMidiDevices
-
 
489
                        .toArray()[i];
-
 
490
-
 
491
                virtualMidiDevice.setName("Hex File Upload " + (i + 1));
535
            }
492
            }
536
493
537
            setRouteIndividualDevices(routeIndividualDevices);
494
            setRouteIndividualDevices(routeIndividualDevices);
538
        }
495
        }
539
       
496
540
        if (observable == sysexSendReceiveDeviceManager) {
497
        if (observable == sysexSendReceiveManager) {
541
498
542
            SysexSendReceiveDevice sysexSendReceiveDevice = (SysexSendReceiveDevice) object;
499
            SysexSendReceive sysexSendReceive = (SysexSendReceive) object;
543
500
544
            if (sysexSendReceiveDeviceManager.getSysexSendReceiveDevices().contains(
501
            if (sysexSendReceiveDevices.containsKey(sysexSendReceive)) {
-
 
502
-
 
503
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) sysexSendReceiveDevices
545
                    sysexSendReceiveDevice)) {
504
                        .get(sysexSendReceive);
-
 
505
-
 
506
                midiDeviceRouting.disconnectDevice(virtualMidiDevice);
-
 
507
-
 
508
                sysexSendReceiveDevices.remove(sysexSendReceive);
-
 
509
-
 
510
            } else {
-
 
511
-
 
512
                VirtualMidiDevice virtualMidiDevice = new VirtualMidiDevice("",
-
 
513
                        -1, -1);
-
 
514
-
 
515
                virtualMidiDevice.setMidiInReceiver(sysexSendReceive);
-
 
516
-
 
517
                sysexSendReceive.setReceiver(virtualMidiDevice
-
 
518
                        .getMidiOutReceiver());
546
519
547
                midiDeviceRouting.connectDevices(miosStudioInPort,
520
                midiDeviceRouting.connectDevices(miosStudioInPort,
548
                        sysexSendReceiveDevice);
521
                        virtualMidiDevice);
549
                midiDeviceRouting.connectDevices(sysexSendReceiveDevice,
522
                midiDeviceRouting.connectDevices(virtualMidiDevice,
550
                        miosStudioOutPort);
523
                        miosStudioOutPort);
-
 
524
-
 
525
                sysexSendReceiveDevices
-
 
526
                        .put(sysexSendReceive, virtualMidiDevice);
551
            } else {
527
            }
-
 
528
552
                midiDeviceRouting.disconnectDevice(sysexSendReceiveDevice);
529
            Collection virtualMidiDevices = sysexSendReceiveDevices.values();
-
 
530
-
 
531
            for (int i = 0; i < virtualMidiDevices.size(); i++) {
-
 
532
-
 
533
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) virtualMidiDevices
-
 
534
                        .toArray()[i];
-
 
535
-
 
536
                virtualMidiDevice.setName("Sysex Send/Receive " + (i + 1));
553
            }
537
            }
554
538
555
            setRouteIndividualDevices(routeIndividualDevices);
539
            setRouteIndividualDevices(routeIndividualDevices);
556
        }
540
        }
557
541
Line 569... Line 553...
569
            setRouteIndividualDevices(routeIndividualDevices);
553
            setRouteIndividualDevices(routeIndividualDevices);
570
        }
554
        }
571
555
572
        if (observable == midiFilterManager) {
556
        if (observable == midiFilterManager) {
573
557
574
            MidiDevice midiFilter = (MidiDevice) object;
558
            MidiFilter midiFilter = (MidiFilter) object;
-
 
559
-
 
560
            if (midiFilterDevices.containsKey(midiFilter)) {
-
 
561
-
 
562
                midiDeviceRouting
-
 
563
                        .disconnectDevice((VirtualMidiDevice) midiFilterDevices
-
 
564
                                .get(midiFilter));
-
 
565
-
 
566
                midiFilterDevices.remove(midiFilter);
-
 
567
-
 
568
            } else {
-
 
569
-
 
570
                VirtualMidiDevice virtualMidiDevice = new VirtualMidiDevice("",
-
 
571
                        -1, -1);
-
 
572
-
 
573
                virtualMidiDevice.setMidiInReceiver(midiFilter);
-
 
574
-
 
575
                midiFilter.setReceiver(virtualMidiDevice.getMidiOutReceiver());
-
 
576
-
 
577
                midiFilterDevices.put(midiFilter, virtualMidiDevice);
-
 
578
            }
-
 
579
-
 
580
            Collection virtualMidiDevices = midiFilterDevices.values();
-
 
581
-
 
582
            for (int i = 0; i < virtualMidiDevices.size(); i++) {
-
 
583
-
 
584
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) virtualMidiDevices
-
 
585
                        .toArray()[i];
575
586
576
            if (!midiFilterManager.getMidiFilterDevices().contains(midiFilter)) {
-
 
577
                midiDeviceRouting.disconnectDevice(midiFilter);
587
                virtualMidiDevice.setName("MIDI Filter " + (i + 1));
578
            }
588
            }
579
589
580
            setRouteIndividualDevices(routeIndividualDevices);
590
            setRouteIndividualDevices(routeIndividualDevices);
581
        }
591
        }
582
    }
592
    }