Subversion Repositories svn.mios

Rev

Rev 800 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
628 adamjking 1
/*
2
 * @(#)MIOSStudio.java  beta8   2006/04/23
3
 *
4
 * Copyright (C) 2008    Adam King (adamjking@optusnet.com.au)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.apps.miosstudio;
22
 
808 adamjking 23
import java.util.Collection;
628 adamjking 24
import java.util.Iterator;
808 adamjking 25
import java.util.LinkedHashMap;
628 adamjking 26
import java.util.Observable;
27
import java.util.Observer;
28
 
641 adamjking 29
import javax.sound.midi.MidiDevice;
30
 
31
import org.midibox.midi.MidiDeviceManager;
628 adamjking 32
import org.midibox.midi.MidiDeviceRouting;
808 adamjking 33
import org.midibox.midi.MidiFilter;
34
import org.midibox.midi.MidiFilterManager;
35
import org.midibox.midi.MidiKeyboardController;
628 adamjking 36
import org.midibox.midi.MidiMonitorFiltered;
808 adamjking 37
import org.midibox.midi.SysexSendReceive;
38
import org.midibox.midi.SysexSendReceiveManager;
39
import org.midibox.midi.VirtualMidiDevice;
40
import org.midibox.mios.DebugFunction;
41
import org.midibox.mios.HexFileUpload;
42
import org.midibox.mios.HexFileUploadManager;
43
import org.midibox.mios.LCDMessage;
628 adamjking 44
import org.midibox.mios.MIOSTerminal;
45
 
721 adamjking 46
public class MIOSStudio extends Observable implements Observer {
628 adamjking 47
 
721 adamjking 48
    public static Object MIDI_THRU_OUT_PORT = new Object();
723 adamjking 49
 
721 adamjking 50
    public static Object ROUTE_INDIVIDUAL_DEVICES = new Object();
723 adamjking 51
 
628 adamjking 52
    protected MidiDeviceRouting midiDeviceRouting;
53
 
808 adamjking 54
    protected VirtualMidiDevice miosStudioInPort;
628 adamjking 55
 
808 adamjking 56
    protected MidiFilter midiThruFilter;
628 adamjking 57
 
808 adamjking 58
    protected VirtualMidiDevice midiThruFilterDevice;
628 adamjking 59
 
808 adamjking 60
    protected VirtualMidiDevice miosStudioThruPort;
628 adamjking 61
 
808 adamjking 62
    protected VirtualMidiDevice miosStudioOutPort;
641 adamjking 63
 
64
    private MidiDeviceManager midiDeviceManager;
65
 
808 adamjking 66
    private MidiFilterManager midiFilterManager;
641 adamjking 67
 
808 adamjking 68
    private MidiMonitorFiltered midiInPortMonitor;
641 adamjking 69
 
808 adamjking 70
    private VirtualMidiDevice midiInPortMonitorDevice;
628 adamjking 71
 
808 adamjking 72
    private MidiMonitorFiltered midiOutPortMonitor;
628 adamjking 73
 
808 adamjking 74
    private VirtualMidiDevice midiOutPortMonitorDevice;
628 adamjking 75
 
808 adamjking 76
    private MidiKeyboardController midiKeyboardController;
628 adamjking 77
 
808 adamjking 78
    private VirtualMidiDevice midiKeyboardControllerDevice;
628 adamjking 79
 
808 adamjking 80
    private SysexSendReceiveManager sysexSendReceiveManager;
628 adamjking 81
 
808 adamjking 82
    private HexFileUploadManager hexFileUploadManager;
628 adamjking 83
 
808 adamjking 84
    private LCDMessage lcdMessage;
628 adamjking 85
 
808 adamjking 86
    private VirtualMidiDevice lcdMessageDevice;
628 adamjking 87
 
808 adamjking 88
    private DebugFunction debugFunction;
628 adamjking 89
 
808 adamjking 90
    private VirtualMidiDevice debugFunctionDevice;
628 adamjking 91
 
808 adamjking 92
    private MidiMonitorFiltered miosTerminal;
628 adamjking 93
 
808 adamjking 94
    private VirtualMidiDevice miosTerminalDevice;
628 adamjking 95
 
96
    private boolean routeIndividualDevices;
97
 
639 adamjking 98
    private boolean midiThruOutPort = false;
628 adamjking 99
 
808 adamjking 100
    private LinkedHashMap midiFilterDevices;
101
 
102
    private LinkedHashMap sysexSendReceiveDevices;
103
 
104
    private LinkedHashMap hexFileUploadDevices;
105
 
628 adamjking 106
    public MIOSStudio() {
107
 
108
        createDevices();
109
 
110
        setRouteIndividualDevices(false);
111
 
112
        connectDevices();
113
    }
114
 
115
    protected void createDevices() {
116
 
117
        midiDeviceRouting = new MidiDeviceRouting();
118
 
808 adamjking 119
        miosStudioInPort = new VirtualMidiDevice("MIOS Studio In Port", -1, -1);
120
        miosStudioInPort.setMidiInReceiver(miosStudioInPort
121
                .getMidiOutReceiver());
628 adamjking 122
 
808 adamjking 123
        midiThruFilterDevice = new VirtualMidiDevice("MIOS Studio Thru Filter",
124
                -1, -1);
125
        midiThruFilter = new MidiFilter(midiThruFilterDevice
126
                .getMidiOutReceiver());
127
        midiThruFilterDevice.setMidiInReceiver(midiThruFilter);
628 adamjking 128
 
808 adamjking 129
        miosStudioThruPort = new VirtualMidiDevice("MIOS Studio Thru Port", -1,
130
                -1);
131
        miosStudioThruPort.setMidiInReceiver(miosStudioThruPort
132
                .getMidiOutReceiver());
641 adamjking 133
 
808 adamjking 134
        miosStudioOutPort = new VirtualMidiDevice("MIOS Studio Out Port", -1,
135
                -1);
136
        miosStudioOutPort.setMidiInReceiver(miosStudioOutPort
137
                .getMidiOutReceiver());
639 adamjking 138
 
641 adamjking 139
        midiDeviceManager = new MidiDeviceManager();
140
        midiDeviceManager.addObserver(this);
141
 
808 adamjking 142
        midiFilterManager = new MidiFilterManager();
641 adamjking 143
        midiFilterManager.addObserver(this);
144
 
808 adamjking 145
        midiFilterDevices = new LinkedHashMap();
628 adamjking 146
 
808 adamjking 147
        midiInPortMonitorDevice = new VirtualMidiDevice("MIDI Monitor: IN", 0,
148
                -1);
149
        midiInPortMonitor = new MidiMonitorFiltered();
150
        midiInPortMonitorDevice.setMidiInReceiver(midiInPortMonitor);
628 adamjking 151
 
808 adamjking 152
        midiOutPortMonitorDevice = new VirtualMidiDevice("MIDI Monitor: OUT",
153
                0, -1);
154
        midiOutPortMonitor = new MidiMonitorFiltered();
155
        midiOutPortMonitorDevice.setMidiInReceiver(midiOutPortMonitor);
628 adamjking 156
 
808 adamjking 157
        midiKeyboardControllerDevice = new VirtualMidiDevice(
158
                "MIDI Keyboard Controller", -1, -1);
159
        midiKeyboardController = new MidiKeyboardController(
160
                midiKeyboardControllerDevice.getMidiOutReceiver(), 0);
161
        midiKeyboardControllerDevice.setMidiInReceiver(midiKeyboardController);
628 adamjking 162
 
808 adamjking 163
        sysexSendReceiveManager = new SysexSendReceiveManager();
628 adamjking 164
 
808 adamjking 165
        sysexSendReceiveManager.addObserver(this);
628 adamjking 166
 
808 adamjking 167
        sysexSendReceiveDevices = new LinkedHashMap();
800 adamjking 168
 
808 adamjking 169
        hexFileUploadManager = new HexFileUploadManager();
693 adamjking 170
 
808 adamjking 171
        hexFileUploadManager.addObserver(this);
723 adamjking 172
 
808 adamjking 173
        hexFileUploadDevices = new LinkedHashMap();
628 adamjking 174
 
808 adamjking 175
        lcdMessageDevice = new VirtualMidiDevice("MIOS LCD Message", -1, -1);
176
        lcdMessage = new LCDMessage(lcdMessageDevice.getMidiOutReceiver());
177
        lcdMessageDevice.setMidiInReceiver(lcdMessage);
628 adamjking 178
 
808 adamjking 179
        debugFunctionDevice = new VirtualMidiDevice("MIOS Debug Function", -1,
180
                -1);
181
        debugFunction = new DebugFunction(debugFunctionDevice
182
                .getMidiOutReceiver());
183
        debugFunctionDevice.setMidiInReceiver(debugFunction);
628 adamjking 184
 
808 adamjking 185
        miosTerminalDevice = new VirtualMidiDevice("MIOS Terminal", 0, -1);
186
        miosTerminal = new MidiMonitorFiltered(new MIOSTerminal());
187
        miosTerminalDevice.setMidiInReceiver(miosTerminal);
628 adamjking 188
 
189
        // special for MIOS Terminal:
190
        // disable all messages by default, only allow pass SysEx
191
        // user can enable other MIDI events again if required
192
 
808 adamjking 193
        miosTerminal.getMidiFilter().setVoiceMessages(false);
723 adamjking 194
 
808 adamjking 195
        miosTerminal.getMidiFilter().setSystemCommonMessages(false);
723 adamjking 196
 
808 adamjking 197
        miosTerminal.getMidiFilter().setSystemRealtimeMessages(false);
800 adamjking 198
 
808 adamjking 199
        miosTerminal.getMidiFilter().setSysexMessages(true);
800 adamjking 200
 
808 adamjking 201
        miosTerminal.getMidiFilter().setMetaMessages(false);
628 adamjking 202
    }
203
 
641 adamjking 204
    public MidiDeviceManager getMidiDeviceManager() {
205
        return midiDeviceManager;
206
    }
207
 
808 adamjking 208
    public MidiFilterManager getMidiFilterManager() {
641 adamjking 209
        return midiFilterManager;
210
    }
211
 
628 adamjking 212
    public MidiDeviceRouting getMidiDeviceRouting() {
213
        return midiDeviceRouting;
214
    }
215
 
808 adamjking 216
    public MidiMonitorFiltered getMidiOutPortMonitor() {
217
        return midiOutPortMonitor;
628 adamjking 218
    }
219
 
808 adamjking 220
    public MidiMonitorFiltered getMidiInPortMonitor() {
221
        return midiInPortMonitor;
628 adamjking 222
    }
223
 
808 adamjking 224
    public MidiKeyboardController getMidiKeyboardController() {
225
        return midiKeyboardController;
628 adamjking 226
    }
227
 
808 adamjking 228
    public SysexSendReceiveManager getSysexSendReceiveManager() {
229
        return sysexSendReceiveManager;
800 adamjking 230
    }
628 adamjking 231
 
808 adamjking 232
    public HexFileUploadManager getHexFileUploadManager() {
233
        return hexFileUploadManager;
628 adamjking 234
    }
235
 
808 adamjking 236
    public DebugFunction getDebugFunction() {
237
        return debugFunction;
628 adamjking 238
    }
239
 
808 adamjking 240
    public LCDMessage getLcdMessage() {
241
        return lcdMessage;
628 adamjking 242
    }
243
 
808 adamjking 244
    public MidiMonitorFiltered getMIOSTerminal() {
245
        return miosTerminal;
628 adamjking 246
    }
247
 
639 adamjking 248
    public boolean isMidiThruOutPort() {
249
        return midiThruOutPort;
628 adamjking 250
    }
251
 
639 adamjking 252
    public void setMidiThruOutPort(boolean midiThru) {
253
        this.midiThruOutPort = midiThru;
628 adamjking 254
 
641 adamjking 255
        midiDeviceRouting
256
                .connectDevices(miosStudioInPort, midiThruFilterDevice);
257
 
628 adamjking 258
        if (midiThru) {
639 adamjking 259
 
260
            midiDeviceRouting.disconnectDevice(miosStudioThruPort);
641 adamjking 261
 
639 adamjking 262
            midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
641 adamjking 263
                    miosStudioThruPort);
639 adamjking 264
 
628 adamjking 265
            midiDeviceRouting.connectDevices(midiThruFilterDevice,
266
                    miosStudioOutPort);
267
        } else {
641 adamjking 268
 
628 adamjking 269
            midiDeviceRouting.disconnectDevices(midiThruFilterDevice,
641 adamjking 270
                    miosStudioOutPort);
271
 
639 adamjking 272
            midiDeviceRouting.connectDevices(midiThruFilterDevice,
273
                    miosStudioThruPort);
628 adamjking 274
        }
641 adamjking 275
 
639 adamjking 276
        setRouteIndividualDevices(routeIndividualDevices);
723 adamjking 277
 
721 adamjking 278
        setChanged();
723 adamjking 279
 
721 adamjking 280
        notifyObservers(MIDI_THRU_OUT_PORT);
723 adamjking 281
 
721 adamjking 282
        clearChanged();
628 adamjking 283
    }
284
 
808 adamjking 285
    public VirtualMidiDevice getMiosStudioInPort() {
628 adamjking 286
        return miosStudioInPort;
287
    }
288
 
808 adamjking 289
    public VirtualMidiDevice getMiosStudioOutPort() {
628 adamjking 290
        return miosStudioOutPort;
291
    }
292
 
808 adamjking 293
    public MidiFilter getMidiThruFilter() {
294
        return midiThruFilter;
628 adamjking 295
    }
296
 
297
    public boolean isRouteIndividualDevices() {
298
        return routeIndividualDevices;
299
    }
300
 
301
    public void setRouteIndividualDevices(boolean routeIndividualDevices) {
808 adamjking 302
 
628 adamjking 303
        this.routeIndividualDevices = routeIndividualDevices;
304
 
305
        // remove all devices
306
        midiDeviceRouting.removeAllMidiReadDevices();
307
        midiDeviceRouting.removeAllMidiWriteDevices();
308
 
309
        // add internal MIOSStudio devices if selected
310
        if (routeIndividualDevices) {
311
 
312
            routeIndividualDevices();
313
 
314
        } else {
315
            midiDeviceRouting.addMidiWriteDevice(miosStudioInPort);
316
            midiDeviceRouting.addMidiReadDevice(miosStudioOutPort);
641 adamjking 317
 
639 adamjking 318
            if (!midiThruOutPort) {
319
                midiDeviceRouting.addMidiReadDevice(miosStudioThruPort);
320
            }
628 adamjking 321
        }
322
 
808 adamjking 323
        midiDeviceRouting.addMidiReadDevices(midiFilterDevices.values());
723 adamjking 324
 
808 adamjking 325
        midiDeviceRouting.addMidiWriteDevices(midiFilterDevices.values());
723 adamjking 326
 
739 adamjking 327
        Iterator it = midiDeviceManager.getMidiReadDevices().values()
328
                .iterator();
641 adamjking 329
 
330
        while (it.hasNext()) {
331
 
332
            Object object = it.next();
333
 
739 adamjking 334
            if (midiDeviceManager.getSelectedMidiReadDevices().values()
335
                    .contains(object)) {
641 adamjking 336
                midiDeviceRouting.addMidiReadDevice((MidiDevice) object);
337
            }
338
        }
339
 
739 adamjking 340
        it = midiDeviceManager.getMidiWriteDevices().values().iterator();
808 adamjking 341
 
641 adamjking 342
        while (it.hasNext()) {
343
 
344
            Object object = it.next();
345
 
739 adamjking 346
            if (midiDeviceManager.getSelectedMidiWriteDevices().values()
641 adamjking 347
                    .contains(object)) {
348
                midiDeviceRouting.addMidiWriteDevice((MidiDevice) object);
349
            }
350
        }
351
 
808 adamjking 352
        setChanged();
353
 
354
        notifyObservers(ROUTE_INDIVIDUAL_DEVICES);
355
 
356
        clearChanged();
641 adamjking 357
    }
358
 
628 adamjking 359
    protected void routeIndividualDevices() {
360
 
361
        midiDeviceRouting.addMidiWriteDevice(miosStudioInPort);
362
        midiDeviceRouting.addMidiReadDevice(miosStudioInPort);
363
 
364
        midiDeviceRouting.addMidiWriteDevice(midiThruFilterDevice);
365
        midiDeviceRouting.addMidiReadDevice(midiThruFilterDevice);
366
 
639 adamjking 367
        if (!midiThruOutPort) {
641 adamjking 368
 
639 adamjking 369
            midiDeviceRouting.addMidiWriteDevice(miosStudioThruPort);
370
            midiDeviceRouting.addMidiReadDevice(miosStudioThruPort);
371
        }
808 adamjking 372
 
628 adamjking 373
        midiDeviceRouting.addMidiWriteDevice(miosStudioOutPort);
374
        midiDeviceRouting.addMidiReadDevice(miosStudioOutPort);
375
 
376
        midiDeviceRouting.addMidiWriteDevice(midiOutPortMonitorDevice);
377
 
378
        midiDeviceRouting.addMidiWriteDevice(midiInPortMonitorDevice);
379
 
380
        midiDeviceRouting.addMidiWriteDevice(midiKeyboardControllerDevice);
381
        midiDeviceRouting.addMidiReadDevice(midiKeyboardControllerDevice);
382
 
808 adamjking 383
        Collection virtualMidiDevices = sysexSendReceiveDevices.values();
628 adamjking 384
 
808 adamjking 385
        midiDeviceRouting.addMidiReadDevices(virtualMidiDevices);
800 adamjking 386
 
808 adamjking 387
        midiDeviceRouting.addMidiWriteDevices(virtualMidiDevices);
628 adamjking 388
 
808 adamjking 389
        virtualMidiDevices = hexFileUploadDevices.values();
390
 
391
        midiDeviceRouting.addMidiReadDevices(virtualMidiDevices);
392
 
393
        midiDeviceRouting.addMidiWriteDevices(virtualMidiDevices);
394
 
628 adamjking 395
        midiDeviceRouting.addMidiReadDevice(lcdMessageDevice);
396
 
397
        midiDeviceRouting.addMidiWriteDevice(debugFunctionDevice);
398
        midiDeviceRouting.addMidiReadDevice(debugFunctionDevice);
399
 
400
        midiDeviceRouting.addMidiWriteDevice(miosTerminalDevice);
401
    }
402
 
403
    public void connectDevices() {
404
 
639 adamjking 405
        setMidiThruOutPort(midiThruOutPort);
641 adamjking 406
 
628 adamjking 407
        midiDeviceRouting.connectDevices(miosStudioInPort,
408
                midiInPortMonitorDevice);
409
 
410
        midiDeviceRouting.connectDevices(miosStudioOutPort,
411
                midiOutPortMonitorDevice);
412
 
413
        midiDeviceRouting.connectDevices(miosStudioInPort,
414
                midiKeyboardControllerDevice);
415
        midiDeviceRouting.connectDevices(midiKeyboardControllerDevice,
416
                miosStudioOutPort);
800 adamjking 417
 
808 adamjking 418
        Iterator it = sysexSendReceiveDevices.values().iterator();
800 adamjking 419
 
628 adamjking 420
        while (it.hasNext()) {
808 adamjking 421
 
422
            VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) it.next();
423
 
800 adamjking 424
            midiDeviceRouting.connectDevices(miosStudioInPort,
808 adamjking 425
                    virtualMidiDevice);
426
 
427
            midiDeviceRouting.connectDevices(virtualMidiDevice,
800 adamjking 428
                    miosStudioOutPort);
628 adamjking 429
        }
800 adamjking 430
 
808 adamjking 431
        it = hexFileUploadDevices.values().iterator();
800 adamjking 432
 
433
        while (it.hasNext()) {
808 adamjking 434
 
435
            VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) it.next();
436
 
800 adamjking 437
            midiDeviceRouting.connectDevices(miosStudioInPort,
808 adamjking 438
                    virtualMidiDevice);
439
            midiDeviceRouting.connectDevices(virtualMidiDevice,
800 adamjking 440
                    miosStudioOutPort);
441
        }
442
 
628 adamjking 443
        midiDeviceRouting.connectDevices(lcdMessageDevice, miosStudioOutPort);
444
        midiDeviceRouting.connectDevices(miosStudioInPort, debugFunctionDevice);
445
        midiDeviceRouting
446
                .connectDevices(debugFunctionDevice, miosStudioOutPort);
447
 
448
        midiDeviceRouting.connectDevices(miosStudioInPort, miosTerminalDevice);
449
    }
450
 
451
    public void update(Observable observable, Object object) {
723 adamjking 452
 
808 adamjking 453
        if (observable == hexFileUploadManager) {
628 adamjking 454
 
808 adamjking 455
            HexFileUpload hexFileUpload = (HexFileUpload) object;
628 adamjking 456
 
808 adamjking 457
            if (hexFileUploadDevices.containsKey(hexFileUpload)) {
628 adamjking 458
 
808 adamjking 459
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) hexFileUploadDevices
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());
475
 
693 adamjking 476
                midiDeviceRouting.connectDevices(miosStudioInPort,
808 adamjking 477
                        virtualMidiDevice);
478
                midiDeviceRouting.connectDevices(virtualMidiDevice,
693 adamjking 479
                        miosStudioOutPort);
808 adamjking 480
 
481
                hexFileUploadDevices.put(hexFileUpload, virtualMidiDevice);
641 adamjking 482
            }
628 adamjking 483
 
808 adamjking 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));
492
            }
493
 
641 adamjking 494
            setRouteIndividualDevices(routeIndividualDevices);
495
        }
496
 
808 adamjking 497
        if (observable == sysexSendReceiveManager) {
800 adamjking 498
 
808 adamjking 499
            SysexSendReceive sysexSendReceive = (SysexSendReceive) object;
800 adamjking 500
 
808 adamjking 501
            if (sysexSendReceiveDevices.containsKey(sysexSendReceive)) {
502
 
503
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) sysexSendReceiveDevices
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());
519
 
800 adamjking 520
                midiDeviceRouting.connectDevices(miosStudioInPort,
808 adamjking 521
                        virtualMidiDevice);
522
                midiDeviceRouting.connectDevices(virtualMidiDevice,
800 adamjking 523
                        miosStudioOutPort);
808 adamjking 524
 
525
                sysexSendReceiveDevices
526
                        .put(sysexSendReceive, virtualMidiDevice);
800 adamjking 527
            }
528
 
808 adamjking 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));
537
            }
538
 
800 adamjking 539
            setRouteIndividualDevices(routeIndividualDevices);
540
        }
541
 
641 adamjking 542
        if (observable == midiDeviceManager) {
543
 
544
            MidiDevice midiDevice = (MidiDevice) object;
545
 
739 adamjking 546
            if (!midiDeviceManager.getSelectedMidiReadDevices().values()
547
                    .contains(midiDevice)
642 adamjking 548
                    && !midiDeviceManager.getSelectedMidiWriteDevices()
739 adamjking 549
                            .values().contains(midiDevice)) {
641 adamjking 550
                midiDeviceRouting.disconnectDevice(midiDevice);
628 adamjking 551
            }
641 adamjking 552
 
553
            setRouteIndividualDevices(routeIndividualDevices);
628 adamjking 554
        }
555
 
641 adamjking 556
        if (observable == midiFilterManager) {
628 adamjking 557
 
808 adamjking 558
            MidiFilter midiFilter = (MidiFilter) object;
628 adamjking 559
 
808 adamjking 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);
628 adamjking 578
            }
641 adamjking 579
 
808 adamjking 580
            Collection virtualMidiDevices = midiFilterDevices.values();
581
 
582
            for (int i = 0; i < virtualMidiDevices.size(); i++) {
583
 
584
                VirtualMidiDevice virtualMidiDevice = (VirtualMidiDevice) virtualMidiDevices
585
                        .toArray()[i];
586
 
587
                virtualMidiDevice.setName("MIDI Filter " + (i + 1));
588
            }
589
 
641 adamjking 590
            setRouteIndividualDevices(routeIndividualDevices);
628 adamjking 591
        }
592
    }
593
}