Remove erroneous assert which I added earlier.
[ardour2.git] / libs / appleutility / CAAUParameter.h
blob4f35b2635307309e52fa7ee8e2dd448ac44d9fd4
1 /* Copyright: © Copyright 2005 Apple Computer, Inc. All rights reserved.
3 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
4 ("Apple") in consideration of your agreement to the following terms, and your
5 use, installation, modification or redistribution of this Apple software
6 constitutes acceptance of these terms. If you do not agree with these terms,
7 please do not use, install, modify or redistribute this Apple software.
9 In consideration of your agreement to abide by the following terms, and subject
10 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
11 copyrights in this original Apple software (the "Apple Software"), to use,
12 reproduce, modify and redistribute the Apple Software, with or without
13 modifications, in source and/or binary forms; provided that if you redistribute
14 the Apple Software in its entirety and without modifications, you must retain
15 this notice and the following text and disclaimers in all such redistributions of
16 the Apple Software. Neither the name, trademarks, service marks or logos of
17 Apple Computer, Inc. may be used to endorse or promote products derived from the
18 Apple Software without specific prior written permission from Apple. Except as
19 expressly stated in this notice, no other rights or licenses, express or implied,
20 are granted by Apple herein, including but not limited to any patent rights that
21 may be infringed by your derivative works or by other works in which the Apple
22 Software may be incorporated.
24 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
25 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28 COMBINATION WITH YOUR PRODUCTS.
30 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 /*=============================================================================
39 CAAUParameter.h
41 =============================================================================*/
43 #ifndef __CAAUParameter_h__
44 #define __CAAUParameter_h__
46 #include <AudioToolbox/AudioUnitUtilities.h>
48 // ____________________________________________________________________________
49 // CAAUParameter
50 // complete parameter specification
51 /*! @class CAAUParameter */
52 class CAAUParameter : public AudioUnitParameter {
53 public:
54 /*! @ctor CAAUParameter.0 */
55 CAAUParameter();
56 /*! @ctor CAAUParameter.1 */
57 CAAUParameter(AudioUnit au, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement element);
58 /*! @ctor CAAUParameter.2 */
59 CAAUParameter(AudioUnitParameter &inParam);
60 /*! @ctor CAAUParameter.3 */
61 CAAUParameter(const CAAUParameter &a);
62 /*! @dtor ~CAAUParameter */
63 ~CAAUParameter();
65 /*! @method operator <@ */
66 bool operator < (const CAAUParameter &a) const
68 return memcmp(this, &a, sizeof(AudioUnitParameter)) < 0;
71 /*! @method operator ==@ */
72 bool operator == (const CAAUParameter &a) const
74 return !memcmp(this, &a, sizeof(AudioUnitParameter));
77 /*! @method operator =@ */
78 CAAUParameter & operator = (const CAAUParameter &a);
80 /*! @method GetValue */
81 Float32 GetValue() const;
82 /*! @method SetValue */
83 void SetValue( AUParameterListenerRef inListener,
84 void * inObject,
85 Float32 inValue) const;
87 /*! @method GetName */
88 CFStringRef GetName() const { return mParamName; }
89 // borrowed reference!
91 /*! @method GetStringFromValueCopy */
92 CFStringRef GetStringFromValueCopy(const Float32 *value = NULL) const;
93 // returns a copy of the name of the current parameter value
94 // or null if there is no name associated
95 // caller must release
96 /*! @method ValuesHaveStrings */
97 bool ValuesHaveStrings () const
99 return (mParamInfo.flags & kAudioUnitParameterFlag_ValuesHaveStrings) != 0;
102 /*! @method GetValueFromString */
103 Float32 GetValueFromString (CFStringRef str) const;
104 // caller must release
106 /*! @method ParamInfo */
107 const AudioUnitParameterInfo &
108 ParamInfo() const { return mParamInfo; }
110 /*! @method GetParamTag */
111 CFStringRef GetParamTag() const { return mParamTag; }
112 // this may return null! -
113 // in which case there is no descriptive tag for the parameter
115 /*! @method GetParamName */
116 CFStringRef GetParamName (int inIndex) const
117 // this can return null if there is no name for the parameter
119 return (mNamedParams && inIndex < mNumIndexedParams)
120 ? (CFStringRef) CFArrayGetValueAtIndex(mNamedParams, inIndex)
121 : 0;
124 /*! @method GetNumIndexedParams */
125 int GetNumIndexedParams () const { return mNumIndexedParams; }
127 /*! @method IsIndexedParam */
128 bool IsIndexedParam () const { return mNumIndexedParams != 0; }
130 /*! @method HasNamedParams */
131 bool HasNamedParams () const { return IsIndexedParam() && mNamedParams; }
133 /*! @method GetClumpID */
134 bool GetClumpID (UInt32 &outClumpID) const
136 if (mParamInfo.flags & kAudioUnitParameterFlag_HasClump) {
137 outClumpID = mParamInfo.clumpID;
138 return true;
140 return false;
143 /*! @method HasDisplayTransformation */
144 bool HasDisplayTransformation () const
146 return GetAudioUnitParameterDisplayType (mParamInfo.flags);
149 /*! @method IsExpert */
150 bool IsExpert () const
152 return mParamInfo.flags & kAudioUnitParameterFlag_ExpertMode;
154 #if DEBUG
155 void Print () const;
156 #endif
158 // these methods are defined in CAPersistence.cpp
159 // they will persist and restore only the scope, element and param ID's of the AudioUnitParameter
160 // however, this is sufficient to be able to save/restore a CAAUParameter object
161 void Save (CFPropertyListRef &outData) const;
163 static void Save (const AudioUnitParameter &inParam, CFPropertyListRef &outData);
165 static OSStatus Restore (const CFPropertyListRef inData, AudioUnitParameter &outParam);
167 protected:
168 // cached parameter info
169 /*! @var mParamInfo */
170 AudioUnitParameterInfo mParamInfo;
171 /*! @var mParamName */
172 CFStringRef mParamName;
173 /*! @var mParamTag */
174 CFStringRef mParamTag;
175 /*! @var mNumIndexedParams */
176 short mNumIndexedParams;
177 /*! @var mNamedParams */
178 CFArrayRef mNamedParams;
180 private:
181 void Init (AudioUnit au, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement element);
187 #endif // __CAAUParameter_h__