3 Abstract: Part of CoreAudio Utility Classes
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.
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.
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.
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.
44 Copyright (C) 2014 Apple Inc. All Rights Reserved.
47 #ifndef __CAAUParameter_h__
48 #define __CAAUParameter_h__
50 #include <AudioToolbox/AudioUnitUtilities.h>
52 // ____________________________________________________________________________
54 // complete parameter specification
55 /*! @class CAAUParameter */
56 class CAAUParameter : public AudioUnitParameter {
58 /*! @ctor CAAUParameter.0 */
60 /*! @ctor CAAUParameter.1 */
61 CAAUParameter(AudioUnit au, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement element);
62 /*! @ctor CAAUParameter.2 */
63 CAAUParameter(AudioUnitParameter &inParam);
64 /*! @ctor CAAUParameter.3 */
65 CAAUParameter(const CAAUParameter &a);
66 /*! @dtor ~CAAUParameter */
69 /*! @method operator <@ */
70 bool operator < (const CAAUParameter &a) const
72 return memcmp(this, &a, sizeof(AudioUnitParameter)) < 0;
75 /*! @method operator ==@ */
76 bool operator == (const CAAUParameter &a) const
78 return !memcmp(this, &a, sizeof(AudioUnitParameter));
81 /*! @method operator =@ */
82 CAAUParameter & operator = (const CAAUParameter &a);
84 /*! @method GetValue */
85 Float32 GetValue() const;
86 /*! @method SetValue */
87 void SetValue( AUParameterListenerRef inListener,
89 Float32 inValue) const;
91 /*! @method GetName */
92 CFStringRef GetName() const { return mParamName; }
93 // borrowed reference!
95 /*! @method GetStringFromValueCopy */
96 CFStringRef GetStringFromValueCopy(const Float32 *value = NULL) const;
97 // returns a copy of the name of the current parameter value
98 // or null if there is no name associated
99 // caller must release
100 /*! @method ValuesHaveStrings */
101 bool ValuesHaveStrings () const
103 return (mParamInfo.flags & kAudioUnitParameterFlag_ValuesHaveStrings) != 0;
106 /*! @method GetValueFromString */
107 Float32 GetValueFromString (CFStringRef str) const;
108 // caller must release
110 /*! @method ParamInfo */
111 const AudioUnitParameterInfo &
112 ParamInfo() const { return mParamInfo; }
114 /*! @method GetParamTag */
115 CFStringRef GetParamTag() const { return mParamTag; }
116 // this may return null! -
117 // in which case there is no descriptive tag for the parameter
119 /*! @method GetParamName */
120 CFStringRef GetParamName (int inIndex) const
121 // this can return null if there is no name for the parameter
123 return (mNamedParams && inIndex < mNumIndexedParams)
124 ? (CFStringRef) CFArrayGetValueAtIndex(mNamedParams, inIndex)
128 /*! @method GetNumIndexedParams */
129 int GetNumIndexedParams () const { return mNumIndexedParams; }
131 /*! @method IsIndexedParam */
132 bool IsIndexedParam () const { return mNumIndexedParams != 0; }
134 /*! @method HasNamedParams */
135 bool HasNamedParams () const { return IsIndexedParam() && mNamedParams; }
137 /*! @method GetClumpID */
138 bool GetClumpID (UInt32 &outClumpID) const
140 if (mParamInfo.flags & kAudioUnitParameterFlag_HasClump) {
141 outClumpID = mParamInfo.clumpID;
147 /*! @method HasDisplayTransformation */
148 bool HasDisplayTransformation () const
150 return GetAudioUnitParameterDisplayType (mParamInfo.flags);
153 /*! @method IsExpert */
154 bool IsExpert () const
156 return mParamInfo.flags & kAudioUnitParameterFlag_ExpertMode;
162 // these methods are defined in CAPersistence.cpp
163 // they will persist and restore only the scope, element and param ID's of the AudioUnitParameter
164 // however, this is sufficient to be able to save/restore a CAAUParameter object
165 void Save (CFPropertyListRef &outData) const;
167 static void Save (const AudioUnitParameter &inParam, CFPropertyListRef &outData);
169 static OSStatus Restore (const CFPropertyListRef inData, AudioUnitParameter &outParam);
172 // cached parameter info
173 /*! @var mParamInfo */
174 AudioUnitParameterInfo mParamInfo;
175 /*! @var mParamName */
176 CFStringRef mParamName;
177 /*! @var mParamTag */
178 CFStringRef mParamTag;
179 /*! @var mNumIndexedParams */
180 short mNumIndexedParams;
181 /*! @var mNamedParams */
182 CFArrayRef mNamedParams;
185 void Init (AudioUnit au, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement element);
191 #endif // __CAAUParameter_h__