os/mm/devsoundextensions/effectspresets/EnvironmentalReverbUtility/src/EnvironmentalReverbUtility.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Utility to Access the EnvironmentalReverb Effect
22 #include <EnvironmentalReverbUtility.h>
23 #include <DrmAudioSamplePlayer.h>
24 #include "TempEnvironmentalReverb.h"
25 #include "EnvironmentalReverbUtilityInternalCRKeys.h"
26 #include <videoplayer.h>
28 // ============================ MEMBER FUNCTIONS ===============================
30 // -----------------------------------------------------------------------------
31 // CEnvironmentalReverbUtility::CEnvironmentalReverbUtility
32 // C++ default constructor can NOT contain any code, that
34 // -----------------------------------------------------------------------------
36 CEnvironmentalReverbUtility::CEnvironmentalReverbUtility()
37 : iEnvironmentalReverb(NULL),
38 iPresetRepository(NULL)
44 CEnvironmentalReverbUtility::~CEnvironmentalReverbUtility()
47 iFullPresetArray.Close();
48 delete iPresetRepository;
49 delete iTransEnvironmentalReverb;
50 delete iEnvironmentalReverb;
54 // -----------------------------------------------------------------------------
55 // CEnvironmentalReverbUtility::ConstructL
56 // Symbian 2nd phase constructor can leave.
57 // -----------------------------------------------------------------------------
59 void CEnvironmentalReverbUtility::ConstructL(CMMFDevSound& aDevSound)
62 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
64 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aDevSound);
65 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
66 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
67 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
68 UpdatePresetArray(iPresetArray,iFullPresetArray);
69 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
73 // -----------------------------------------------------------------------------
74 // CEnvironmentalReverbUtility::ConstructL
75 // Symbian 2nd phase constructor can leave.
76 // -----------------------------------------------------------------------------
78 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioConvertUtility& aUtility)
81 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
83 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
84 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
85 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
86 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
87 UpdatePresetArray(iPresetArray,iFullPresetArray);
88 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
91 // -----------------------------------------------------------------------------
92 // CEnvironmentalReverbUtility::ConstructL
93 // Symbian 2nd phase constructor can leave.
94 // -----------------------------------------------------------------------------
96 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioInputStream& aUtility)
99 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
101 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
102 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
103 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
104 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
105 UpdatePresetArray(iPresetArray,iFullPresetArray);
106 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
109 // -----------------------------------------------------------------------------
110 // CEnvironmentalReverbUtility::ConstructL
111 // Symbian 2nd phase constructor can leave.
112 // -----------------------------------------------------------------------------
114 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioOutputStream& aUtility)
117 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
119 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
120 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
121 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
122 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
123 UpdatePresetArray(iPresetArray,iFullPresetArray);
124 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
127 // -----------------------------------------------------------------------------
128 // CEnvironmentalReverbUtility::ConstructL
129 // Symbian 2nd phase constructor can leave.
130 // -----------------------------------------------------------------------------
132 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioPlayerUtility& aUtility)
135 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
137 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
138 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
139 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
140 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
141 UpdatePresetArray(iPresetArray,iFullPresetArray);
142 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
145 // -----------------------------------------------------------------------------
146 // CEnvironmentalReverbUtility::ConstructL
147 // Symbian 2nd phase constructor can leave.
148 // -----------------------------------------------------------------------------
150 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioRecorderUtility& aUtility )
153 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
155 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility,ETrue);
156 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
157 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
158 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
159 UpdatePresetArray(iPresetArray,iFullPresetArray);
160 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
163 // -----------------------------------------------------------------------------
164 // CEnvironmentalReverbUtility::ConstructL
165 // Symbian 2nd phase constructor can leave.
166 // -----------------------------------------------------------------------------
168 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioToneUtility& aUtility)
171 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
173 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
174 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
175 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
176 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
177 UpdatePresetArray(iPresetArray,iFullPresetArray);
178 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
181 // -----------------------------------------------------------------------------
182 // CEnvironmentalReverbUtility::ConstructL
183 // Symbian 2nd phase constructor can leave.
184 // -----------------------------------------------------------------------------
186 void CEnvironmentalReverbUtility::ConstructL(CCustomCommandUtility* aUtility)
189 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
191 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
192 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
193 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
194 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
195 UpdatePresetArray(iPresetArray,iFullPresetArray);
196 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
199 // -----------------------------------------------------------------------------
200 // CEnvironmentalReverbUtility::ConstructL
201 // Symbian 2nd phase constructor can leave.
202 // -----------------------------------------------------------------------------
204 void CEnvironmentalReverbUtility::ConstructL(MCustomInterface& aCustomInterface)
207 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
209 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aCustomInterface);
210 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
211 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
212 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
213 UpdatePresetArray(iPresetArray,iFullPresetArray);
214 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
218 // -----------------------------------------------------------------------------
219 // CEnvironmentalReverbUtility::ConstructL
220 // Symbian 2nd phase constructor can leave.
221 // -----------------------------------------------------------------------------
223 void CEnvironmentalReverbUtility::ConstructL(CMidiClientUtility& aUtility)
226 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
228 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
229 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
230 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
231 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
232 UpdatePresetArray(iPresetArray,iFullPresetArray);
233 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
236 // -----------------------------------------------------------------------------
237 // CEnvironmentalReverbUtility::ConstructL
238 // Symbian 2nd phase constructor can leave.
239 // -----------------------------------------------------------------------------
241 void CEnvironmentalReverbUtility::ConstructL(CDrmPlayerUtility& aUtility)
244 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
246 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
247 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
248 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
249 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
250 UpdatePresetArray(iPresetArray,iFullPresetArray);
251 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
254 // -----------------------------------------------------------------------------
255 // CEnvironmentalReverbUtility::ConstructL
256 // Symbian 2nd phase constructor can leave.
257 // -----------------------------------------------------------------------------
259 void CEnvironmentalReverbUtility::ConstructL(CVideoPlayerUtility& aUtility)
262 RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
264 iEnvironmentalReverb = CEnvironmentalReverb::NewL(aUtility);
265 iTransEnvironmentalReverb = CTempEnvironmentalReverb::NewL(iEnvironmentalReverb);
266 iPresetRepository = CRepository::NewL(KCRUidEnvironmentalReverbUtilityPresets);
267 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
268 UpdatePresetArray(iPresetArray,iFullPresetArray);
269 iTransEnvironmentalReverb->SetEffectData(iEnvironmentalReverb->DoEffectData());
272 // -----------------------------------------------------------------------------
273 // CEnvironmentalReverbUtility::NewL
274 // Two-phased constructor.
275 // -----------------------------------------------------------------------------
277 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMMFDevSound& aDevSound)
280 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
282 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
283 CleanupStack::PushL( self );
284 self->ConstructL(aDevSound);
285 CleanupStack::Pop(self);
290 // -----------------------------------------------------------------------------
291 // CEnvironmentalReverbUtility::NewL
292 // Two-phased constructor.
293 // -----------------------------------------------------------------------------
295 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioConvertUtility& aUtility)
298 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
300 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
301 CleanupStack::PushL( self );
302 self->ConstructL(aUtility);
303 CleanupStack::Pop(self);
308 // -----------------------------------------------------------------------------
309 // CEnvironmentalReverbUtility::NewL
310 // Two-phased constructor.
311 // -----------------------------------------------------------------------------
313 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioInputStream& aUtility)
316 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
318 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
319 CleanupStack::PushL( self );
320 self->ConstructL(aUtility);
321 CleanupStack::Pop(self);
326 // -----------------------------------------------------------------------------
327 // CEnvironmentalReverbUtility::NewL
328 // Two-phased constructor.
329 // -----------------------------------------------------------------------------
331 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioOutputStream& aUtility)
334 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
336 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
337 CleanupStack::PushL( self );
338 self->ConstructL(aUtility);
339 CleanupStack::Pop(self);
344 // -----------------------------------------------------------------------------
345 // CEnvironmentalReverbUtility::NewL
346 // Two-phased constructor.
347 // -----------------------------------------------------------------------------
349 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioPlayerUtility& aUtility)
352 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
354 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
355 CleanupStack::PushL( self );
356 self->ConstructL(aUtility);
357 CleanupStack::Pop(self);
362 // -----------------------------------------------------------------------------
363 // CEnvironmentalReverbUtility::NewL
364 // Two-phased constructor.
365 // -----------------------------------------------------------------------------
367 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioRecorderUtility& aUtility)
370 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
372 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
373 CleanupStack::PushL( self );
374 self->ConstructL(aUtility);
375 CleanupStack::Pop(self);
380 // -----------------------------------------------------------------------------
381 // CEnvironmentalReverbUtility::NewL
382 // Two-phased constructor.
383 // -----------------------------------------------------------------------------
385 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioToneUtility& aUtility)
388 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
390 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
391 CleanupStack::PushL( self );
392 self->ConstructL(aUtility);
393 CleanupStack::Pop(self);
398 // -----------------------------------------------------------------------------
399 // CEnvironmentalReverbUtility::NewL
400 // Two-phased constructor.
401 // -----------------------------------------------------------------------------
403 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CCustomCommandUtility* aUtility)
406 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
408 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
409 CleanupStack::PushL( self );
410 self->ConstructL(aUtility);
411 CleanupStack::Pop(self);
416 // -----------------------------------------------------------------------------
417 // CEnvironmentalReverbUtility::NewL
418 // Two-phased constructor.
419 // -----------------------------------------------------------------------------
421 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(MCustomInterface& aCustomInterface)
424 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
426 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
427 CleanupStack::PushL( self );
428 self->ConstructL(aCustomInterface);
429 CleanupStack::Pop(self);
435 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMidiClientUtility& aUtility)
438 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
440 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
441 CleanupStack::PushL( self );
442 self->ConstructL(aUtility);
443 CleanupStack::Pop(self);
447 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CDrmPlayerUtility& aUtility)
450 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
452 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
453 CleanupStack::PushL( self );
454 self->ConstructL(aUtility);
455 CleanupStack::Pop(self);
459 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CVideoPlayerUtility& aUtility)
462 RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
464 CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
465 CleanupStack::PushL( self );
466 self->ConstructL(aUtility);
467 CleanupStack::Pop(self);
471 // -----------------------------------------------------------------------------
472 // CEnvironmentalReverbUtility::ApplyPresetL()
473 // Applies the Preset to the EnvironmentalReverb Object
474 // (other items were commented in a header).
475 // -----------------------------------------------------------------------------
477 EXPORT_C void CEnvironmentalReverbUtility::ApplyPresetL(
481 RDebug::Print(_L("CEnvironmentalReverbUtility::ApplyPresetL"));
483 // Get the Preset from the Central Repository
484 // and Apply it to the EnvironmentalReverb Object
485 // using SetBandData method. After that Just Enable() the Effect
487 TBuf8<256> aDescription;
489 TBool presetFound = EFalse;
491 if(aPresetIndex > (iPresetArray.Count() - 1))
492 User::Leave(KErrArgument);
494 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
496 // Write the EnvironmentalReverb Data in the first available NULL Space
497 for( TInt j = 0; j < iFullPresetArray.Count();j++)
499 if( (iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey) &&
500 (iFullPresetArray[j].iPresetName.Length()))
502 iPresetRepository->Get(iFullPresetArray[j].iPresetDescriptionKey,aDescription);
506 iEnvironmentalReverb->SetEffectData(aDes);
508 // Applying the Settings to the Audio EnvironmentalReverb
509 // iEnvironmentalReverb->ApplyL();
511 iEnvironmentalReverb->EnableL();
519 User::Leave(KErrNotFound);
522 // -----------------------------------------------------------------------------
523 // CEnvironmentalReverbUtility::CreatePresetL(TDesC& aName,CEnvironmentalReverb& aEnvironmentalReverb)
524 // Applies the Preset to the EnvironmentalReverb Object
525 // (other items were commented in a header).
526 // -----------------------------------------------------------------------------
529 EXPORT_C void CEnvironmentalReverbUtility:: CreatePresetL(
531 CEnvironmentalReverb& aEnvironmentalReverbUI)
534 RDebug::Print(_L("CEnvironmentalReverbUtility::CreatePresetL"));
536 // Get the Preset from the UI and create a DesC using
537 // DoBandData() method and then store it to the
538 // Central Repository
540 __ASSERT_ALWAYS(aName.Length() > 0,User::Leave(KErrArgument));
543 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
545 iEnvironmentalReverb = &aEnvironmentalReverbUI;
547 //Create New Keys at the End of the Repository
548 TInt currentNumber = 0;
549 // Get the number of User Defined Presets in the Repository
550 iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfUserDefinedPresets,currentNumber);
552 HBufC8* presetHeap = HBufC8::NewL(sizeof(TEfEnvironmentalReverb));
553 TPtr8 des = presetHeap->Des();
554 des.SetLength(presetHeap->Size());
555 des.Append(iEnvironmentalReverb->DoEffectData());
557 // Calculate and Create the EnvironmentalReverb Data for the New Preset
558 iPresetRepository->Create(currentNumber*2+KEnvironmentalReverbUtilityUserDefinedPresetStart,des);
559 // Calculate and create the New Preset Name in the End
560 iPresetRepository->Create(currentNumber*2+KEnvironmentalReverbUtilityUserDefinedPresetStartName,aName);
561 // Update the Number of UserDefined Presets in the End
562 // Since we created new Keys for the Name and the Descriptor
564 iPresetRepository->Set(KEnvironmentalReverbUtilityNumberOfUserDefinedPresets,currentNumber);
565 iPresetRepository->Get(KEnvironmentalReverbUtilityPresetsCounter,currentNumber);
566 iPresetRepository->Set(KEnvironmentalReverbUtilityPresetsCounter,currentNumber + 1);
568 // Refresh the iFullPresetArray
569 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
575 // -----------------------------------------------------------------------------
576 // CEnvironmentalReverbUtility::GetPresetL()
577 // Gets the Preset from the Central Repository
578 // (other items were commented in a header).
579 // -----------------------------------------------------------------------------
581 EXPORT_C const TDesC& CEnvironmentalReverbUtility::GetPresetL(
585 RDebug::Print(_L("CEnvironmentalReverbUtility::GetPresetL"));
587 // Get the Preset from the Central Repository
588 // and Apply it to the EnvironmentalReverb Object
589 // using SetBandData method. After that Just Enable() the Effect
592 if(aPresetIndex > (iPresetArray.Count() - 1))
593 User::Leave(KErrArgument);
595 TBuf8<256> aDescription;
597 TBool presetFound = EFalse;
599 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
601 // Write the EnvironmentalReverb Data in the first available NULL Space
602 for(TInt j = 0; j < iFullPresetArray.Count();j++)
604 if( (iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey) &&
605 (iFullPresetArray[j].iPresetName.Length()))
607 iPresetRepository->Get(iFullPresetArray[j].iPresetDescriptionKey,aDescription);
610 iEnvironmentalReverb->SetEffectData(aDes); // The First Argument should be > 1 for getting all bands
612 return iFullPresetArray[j].iPresetName;
618 User::Leave(KErrNotFound);
626 // -----------------------------------------------------------------------------
627 // CEnvironmentalReverbUtility::DeletePresetL()
628 // Deletes the Preset from the Central Repository
629 // (other items were commented in a header).
630 // -----------------------------------------------------------------------------
632 EXPORT_C void CEnvironmentalReverbUtility::DeletePresetL(
636 RDebug::Print(_L("CEnvironmentalReverbUtility::DeletePresetL"));
638 // Get the Name from the PresetIndex
639 // This Preset Index is from the Array returned to the UI
642 TBool presetFound = EFalse;
645 // Leave if it deletes a predefined preset
646 TInt currentNumberOfPredefinedPresets = 0;
648 // Get the number of User Defined Presets in the Repository
649 iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,currentNumberOfPredefinedPresets);
651 if (aPresetIndex < currentNumberOfPredefinedPresets) //it is a predefined preset,
653 User::Leave(KErrArgument);
657 if(aPresetIndex > (iPresetArray.Count() - 1))
658 User::Leave(KErrArgument);
660 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
661 UpdatePresetArray(iPresetArray,iFullPresetArray);
664 RDebug::RawPrint(iPresetArray[aPresetIndex].iPresetName);
667 // Deletes the Preset from the iFullPresetArray and then
668 // rewrite it to the Central Repository
669 for(TInt j = 0; j < iFullPresetArray.Count();j++)
672 if( (iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey) &&
673 (iFullPresetArray[j].iPresetName.Length()))
677 TRAP(err,iPresetRepository->Set(iFullPresetArray[j].iPresetNameKey,KNullDesC));
678 TRAP(err,iPresetRepository->Set(iFullPresetArray[j].iPresetDescriptionKey,KNullDesC));
685 iFullPresetArray[j].iPresetName.FillZ(0);
686 iFullPresetArray[j].iPresetNameKey = 0;
687 iFullPresetArray[j].iPresetDescriptionKey = 0;
694 RDebug::RawPrint(iFullPresetArray[j].iPresetName);
700 User::Leave(KErrNotFound);
703 // After This Update the iPresetArray for the UI
704 UpdatePresetArray(iPresetArray,iFullPresetArray);
707 // -----------------------------------------------------------------------------
708 // CEnvironmentalReverbUtility::DisablePresetL()
709 // Disable the Preset
710 // (other items were commented in a header).
711 // -----------------------------------------------------------------------------
714 EXPORT_C void CEnvironmentalReverbUtility::DisableEnvironmentalReverbL()
717 RDebug::Print(_L("CEnvironmentalReverbUtility::DisableEnvironmentalReverbL"));
720 if(iEnvironmentalReverb)
722 iEnvironmentalReverb->DisableL();
726 // -----------------------------------------------------------------------------
727 // CEnvironmentalReverbUtility::EnvironmentalReverb()
728 // Applies the Preset to the EnvironmentalReverb Object
729 // (other items were commented in a header).
730 // -----------------------------------------------------------------------------
732 EXPORT_C CEnvironmentalReverb& CEnvironmentalReverbUtility::EnvironmentalReverb()
735 RDebug::Print(_L("CEnvironmentalReverbUtility::EnvironmentalReverb()"));
738 return *iEnvironmentalReverb;
741 // -----------------------------------------------------------------------------
742 // CEnvironmentalReverbUtility::ModifyPresetL()
743 // Applies the Preset to the EnvironmentalReverb Object
744 // (other items were commented in a header).
745 // -----------------------------------------------------------------------------
747 EXPORT_C void CEnvironmentalReverbUtility::ModifyPresetL(
750 CEnvironmentalReverb& aEnvironmentalReverbUI)
753 RDebug::Print(_L("CEnvironmentalReverbUtility::ModifyPresetL"));
756 __ASSERT_ALWAYS(aName.Length() > 0,User::Leave(KErrArgument));
758 // Modifies the Preset Data in the Central Repository
759 // with the updated Name and EnvironmentalReverb Settings for the
762 if(aPresetIndex > (iPresetArray.Count() - 1))
763 User::Leave(KErrArgument);
765 iEnvironmentalReverb = &aEnvironmentalReverbUI;
767 // Write the EnvironmentalReverb Data in the first available NULL Space
768 for( TInt j = 0; j < iFullPresetArray.Count();j++)
770 if( iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey)
772 iPresetRepository->Set(iFullPresetArray[j].iPresetNameKey,aName);
774 HBufC8* presetHeap = HBufC8::NewL(sizeof(TEfEnvironmentalReverb));
775 TPtr8 des = presetHeap->Des();
776 des.SetLength(presetHeap->Size());
777 des.Append(iEnvironmentalReverb->DoEffectData());
779 iPresetRepository->Set(iFullPresetArray[j].iPresetDescriptionKey,des);
785 UpdateFullPresetArrayFromCenRep(iFullPresetArray);
789 // -----------------------------------------------------------------------------
790 // CEnvironmentalReverbUtility::NumberOfPreDefinedPresets()
791 // Applies the Preset to the EnvironmentalReverb Object
792 // (other items were commented in a header).
793 // -----------------------------------------------------------------------------
797 EXPORT_C TUint32 CEnvironmentalReverbUtility::NumberOfPreDefinedPresets() const
800 RDebug::Print(_L("CEnvironmentalReverbUtility::NumberOfPreDefinedPresets"));
803 TInt numberOfPresets;
804 iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,numberOfPresets);
805 return numberOfPresets;
809 // -----------------------------------------------------------------------------
810 // CEnvironmentalReverbUtility::Presets()
811 // Applies the Preset to the EnvironmentalReverb Object
812 // (other items were commented in a header).
813 // -----------------------------------------------------------------------------
815 EXPORT_C TArray<TEfEnvironmentalReverbUtilityPreset> CEnvironmentalReverbUtility::Presets()
818 RDebug::Print(_L("CEnvironmentalReverbUtility::Presets"));
821 // returns all the Presets from the System Defined and
822 // User Defined Preset Array in the Central Repository
823 UpdatePresetArray(iPresetArray,iFullPresetArray);
824 return iPresetArray.Array();
828 // -----------------------------------------------------------------------------
829 // CEnvironmentalReverbUtility::ResetPresetL(TInt aPresetIndex)
830 // Applies the Preset to the EnvironmentalReverb Object
831 // (other items were commented in a header).
832 // -----------------------------------------------------------------------------
834 EXPORT_C void CEnvironmentalReverbUtility::ResetPresetL(TInt aPresetIndex)
837 RDebug::Print(_L("CEnvironmentalReverbUtility::ResetPresetL"));
840 if(aPresetIndex > (iPresetArray.Count() - 1))
841 User::Leave(KErrArgument);
843 TInt currentNumber = 0;
844 // Get the number of System Defined Presets in the Repository
845 iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,currentNumber);
847 if(aPresetIndex >= currentNumber)
848 User::Leave(KErrNotSupported);
851 for( TInt j = 0; j < currentNumber;j++)
853 if( iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey)
855 iPresetRepository->Reset(iFullPresetArray[j].iPresetDescriptionKey);
856 iPresetRepository->Reset(iFullPresetArray[j].iPresetNameKey);
860 UpdatePresetArray(iPresetArray,iFullPresetArray);
864 // -----------------------------------------------------------------------------
865 // CEnvironmentalReverbUtility::UpdatePresetArrayFromCenRep(RArray<TEfEnvironmentalReverbUtilityPreset> &aFullPresetArray)
866 // Updates the Array with the Values in Central Repository
867 // (other items were commented in a header).
868 // -----------------------------------------------------------------------------
871 void CEnvironmentalReverbUtility::UpdateFullPresetArrayFromCenRep(RArray<TEfEnvironmentalReverbUtilityPreset>& aFullPresetArray)
874 aFullPresetArray.Reset();
875 TEfEnvironmentalReverbUtilityPreset tempPreset;
878 TInt numberOfUserDefinedPresets = 0;
879 TInt numberOfPreDefinedPresets = 0;
881 iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfUserDefinedPresets,numberOfUserDefinedPresets);
882 iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,numberOfPreDefinedPresets);
884 for( TInt j = 0; j < (numberOfPreDefinedPresets); j++)
886 tempPreset.iPresetDescriptionKey = KEnvironmentalReverbUtilityPreDefinedPresetStart + (2 * j);
887 tempPreset.iPresetNameKey = KEnvironmentalReverbUtilityPreDefinedPresetStartName + (2 * j);
888 iPresetRepository->Get((KEnvironmentalReverbUtilityPreDefinedPresetStartName + (2 * j)) ,tempPreset.iPresetName);
890 RDebug::RawPrint(tempPreset.iPresetName);
892 aFullPresetArray.Append(tempPreset);
896 for( TInt j = 0; j < (numberOfUserDefinedPresets); j++)
898 tempPreset.iPresetDescriptionKey = KEnvironmentalReverbUtilityUserDefinedPresetStart + (2 * j);
899 tempPreset.iPresetNameKey = KEnvironmentalReverbUtilityUserDefinedPresetStartName + (2 * j);
900 iPresetRepository->Get((KEnvironmentalReverbUtilityUserDefinedPresetStartName + (2 * j)) ,tempPreset.iPresetName);
902 RDebug::RawPrint(tempPreset.iPresetName);
904 aFullPresetArray.Append(tempPreset);
910 // -----------------------------------------------------------------------------
911 // CEnvironmentalReverbUtility::UpdatePresetArray(RArray<TDesC>& aPresetArray,const RArray<TEfEnvironmentalReverbUtilityPreset> &aFullPresetArray)
912 // Creates the Descriptor Array of Names of the Presets Stored in Central Repository
913 // (other items were commented in a header).
914 // -----------------------------------------------------------------------------
916 void CEnvironmentalReverbUtility::UpdatePresetArray(RArray<TEfEnvironmentalReverbUtilityPreset>& aPresetArray,const RArray<TEfEnvironmentalReverbUtilityPreset>& aFullPresetArray)
919 aPresetArray.Reset();
920 TEfEnvironmentalReverbUtilityPreset tempClientArray;
922 // Write the EnvironmentalReverb Data in the first available NULL Space
923 for( TInt j = 0; j < aFullPresetArray.Count();j++)
925 if( aFullPresetArray[j].iPresetName.Length() != 0)
928 tempClientArray.iPresetName = aFullPresetArray[j].iPresetName;
929 tempClientArray.iPresetNameKey = aFullPresetArray[j].iPresetNameKey;
931 aPresetArray.Append(tempClientArray);
934 RDebug::Print(_L("Name Length %d "),aFullPresetArray[j].iPresetName.Length());
935 RDebug::RawPrint(aFullPresetArray[j].iPresetName);
942 // ========================== OTHER EXPORTED FUNCTIONS =========================