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