/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInputDeviceCoreMidi.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceCoreMidi.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2370 - (show annotations) (download) (as text)
Wed Sep 19 13:11:45 2012 UTC (11 years, 7 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5629 byte(s)
* CoreMIDI driver: implemented driver specific port parameter
  "CORE_MIDI_BINDINGS", which allows to retrieve the list of CoreMIDI
  clients / ports and to connect to them a la JACK, via the usual
  sampler APIs
* CoreMIDI driver: added driver specific port parameter "AUTO_BIND", if
  enabled the driver will automatically connect to other CoreMIDI
  clients' ports (e.g. external MIDI devices being attached to the Mac)

1 /***************************************************************************
2 * *
3 * Copyright (C) 2004, 2005 Grame *
4 * Copyright (C) 2005 - 2012 Christian Schoenebeck *
5 * *
6 * This program 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 program 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 program; if not, write to the Free Software *
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
19 * MA 02111-1307 USA *
20 ***************************************************************************/
21
22 #ifndef __LS_MIDIINPUTDEVICECOREMIDI_H__
23 #define __LS_MIDIINPUTDEVICECOREMIDI_H__
24
25 #include <CoreMIDI/MIDIServices.h>
26
27 #include "../../common/global_private.h"
28 #include "MidiInputDevice.h"
29
30 namespace LinuxSampler {
31
32 /** CoreMidi input driver
33 *
34 * Implements MIDI input for MacOSX CoreMidi architecture
35 */
36 class MidiInputDeviceCoreMidi : public MidiInputDevice {
37
38 public:
39 /**
40 * MIDI Port implementation for the CoreMidi input driver.
41 */
42 class MidiInputPortCoreMidi : public MidiInputPort {
43 public:
44 /** MIDI Port Parameter 'NAME'
45 *
46 * Used to assign an arbitrary name to the MIDI port.
47 */
48 class ParameterName : public MidiInputPort::ParameterName {
49 public:
50 ParameterName(MidiInputPort* pPort) throw (Exception);
51 virtual void OnSetValue(String s) throw (Exception);
52 };
53
54 /** MIDI Port Parameter 'CORE_MIDI_BINDINGS'
55 *
56 * Used to connect to other Alsa sequencer clients.
57 */
58
59 class ParameterCoreMidiBindings : public DeviceRuntimeParameterStrings {
60 public:
61 ParameterCoreMidiBindings(MidiInputPortCoreMidi* pPort);
62 virtual String Description();
63 virtual bool Fix();
64 virtual std::vector<String> PossibilitiesAsString();
65 virtual void OnSetValue(std::vector<String> vS) throw (Exception);
66 protected:
67 MidiInputPortCoreMidi* pPort;
68 };
69
70 /** MIDI Port Parameter 'AUTO_BIND'
71 *
72 * If enabled, the port will automatically be connected to all
73 * CoreMIDI source endpoints at present and future.
74 */
75 class ParameterAutoBind : public DeviceRuntimeParameterBool {
76 public:
77 ParameterAutoBind(MidiInputPortCoreMidi* pPort);
78 virtual String Description();
79 virtual bool Fix();
80 virtual void OnSetValue(bool b) throw (Exception);
81 protected:
82 MidiInputPortCoreMidi* pPort;
83 };
84
85 void ProcessMidiEvents(const MIDIPacketList *pktlist);
86
87 static void ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon);
88 static int pPortID;
89
90 protected:
91 MidiInputPortCoreMidi(MidiInputDeviceCoreMidi* pDevice) throw (MidiInputException);
92 ~MidiInputPortCoreMidi();
93 void connectToSource(MIDIEndpointRef source);
94 void connectToAllSources();
95 void onNewSourceAppeared(MIDIEndpointRef source);
96 void onNewSourceDisappeared(MIDIEndpointRef source);
97 friend class MidiInputDeviceCoreMidi;
98 private:
99 MidiInputDeviceCoreMidi* pDevice;
100 MIDIEndpointRef pDestination;
101 std::vector<MIDIEndpointRef> bindings; //TODO: shall probably be protected by a mutex (since the CoreMIDI notification callback thread might also modify it when new sources appear or disappear)
102
103 friend class ParameterName;
104 friend class ParameterCoreMidiBindings;
105 };
106
107 MidiInputDeviceCoreMidi(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler);
108 virtual ~MidiInputDeviceCoreMidi();
109
110 // derived abstract methods from class 'MidiInputDevice'
111 void Listen(){}
112 void StopListen(){}
113 virtual String Driver();
114 static String Name();
115 static String Description();
116 static String Version();
117
118 MidiInputPortCoreMidi* CreateMidiPort();
119
120 // CoreMidi callback
121 static void NotifyProc(const MIDINotification* message, void* refCon);
122
123 private:
124 MIDIClientRef hCoreMidiClient;
125 MIDIPortRef pBridge;
126 };
127 }
128
129 #endif // __LS_MIDIINPUTDEVICECOREMIDI_H__

  ViewVC Help
Powered by ViewVC