1 /* |
|
2 * Copyright (c) 2005-2007 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 reverb controls |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <EnvironmentalReverbUtility.h> |
|
21 #include <EnvironmentalReverbUtilityData.h> |
|
22 #include <logger.h> |
|
23 |
|
24 #include "cammsreverbcontrolgroup.h" |
|
25 #include "cammsbasereverbcontrol.h" |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CAMMSReverbControlGroup::NewLC |
|
32 // Two-phased constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 CAMMSReverbControlGroup* CAMMSReverbControlGroup::NewLC() |
|
35 { |
|
36 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::NewLC +"); |
|
37 |
|
38 CAMMSReverbControlGroup* self = new(ELeave) CAMMSReverbControlGroup; |
|
39 |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 |
|
43 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::NewLC -"); |
|
44 |
|
45 return self; |
|
46 } |
|
47 |
|
48 // Destructor |
|
49 CAMMSReverbControlGroup::~CAMMSReverbControlGroup() |
|
50 { |
|
51 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::~"); |
|
52 |
|
53 delete iEmptyEnvironmentalReverbUtility; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CAMMSReverbControlGroup::ReverbLevel |
|
58 // Gets the gain level of the reverberation |
|
59 // (other items were commented in a header). |
|
60 // ----------------------------------------------------------------------------- |
|
61 TInt CAMMSReverbControlGroup::ReverbLevel() |
|
62 { |
|
63 return iReverbLevel; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CAMMSReverbControlGroup::ReverbTime |
|
68 // Gets the reverberation time, as set either explicitly via |
|
69 // (other items were commented in a header). |
|
70 // ----------------------------------------------------------------------------- |
|
71 TInt CAMMSReverbControlGroup::ReverbTime() |
|
72 { |
|
73 return iReverbTime; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CAMMSReverbControlGroup::SetReverbLevelL |
|
78 // Sets the gain level of the reverberation |
|
79 // (other items were commented in a header). |
|
80 // ----------------------------------------------------------------------------- |
|
81 void CAMMSReverbControlGroup::SetReverbLevelL(TInt aLevel) |
|
82 { |
|
83 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::SetReverbLevelL"); |
|
84 |
|
85 __ASSERT_DEBUG(aLevel <= 0, User::Invariant()); |
|
86 |
|
87 // Set the level between the accepted limits [iReverbMinLevel, |
|
88 // iReverbMaxLevel]. |
|
89 TInt reverbLevel = Min(aLevel, iReverbMaxLevel); |
|
90 reverbLevel = Max(reverbLevel, iReverbMinLevel); |
|
91 |
|
92 // Set reverb level to the controls. |
|
93 TInt count = ControlCount(); |
|
94 for (TInt i = 0; i < count; i++) |
|
95 { |
|
96 TypeSafeControl(i)->SetReverbLevelL(reverbLevel); |
|
97 } |
|
98 |
|
99 // Invalidate current preset and save the new reverb level |
|
100 iPresetIndex = -1; |
|
101 iReverbLevel = reverbLevel; |
|
102 |
|
103 LOG4( EJavaMMAPI, EInfo, "CAMMSReverbControlGroup::SetReverbLevelL, levels: %d, %d, %d %d", |
|
104 aLevel, iReverbMinLevel, iReverbMaxLevel, reverbLevel); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CAMMSReverbControlGroup::SetReverbTimeL |
|
109 // Sets the reverberation time of the reverb |
|
110 // (other items were commented in a header). |
|
111 // ----------------------------------------------------------------------------- |
|
112 void CAMMSReverbControlGroup::SetReverbTimeL(TInt aTime) |
|
113 { |
|
114 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::SetReverbTimeL +"); |
|
115 |
|
116 __ASSERT_DEBUG(aTime >= 0, User::Invariant()); |
|
117 |
|
118 // Set reverb time to controls. |
|
119 TInt count = ControlCount(); |
|
120 for (TInt i = 0; i < count; i++) |
|
121 { |
|
122 TypeSafeControl(i)->SetReverbTimeL(aTime); |
|
123 } |
|
124 |
|
125 // Invalidate current preset and save new reverb time |
|
126 iPresetIndex = -1; |
|
127 iReverbTime = aTime; |
|
128 |
|
129 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::SetReverbTimeL -"); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CAMMSReverbControlGroup::TypeSafeControl |
|
134 // Gets control. Ownership is not tranferred. |
|
135 // (other items were commented in a header). |
|
136 // ----------------------------------------------------------------------------- |
|
137 CAMMSBaseReverbControl* |
|
138 CAMMSReverbControlGroup::TypeSafeControl(TInt aIndex) const |
|
139 { |
|
140 return static_cast<CAMMSBaseReverbControl*>(Control(aIndex)); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CAMMSReverbControlGroup::ClassName |
|
145 // Returns class name that identifies this control group. |
|
146 // (other items were commented in a header). |
|
147 // ----------------------------------------------------------------------------- |
|
148 const TDesC16& CAMMSReverbControlGroup::ClassName() |
|
149 { |
|
150 return KAMMSReverbControlClassName; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CAMMSReverbControlGroup::NotifyPlayerAddedL |
|
155 // Called by when a new player is added |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 void CAMMSReverbControlGroup::NotifyPlayerAddedL( |
|
159 CMMAPlayer *aPlayer, |
|
160 CMMAControl* aControl) |
|
161 { |
|
162 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::NotifyPlayerAddedL +"); |
|
163 |
|
164 CAMMSEffectControlGroup::NotifyPlayerAddedL(aPlayer, aControl); |
|
165 |
|
166 CAMMSBaseReverbControl* control = |
|
167 static_cast<CAMMSBaseReverbControl*>(aControl); |
|
168 |
|
169 // if the preset is not valid, set reverb level and time to the added |
|
170 // control |
|
171 if (iPresetIndex < 0) |
|
172 { |
|
173 control->SetReverbLevelL(iReverbLevel); |
|
174 control->SetReverbTimeL(iReverbTime); |
|
175 } |
|
176 |
|
177 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::NotifyPlayerAddedL -"); |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CAMMSReverbControlGroup::PresetChangedL |
|
182 // Called when the current preset changes |
|
183 // (other items were commented in a header). |
|
184 // ----------------------------------------------------------------------------- |
|
185 void CAMMSReverbControlGroup::PresetChangedL() |
|
186 { |
|
187 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::PresetChangedL +"); |
|
188 |
|
189 TInt count = ControlCount(); |
|
190 |
|
191 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::PresetChangedL, controls=%d", |
|
192 count); |
|
193 |
|
194 // Ask preset data from the first control if exists. If not, ask the |
|
195 // data from the empty group utility. |
|
196 if (count > 0) |
|
197 { |
|
198 CAMMSBaseReverbControl* control = TypeSafeControl(0); |
|
199 |
|
200 iReverbTime = control->ReverbTime(); |
|
201 iReverbLevel = control->ReverbLevel(); |
|
202 iReverbMinLevel = control->MinReverbLevel(); |
|
203 iReverbMaxLevel = control->MaxReverbLevel(); |
|
204 } |
|
205 else |
|
206 { |
|
207 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::PresetChangedL, index=%d", |
|
208 iPresetIndex); |
|
209 |
|
210 __ASSERT_DEBUG(iPresetIndex >= 0, User::Invariant()); |
|
211 |
|
212 // Create empty group utilities for getting preset data. |
|
213 PrepareEmptyGroupUtilitiesL(); |
|
214 |
|
215 // Set the preset to the empty group utility. |
|
216 iEmptyEnvironmentalReverbUtility->GetPresetL(iPresetIndex); |
|
217 |
|
218 CEnvironmentalReverb& audioEffect = |
|
219 iEmptyEnvironmentalReverbUtility->EnvironmentalReverb(); |
|
220 |
|
221 |
|
222 iReverbTime = audioEffect.DecayTime(); |
|
223 iReverbLevel = |
|
224 audioEffect.ReflectionsLevel() + audioEffect.RoomLevel(); |
|
225 |
|
226 TInt32 minLevel; |
|
227 TInt32 maxLevel; |
|
228 audioEffect.ReverbLevelRange(minLevel, maxLevel); |
|
229 |
|
230 iReverbMinLevel = minLevel; |
|
231 iReverbMaxLevel = maxLevel; |
|
232 |
|
233 // Delete empty group utilities in order to save memory. |
|
234 DeleteEmptyGroupUtilities(); |
|
235 } |
|
236 |
|
237 LOG4( EJavaAMMS, EInfo, "CAMMSReverbControlGroup::PresetChangedL, values: %d, %d, %d %d", |
|
238 iReverbTime, iReverbLevel, iReverbMinLevel, iReverbMaxLevel); |
|
239 |
|
240 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::PresetChangedL -"); |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CAMMSReverbControlGroup::InitializeL |
|
245 // Finish initialization (after the 1st player is added) |
|
246 // (other items were commented in a header). |
|
247 // ----------------------------------------------------------------------------- |
|
248 void CAMMSReverbControlGroup::InitializeL() |
|
249 { |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CAMMSReverbControlGroup::PrepareEmptyGroupUtilitiesL |
|
254 // Creates utilities that can be used to obtain preset names and preset data. |
|
255 // (other items were commented in a header). |
|
256 // ----------------------------------------------------------------------------- |
|
257 void CAMMSReverbControlGroup::PrepareEmptyGroupUtilitiesL() |
|
258 { |
|
259 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::PrepareEmptyGroupUtilitiesL +"); |
|
260 |
|
261 if (!iEmptyEnvironmentalReverbUtility) |
|
262 { |
|
263 CAMMSEffectControlGroup::PrepareEmptyGroupUtilitiesL(); |
|
264 |
|
265 iEmptyEnvironmentalReverbUtility = |
|
266 CEnvironmentalReverbUtility::NewL(*iEmptyPlayerUtility); |
|
267 } |
|
268 |
|
269 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::PrepareEmptyGroupUtilitiesL -"); |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CAMMSReverbControlGroup::DeleteEmptyGroupUtilities |
|
274 // Deletes utilities that are used to obtain preset names and preset data. |
|
275 // (other items were commented in a header). |
|
276 // ----------------------------------------------------------------------------- |
|
277 void CAMMSReverbControlGroup::DeleteEmptyGroupUtilities() |
|
278 { |
|
279 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::DeleteEmptyGroupUtilities +"); |
|
280 |
|
281 if (iEmptyPlayerUtility) |
|
282 { |
|
283 delete iEmptyEnvironmentalReverbUtility; |
|
284 iEmptyEnvironmentalReverbUtility = NULL; |
|
285 |
|
286 CAMMSEffectControlGroup::DeleteEmptyGroupUtilities(); |
|
287 } |
|
288 |
|
289 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::DeleteEmptyGroupUtilities -"); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CAMMSReverbControlGroup::GetPresetNamesL |
|
294 // Gets list of preset names available. |
|
295 // (other items were commented in a header). |
|
296 // ----------------------------------------------------------------------------- |
|
297 void CAMMSReverbControlGroup::GetPresetNamesL( |
|
298 CDesCArray& aPresetNames) |
|
299 { |
|
300 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::GetPresetNamesL +"); |
|
301 |
|
302 // Create empty group utilities for getting preset names. |
|
303 PrepareEmptyGroupUtilitiesL(); |
|
304 |
|
305 TArray< TEfEnvironmentalReverbUtilityPreset > presetNames = |
|
306 iEmptyEnvironmentalReverbUtility->Presets(); |
|
307 |
|
308 |
|
309 TInt presetCount = presetNames.Count(); |
|
310 |
|
311 for (TInt i = 0; i < presetCount; i++) |
|
312 { |
|
313 aPresetNames.AppendL(presetNames[ i ].iPresetName); |
|
314 } |
|
315 |
|
316 // Delete empty group utilities in order to save memory. |
|
317 DeleteEmptyGroupUtilities(); |
|
318 |
|
319 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::GetPresetNamesL -"); |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CAMMSReverbControlGroup::CAMMSReverbControlGroup |
|
324 // C++ default constructor can NOT contain any code, that might leave. |
|
325 // ----------------------------------------------------------------------------- |
|
326 CAMMSReverbControlGroup::CAMMSReverbControlGroup() |
|
327 : CAMMSEffectControlGroup(KAMMSBaseReverbControl) |
|
328 { |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CAMMSReverbControlGroup::ConstructL |
|
333 // Symbian 2nd phase constructor can leave. |
|
334 // ----------------------------------------------------------------------------- |
|
335 void CAMMSReverbControlGroup::ConstructL() |
|
336 { |
|
337 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::ConstructL +"); |
|
338 |
|
339 CAMMSEffectControlGroup::BaseConstructL(); |
|
340 |
|
341 TRAPD(err, SetPresetL(KAMMSBaseDefaultReverbPreset)); |
|
342 |
|
343 // The following code prevents build warning. |
|
344 if (err != KErrNone) |
|
345 { |
|
346 ELOG1( EJavaAMMS, "AMMS::CAMMSReverbControlGroup::ConstructL, err %d", err); |
|
347 } |
|
348 |
|
349 // Ignore the error so that using MMA and AMMS is possible. |
|
350 // Error is visible so that "smallroom" preset is not activated. |
|
351 |
|
352 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSReverbControlGroup::ConstructL -"); |
|
353 } |
|
354 |
|
355 // End of File |
|