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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 201 by schoenebeck, Tue Jul 13 22:10:21 2004 UTC revision 2719 by schoenebeck, Wed Feb 25 22:46:38 2015 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   Copyright (C) 2004, 2005 Grame                                        *
4   *                                                                         *   *   Copyright (C) 2005 - 2015 Christian Schoenebeck                       *
  *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *  
  *   Copyright (C) 2004 Grame                                                                                      *  
5   *                                                                         *   *                                                                         *
6   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 26  Line 24 
24    
25  #include <CoreMIDI/MIDIServices.h>  #include <CoreMIDI/MIDIServices.h>
26    
27  #include "../common/global.h"  #include "../../common/global_private.h"
28  #include "MidiInputDevice.h"  #include "MidiInputDevice.h"
29    
30  namespace LinuxSampler {  namespace LinuxSampler {
31    
32      /** Core MIDI input driver      /** CoreMidi input driver
33       *       *
34       * Implements MIDI input for MacOSX CoreMidi architecture       * Implements MIDI input for MacOSX CoreMidi architecture
35       */       */
36      class MidiInputDeviceCoreMidi : public MidiInputDevice {      class MidiInputDeviceCoreMidi : public MidiInputDevice {
37          public:  
38              MidiInputDeviceCoreMidi(char* AutoConnectPortID = NULL);                   public:
39              ~MidiInputDeviceCoreMidi();                          /**
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) OVERRIDE;
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() 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                            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() OVERRIDE;
79                                                            virtual bool Fix() OVERRIDE;
80                                                            virtual void OnSetValue(bool b) throw (Exception) OVERRIDE;
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                        void onCoreMIDIDeviceAppeared(MIDIDeviceRef device);
98                        void onCoreMIDIDeviceDisappeared(MIDIDeviceRef device);
99                        void onCoreMIDIEntityAppeared(MIDIEntityRef entity);
100                        void onCoreMIDIEntityDisappeared(MIDIEntityRef entity);
101                        friend class MidiInputDeviceCoreMidi;
102                    private:
103                        MidiInputDeviceCoreMidi* pDevice;
104                                            MIDIEndpointRef pDestination;
105                                            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    
107                        friend class ParameterName;
108                        friend class ParameterCoreMidiBindings;
109                };
110    
111                MidiInputDeviceCoreMidi(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler);
112                virtual ~MidiInputDeviceCoreMidi();
113    
114              // derived abstract methods from class 'MidiInputDevice'              // derived abstract methods from class 'MidiInputDevice'
115              void Listen(){}              void Listen() OVERRIDE {}
116              void StopListen(){}              void StopListen() OVERRIDE {}
117                          void SetInputPort(const char *);                          virtual String Driver() OVERRIDE;
118                            static String Name();
119              // own methods                          static String Description();
120              void ConnectToCoreMidiSource(const char* MidiSource);              static String Version();
121                            
122                            MidiInputPortCoreMidi* CreateMidiPort();
123    
124                          // CoreMidi callback                          // CoreMidi callback
125                          static void NotifyProc(const MIDINotification *message, void *refCon);                          static void NotifyProc(const MIDINotification* message, void* refCon);
126                          static void ReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon);  
                           
127          private:          private:
128                          MIDIClientRef   hCoreMidiClient;                          MIDIClientRef   hCoreMidiClient;
129                          MIDIPortRef             hCoreMidiInPort;                          MIDIPortRef pBridge;
130      };      };
131  }  }
132    

Legend:
Removed from v.201  
changed lines
  Added in v.2719

  ViewVC Help
Powered by ViewVC