Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
628 adamjking 1
/*
2
 * @(#)VirtualKeyboard.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.virtualkeyboard;
22
 
641 adamjking 23
import org.midibox.midi.MidiDeviceManager;
628 adamjking 24
import org.midibox.midi.MidiDeviceRouting;
808 adamjking 25
import org.midibox.midi.MidiKeyboardController;
26
import org.midibox.midi.VirtualMidiDevice;
628 adamjking 27
 
28
public class VirtualKeyboard {
642 adamjking 29
 
641 adamjking 30
    private MidiDeviceManager midiDeviceManager;
628 adamjking 31
 
32
    private MidiDeviceRouting midiDeviceRouting;
33
 
808 adamjking 34
    private MidiKeyboardController midiKeyboardController;
628 adamjking 35
 
808 adamjking 36
    private VirtualMidiDevice midiKeyboardControllerDevice;
647 adamjking 37
 
808 adamjking 38
    private VirtualMidiDevice virtualKeyboardInPort;
647 adamjking 39
 
808 adamjking 40
    private VirtualMidiDevice virtualKeyboardThruPort;
647 adamjking 41
 
808 adamjking 42
    private VirtualMidiDevice virtualKeyboardOutPort;
43
 
628 adamjking 44
    public VirtualKeyboard() {
45
 
46
        midiDeviceRouting = new MidiDeviceRouting();
47
 
808 adamjking 48
        midiKeyboardControllerDevice = new VirtualMidiDevice(
49
                "Virtual MIDI Keyboard", -1, -1);
628 adamjking 50
 
808 adamjking 51
        midiKeyboardController = new MidiKeyboardController(
52
                midiKeyboardControllerDevice.getMidiOutReceiver(), 0);
53
 
641 adamjking 54
        midiDeviceManager = new MidiDeviceManager();
642 adamjking 55
 
641 adamjking 56
        midiDeviceManager.rescanDevices();
642 adamjking 57
 
808 adamjking 58
        virtualKeyboardInPort = new VirtualMidiDevice("Virtual Keyboard In",
59
                -1, -1);
60
        virtualKeyboardInPort.setMidiInReceiver(virtualKeyboardInPort
61
                .getMidiOutReceiver());
647 adamjking 62
 
808 adamjking 63
        virtualKeyboardThruPort = new VirtualMidiDevice(
64
                "Virtual Keyboard Thru", -1, -1);
65
        virtualKeyboardThruPort.setMidiInReceiver(virtualKeyboardThruPort
66
                .getMidiOutReceiver());
647 adamjking 67
 
808 adamjking 68
        virtualKeyboardOutPort = new VirtualMidiDevice("Virtual Keyboard Out",
69
                -1, -1);
70
        virtualKeyboardOutPort.setMidiInReceiver(virtualKeyboardOutPort
71
                .getMidiOutReceiver());
647 adamjking 72
 
73
        midiDeviceRouting.connectDevices(virtualKeyboardInPort,
74
                midiKeyboardControllerDevice);
75
 
76
        midiDeviceRouting.connectDevices(virtualKeyboardInPort,
77
                virtualKeyboardThruPort);
78
 
79
        midiDeviceRouting.connectDevices(midiKeyboardControllerDevice,
80
                virtualKeyboardOutPort);
81
 
82
        midiDeviceRouting.addMidiReadDevice(virtualKeyboardOutPort);
83
 
84
        midiDeviceRouting.addMidiReadDevice(virtualKeyboardThruPort);
85
 
86
        midiDeviceRouting.addMidiWriteDevice(virtualKeyboardInPort);
87
 
642 adamjking 88
        midiDeviceRouting.addMidiReadDevices(midiDeviceManager
739 adamjking 89
                .getSelectedMidiReadDevices().values());
647 adamjking 90
 
642 adamjking 91
        midiDeviceRouting.addMidiWriteDevices(midiDeviceManager
739 adamjking 92
                .getSelectedMidiWriteDevices().values());
628 adamjking 93
    }
94
 
95
    public MidiDeviceRouting getMidiDeviceRouting() {
96
        return midiDeviceRouting;
97
    }
98
 
808 adamjking 99
    public MidiKeyboardController getMidiKeyboardController() {
100
        return midiKeyboardController;
628 adamjking 101
    }
102
}