alternative new version of the AppleUtility library
[ardour.git] / libs / appleutility / CoreAudio / AudioUnits / AUPublic / OtherBases / AUMIDIBase.h
1 /*
2      File: AUMIDIBase.h
3  Abstract: Part of CoreAudio Utility Classes
4   Version: 1.1
5  
6  Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
7  Inc. ("Apple") in consideration of your agreement to the following
8  terms, and your use, installation, modification or redistribution of
9  this Apple software constitutes acceptance of these terms.  If you do
10  not agree with these terms, please do not use, install, modify or
11  redistribute this Apple software.
12  
13  In consideration of your agreement to abide by the following terms, and
14  subject to these terms, Apple grants you a personal, non-exclusive
15  license, under Apple's copyrights in this original Apple software (the
16  "Apple Software"), to use, reproduce, modify and redistribute the Apple
17  Software, with or without modifications, in source and/or binary forms;
18  provided that if you redistribute the Apple Software in its entirety and
19  without modifications, you must retain this notice and the following
20  text and disclaimers in all such redistributions of the Apple Software.
21  Neither the name, trademarks, service marks or logos of Apple Inc. may
22  be used to endorse or promote products derived from the Apple Software
23  without specific prior written permission from Apple.  Except as
24  expressly stated in this notice, no other rights or licenses, express or
25  implied, are granted by Apple herein, including but not limited to any
26  patent rights that may be infringed by your derivative works or by other
27  works in which the Apple Software may be incorporated.
28  
29  The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
30  MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31  THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32  FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33  OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34  
35  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39  MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40  AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41  STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42  POSSIBILITY OF SUCH DAMAGE.
43  
44  Copyright (C) 2014 Apple Inc. All Rights Reserved.
45  
46 */
47 #ifndef __AUMIDIBase_h__
48 #define __AUMIDIBase_h__
49
50 #include "AUBase.h"
51
52 #if CA_AUTO_MIDI_MAP
53         #include "CAAUMIDIMapManager.h"
54 #endif
55
56 struct MIDIPacketList;
57
58 // ________________________________________________________________________
59 //      MusicDeviceBase
60 //
61         /*! @class AUMIDIBase */
62 class AUMIDIBase {
63 public:
64                                                                         // this is NOT a copy constructor!
65         /*! @ctor AUMIDIBase */
66                                                                 AUMIDIBase(AUBase* inBase);
67         /*! @dtor ~AUMIDIBase */
68         virtual                                         ~AUMIDIBase();
69         
70         /*! @method MIDIEvent */
71         virtual OSStatus        MIDIEvent(              UInt32                                          inStatus, 
72                                                                                 UInt32                                          inData1, 
73                                                                                 UInt32                                          inData2, 
74                                                                                 UInt32                                          inOffsetSampleFrame)
75         {
76                 UInt32 strippedStatus = inStatus & 0xf0;
77                 UInt32 channel = inStatus & 0x0f;
78         
79                 return HandleMidiEvent(strippedStatus, channel, inData1, inData2, inOffsetSampleFrame);
80         }
81         
82         /*! @method HandleMIDIPacketList */
83         OSStatus                        HandleMIDIPacketList(const MIDIPacketList *pktlist);
84         
85         /*! @method SysEx */
86         virtual OSStatus        SysEx(                  const UInt8 *                           inData, 
87                                                                                 UInt32                                          inLength);
88
89 #if TARGET_API_MAC_OSX
90         /*! @method DelegateGetPropertyInfo */
91         virtual OSStatus                        DelegateGetPropertyInfo(AudioUnitPropertyID                     inID,
92                                                                                                                 AudioUnitScope                          inScope,
93                                                                                                                 AudioUnitElement                        inElement,
94                                                                                                                 UInt32 &                                        outDataSize,
95                                                                                                                 Boolean &                                       outWritable);
96
97         /*! @method DelegateGetProperty */
98         virtual OSStatus                        DelegateGetProperty(    AudioUnitPropertyID             inID,
99                                                                                                                 AudioUnitScope                          inScope,
100                                                                                                                 AudioUnitElement                        inElement,
101                                                                                                                 void *                                          outData);
102                                                                                                                 
103         /*! @method DelegateSetProperty */
104         virtual OSStatus                        DelegateSetProperty(    AudioUnitPropertyID             inID,
105                                                                                                                 AudioUnitScope                          inScope,
106                                                                                                                 AudioUnitElement                        inElement,
107                                                                                                                 const void *                            inData,
108                                                                                                                 UInt32                                          inDataSize);
109 #endif
110
111 protected:
112         // MIDI dispatch
113         /*! @method HandleMidiEvent */
114         virtual OSStatus        HandleMidiEvent(                UInt8   inStatus,
115                                                                                                 UInt8   inChannel,
116                                                                                                 UInt8   inData1,
117                                                                                                 UInt8   inData2,
118                                                                                                 UInt32  inStartFrame);
119
120         /*! @method HandleNonNoteEvent */
121         virtual OSStatus        HandleNonNoteEvent (    UInt8   status, 
122                                                                                                 UInt8   channel, 
123                                                                                                 UInt8   data1, 
124                                                                                                 UInt8   data2, 
125                                                                                                 UInt32  inStartFrame);
126
127 #if TARGET_API_MAC_OSX
128         /*! @method GetXMLNames */
129         virtual OSStatus                        GetXMLNames(CFURLRef *outNameDocument) 
130         { return kAudioUnitErr_InvalidProperty; }       // if not overridden, it's unsupported
131 #endif
132
133 // channel messages
134         /*! @method HandleNoteOn */
135         virtual OSStatus        HandleNoteOn(                   UInt8   inChannel,
136                                                                                                 UInt8   inNoteNumber,
137                                                                                                 UInt8   inVelocity,
138                                                                                                 UInt32  inStartFrame) { return noErr; }
139                                                                                                 
140         /*! @method HandleNoteOff */
141         virtual OSStatus        HandleNoteOff(                  UInt8   inChannel,
142                                                                                                 UInt8   inNoteNumber,
143                                                                                                 UInt8   inVelocity,
144                                                                                                 UInt32  inStartFrame) { return noErr; }
145                                                                                                 
146         /*! @method HandleControlChange */
147         virtual OSStatus        HandleControlChange(    UInt8   inChannel,
148                                                                                                 UInt8   inController,
149                                                                                                 UInt8   inValue,
150                                                                                                 UInt32  inStartFrame) { return noErr; }
151                                                                                                 
152         /*! @method HandlePitchWheel */
153         virtual OSStatus        HandlePitchWheel(               UInt8   inChannel,
154                                                                                                 UInt8   inPitch1,
155                                                                                                 UInt8   inPitch2,
156                                                                                                 UInt32  inStartFrame) { return noErr; }
157                                                                                                 
158         /*! @method HandleChannelPressure */
159         virtual OSStatus        HandleChannelPressure(  UInt8   inChannel,
160                                                                                                 UInt8   inValue,
161                                                                                                 UInt32  inStartFrame) { return noErr; }
162
163         /*! @method HandleProgramChange */
164         virtual OSStatus        HandleProgramChange(    UInt8   inChannel,
165                                                                                                 UInt8   inValue) { return noErr; }
166
167         /*! @method HandlePolyPressure */
168         virtual OSStatus        HandlePolyPressure(             UInt8   inChannel,
169                                                                                                 UInt8   inKey,
170                                                                                                 UInt8   inValue,
171                                                                                                 UInt32  inStartFrame) { return noErr; }
172
173         /*! @method HandleResetAllControllers */
174         virtual OSStatus        HandleResetAllControllers(UInt8 inChannel) { return noErr; }
175         
176         /*! @method HandleAllNotesOff */
177         virtual OSStatus        HandleAllNotesOff(              UInt8   inChannel) { return noErr; }
178         
179         /*! @method HandleAllSoundOff */
180         virtual OSStatus        HandleAllSoundOff(              UInt8   inChannel) { return noErr; }
181
182
183 //System messages   
184         /*! @method HandleSysEx */
185         virtual OSStatus        HandleSysEx(                    const UInt8 *   inData,
186                                                         UInt32                  inLength ) { return noErr; }
187
188 #if CA_AUTO_MIDI_MAP
189         /* map manager */
190         CAAUMIDIMapManager                      *GetMIDIMapManager() {return mMapManager;};
191         
192 #endif
193
194                                                                                                 
195 private:
196         /*! @var mAUBaseInstance */
197         AUBase                                          & mAUBaseInstance;
198         
199 #if CA_AUTO_MIDI_MAP
200         /* map manager */
201         CAAUMIDIMapManager                      * mMapManager;
202 #endif
203         
204 public:
205 #if !CA_USE_AUDIO_PLUGIN_ONLY
206         // component dispatcher
207         /*! @method ComponentEntryDispatch */
208         static OSStatus                 ComponentEntryDispatch( ComponentParameters             *params,
209                                                                                                                 AUMIDIBase                                      *This);
210 #endif
211 };
212
213 #endif // __AUMIDIBase_h__