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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3054 - (hide annotations) (download) (as text)
Thu Dec 15 12:47:45 2016 UTC (7 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6037 byte(s)
* Fixed numerous compiler warnings.
* Bumped version (2.0.0.svn32).

1 schoenebeck 201 /***************************************************************************
2     * *
3 schoenebeck 551 * Copyright (C) 2004, 2005 Grame *
4 schoenebeck 3054 * Copyright (C) 2005 - 2016 Christian Schoenebeck *
5 schoenebeck 201 * *
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 schoenebeck 1424 #include "../../common/global_private.h"
28 schoenebeck 201 #include "MidiInputDevice.h"
29    
30     namespace LinuxSampler {
31    
32 letz 362 /** CoreMidi input driver
33 schoenebeck 201 *
34     * Implements MIDI input for MacOSX CoreMidi architecture
35     */
36     class MidiInputDeviceCoreMidi : public MidiInputDevice {
37 schoenebeck 551
38 letz 362 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 schoenebeck 1149 ParameterName(MidiInputPort* pPort) throw (Exception);
51 schoenebeck 2434 virtual void OnSetValue(String s) throw (Exception) OVERRIDE;
52 letz 362 };
53 schoenebeck 201
54 letz 362 /** MIDI Port Parameter 'CORE_MIDI_BINDINGS'
55     *
56     * Used to connect to other Alsa sequencer clients.
57     */
58 schoenebeck 551
59 letz 362 class ParameterCoreMidiBindings : public DeviceRuntimeParameterStrings {
60     public:
61     ParameterCoreMidiBindings(MidiInputPortCoreMidi* pPort);
62 schoenebeck 2434 virtual String Description() OVERRIDE;
63     virtual bool Fix() OVERRIDE;
64     virtual std::vector<String> PossibilitiesAsString() OVERRIDE;
65     virtual void OnSetValue(std::vector<String> vS) throw (Exception) OVERRIDE;
66 letz 362 protected:
67     MidiInputPortCoreMidi* pPort;
68     };
69 schoenebeck 2370
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 schoenebeck 2434 virtual String Description() OVERRIDE;
79     virtual bool Fix() OVERRIDE;
80     virtual void OnSetValue(bool b) throw (Exception) OVERRIDE;
81 schoenebeck 2370 protected:
82     MidiInputPortCoreMidi* pPort;
83     };
84    
85     void ProcessMidiEvents(const MIDIPacketList *pktlist);
86 schoenebeck 551
87 letz 362 static void ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon);
88     static int pPortID;
89 schoenebeck 551
90 letz 362 protected:
91     MidiInputPortCoreMidi(MidiInputDeviceCoreMidi* pDevice) throw (MidiInputException);
92     ~MidiInputPortCoreMidi();
93 schoenebeck 2370 void connectToSource(MIDIEndpointRef source);
94     void connectToAllSources();
95     void onNewSourceAppeared(MIDIEndpointRef source);
96     void onNewSourceDisappeared(MIDIEndpointRef source);
97 schoenebeck 2719 void onCoreMIDIDeviceAppeared(MIDIDeviceRef device);
98     void onCoreMIDIDeviceDisappeared(MIDIDeviceRef device);
99     void onCoreMIDIEntityAppeared(MIDIEntityRef entity);
100     void onCoreMIDIEntityDisappeared(MIDIEntityRef entity);
101 letz 362 friend class MidiInputDeviceCoreMidi;
102     private:
103 schoenebeck 2370 MidiInputDeviceCoreMidi* pDevice;
104 letz 362 MIDIEndpointRef pDestination;
105 schoenebeck 2370 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)
106 letz 362
107     friend class ParameterName;
108     friend class ParameterCoreMidiBindings;
109     };
110 schoenebeck 551
111     MidiInputDeviceCoreMidi(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler);
112 letz 362 virtual ~MidiInputDeviceCoreMidi();
113    
114 schoenebeck 201 // derived abstract methods from class 'MidiInputDevice'
115 schoenebeck 2434 void Listen() OVERRIDE {}
116     void StopListen() OVERRIDE {}
117     virtual String Driver() OVERRIDE;
118 letz 362 static String Name();
119     static String Description();
120     static String Version();
121 schoenebeck 201
122 schoenebeck 3054 MidiInputPortCoreMidi* CreateMidiPort() OVERRIDE;
123 schoenebeck 551
124 schoenebeck 201 // CoreMidi callback
125 letz 362 static void NotifyProc(const MIDINotification* message, void* refCon);
126 schoenebeck 551
127 schoenebeck 201 private:
128     MIDIClientRef hCoreMidiClient;
129 schoenebeck 2370 MIDIPortRef pBridge;
130 schoenebeck 201 };
131     }
132    
133     #endif // __LS_MIDIINPUTDEVICECOREMIDI_H__

  ViewVC Help
Powered by ViewVC