|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Group for equalizer controls |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAMMSEQUALIZERCONTROLGROUP_H |
|
20 #define CAMMSEQUALIZERCONTROLGROUP_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "cammseffectcontrolgroup.h" |
|
25 #include <AudioEqualizerData.h> |
|
26 |
|
27 // CONSTANTS |
|
28 _LIT(KAMMSEqualizerControlClassName, |
|
29 ".amms.control.audioeffect.EqualizerControl"); |
|
30 |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CAMMSBaseEqualizerControl; |
|
34 class CAudioEqualizerUtility; |
|
35 |
|
36 |
|
37 // CLASS DECLARATION |
|
38 /** |
|
39 * Group for equalizer controls |
|
40 * |
|
41 * @since 3.0 |
|
42 */ |
|
43 NONSHARABLE_CLASS(CAMMSEqualizerControlGroup): public CAMMSEffectControlGroup |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 */ |
|
50 static CAMMSEqualizerControlGroup* NewLC(); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 ~CAMMSEqualizerControlGroup(); |
|
56 |
|
57 public: // New functions |
|
58 /** |
|
59 * Gets the band that has the most effect on the given frequency |
|
60 * |
|
61 * @param aFrequency The frequency in milliHertz which is |
|
62 * to be equalized via the returned band |
|
63 * |
|
64 * @return The frequency band that has most effect on the given |
|
65 * frequency or -1 if no band has effect on the given frequency |
|
66 */ |
|
67 TInt Band(TInt aFrequency); |
|
68 |
|
69 /** |
|
70 * Gets the gain set for the given equalizer band. |
|
71 * |
|
72 * @param aBand The frequency band whose gain is asked. |
|
73 * @param aBandLevel The returned level for the given band in millibels. |
|
74 * |
|
75 */ |
|
76 void GetBandLevelL(TInt aBand, TInt& aBandLevel); |
|
77 |
|
78 /** |
|
79 * Gets the bass level. |
|
80 * |
|
81 * @return The current level that is set to the bass band. If the |
|
82 * bass level cannot been defined EqualizerControl.UNDEFINED will |
|
83 * be returned |
|
84 */ |
|
85 TInt Bass(); |
|
86 |
|
87 /** |
|
88 * Gets the center frequency of the given band |
|
89 * |
|
90 * @param aBand The frequency band whose center frequency |
|
91 * is asked. |
|
92 * @param aCenterFreq The returned center frequency in milliHertz. |
|
93 */ |
|
94 void GetCenterFreqL(TInt aBand, TInt& aCenterFreq); |
|
95 |
|
96 /** |
|
97 * Returns the maximum band level supported |
|
98 * |
|
99 * @return the maximum band level supported |
|
100 */ |
|
101 TInt MaxBandLevel(); |
|
102 |
|
103 /** |
|
104 * Returns the minimum band level supported. |
|
105 * |
|
106 * @return the minimum band level supported. |
|
107 */ |
|
108 TInt MinBandLevel(); |
|
109 |
|
110 /** |
|
111 * Gets the number of frequency bands that the equalizer supports. |
|
112 * |
|
113 * @return the number of frequency bands that the equalizer supports. |
|
114 */ |
|
115 TInt NumberOfBands(); |
|
116 |
|
117 /** |
|
118 * Gets the treble level. |
|
119 * |
|
120 * @return The current level that is set to the treble band. If the |
|
121 * treble level cannot been defined EqualizerControl.UNDEFINED will |
|
122 * be returned |
|
123 */ |
|
124 TInt Treble(); |
|
125 |
|
126 /** |
|
127 * Sets the given equalizer band to the given gain value. |
|
128 * |
|
129 * @param aLevel The new gain in millibels that will be set to the |
|
130 * given band |
|
131 * @param aBand The frequency band that will have the new gain |
|
132 */ |
|
133 void SetBandLevelL(TInt aLevel, TInt aBand); |
|
134 |
|
135 /** |
|
136 * Sets the bass level using a linear point scale with values between |
|
137 * 0 and 100: a value of 0 applies the maximum available attenuation |
|
138 * to frequencies in the bass band; a value of 50 gives a flat |
|
139 * equalization of the bass band; and a value of 100 applies the |
|
140 * maximum available amplification to frequencies in the bass band. |
|
141 * |
|
142 * @param aLevel The new level on a linear point scale that will |
|
143 * be set to the bass band |
|
144 * @param aSetLevel Returned level that was actually set |
|
145 */ |
|
146 void SetBassL(TInt aLevel, TInt& aSetLevel); |
|
147 |
|
148 /** |
|
149 * Sets the treble level using a linear point scale with values between |
|
150 * 0 and 100: a value of 0 applies the maximum available attenuation to |
|
151 * frequencies in the treble band; a value of 50 gives a flat |
|
152 * equalization of the treble band; and a value of 100 applies the |
|
153 * maximum available amplification to frequencies in the treble band |
|
154 * |
|
155 * @param aLevel The new level on a linear point scale that will |
|
156 * be set to the treble band |
|
157 * |
|
158 * @param aSetLevel Returned level that was actually set |
|
159 */ |
|
160 void SetTrebleL(TInt aLevel, TInt& aSetLevel); |
|
161 |
|
162 private: // New functions |
|
163 /** |
|
164 * Gets control. Ownership is not tranferred. |
|
165 * |
|
166 * @param aIndex Control index. |
|
167 */ |
|
168 CAMMSBaseEqualizerControl* TypeSafeControl(TInt aIndex) const; |
|
169 |
|
170 /** |
|
171 * Checks whether the band index is between 0 and number of bands -1. |
|
172 * Function leaves with KErrArgument if the band is not between the |
|
173 * limits. |
|
174 */ |
|
175 void CheckBandIndexL(TInt aBand) const; |
|
176 |
|
177 /** |
|
178 * Gets bands corresponding to the given preset index. |
|
179 * The data is obtained from controls (or from empty group utility, if the |
|
180 * group has no controls). |
|
181 * @param aPresetIndex Index of the preset whose bands are asked |
|
182 * @param aBands Returned bands |
|
183 */ |
|
184 void GetPresetBandsL(TUint aPresetIndex, |
|
185 RArray< TEfAudioEqualizerBand >& aBands); |
|
186 |
|
187 public: // Functions from base classes |
|
188 /** |
|
189 * Returns class name that identifies this control group. |
|
190 * |
|
191 * @return Control group name. |
|
192 */ |
|
193 const TDesC16& ClassName(); |
|
194 |
|
195 protected: // Functions from base classes |
|
196 /** |
|
197 * Called by when a new player is added |
|
198 * |
|
199 * @param aPlayer The player being added |
|
200 * @param aControl The player's control relevant to this group |
|
201 */ |
|
202 void NotifyPlayerAddedL(CMMAPlayer *aPlayer, CMMAControl* aControl); |
|
203 |
|
204 /** |
|
205 * Called when the current preset changes |
|
206 */ |
|
207 void PresetChangedL(); |
|
208 |
|
209 /** |
|
210 * Finish initialization (after the 1st player is added) |
|
211 */ |
|
212 void InitializeL(); |
|
213 |
|
214 /** |
|
215 * Creates utilities that can be used to obtain preset names |
|
216 * and preset data (needed when the group has no controls). |
|
217 * Does nothing if the utility already exists. |
|
218 */ |
|
219 void PrepareEmptyGroupUtilitiesL(); |
|
220 |
|
221 /** |
|
222 * Deletes utilities that are used to obtain preset names |
|
223 * and preset data (needed when the group has no controls). |
|
224 * Does nothing if the utilities have already been deleted. |
|
225 */ |
|
226 void DeleteEmptyGroupUtilities(); |
|
227 |
|
228 /** |
|
229 * Gets list of preset names available. |
|
230 * @param aPresetNames Returned preset names |
|
231 */ |
|
232 void GetPresetNamesL(CDesCArray& aPresetNames); |
|
233 |
|
234 protected: |
|
235 /** |
|
236 * C++ default constructor. |
|
237 */ |
|
238 CAMMSEqualizerControlGroup(); |
|
239 |
|
240 /** |
|
241 * By default Symbian 2nd phase constructor is private. |
|
242 */ |
|
243 void ConstructL(); |
|
244 |
|
245 private: // data |
|
246 |
|
247 // Needed to get preset names when the group has no controls. |
|
248 CAudioEqualizerUtility* iEmptyAudioEqualizerUtility; // Owned. |
|
249 |
|
250 RArray< TEfAudioEqualizerBand > iBands; |
|
251 TInt iBass; // bass level |
|
252 TInt iTreble; // treble level |
|
253 TInt iMaxBandLevel; |
|
254 TInt iMinBandLevel; |
|
255 }; |
|
256 |
|
257 #endif // CAMMSEQUALIZERCONTROLGROUP_H |
|
258 |
|
259 |