os/mm/devsoundextensions/effectspresets/EnvironmentalReverbUtility/src/EnvironmentalReverbUtility.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006 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:   Utility to Access the EnvironmentalReverb Effect
    15 *
    16 */
    17 
    18 
    19 
    20 // INCLUDE FILES
    21 #include <e32std.h>
    22 #include <EnvironmentalReverbUtility.h>
    23 #include <DrmAudioSamplePlayer.h>
    24 #include "TempEnvironmentalReverb.h"
    25 #include "EnvironmentalReverbUtilityInternalCRKeys.h"
    26 #include <videoplayer.h>
    27 
    28 // ============================ MEMBER FUNCTIONS ===============================
    29 
    30 // -----------------------------------------------------------------------------
    31 // CEnvironmentalReverbUtility::CEnvironmentalReverbUtility
    32 // C++ default constructor can NOT contain any code, that
    33 // might leave.
    34 // -----------------------------------------------------------------------------
    35 //
    36 CEnvironmentalReverbUtility::CEnvironmentalReverbUtility()
    37 	: iEnvironmentalReverb(NULL),
    38 	  iPresetRepository(NULL)
    39 	{
    40     }
    41 
    42 
    43 // Destructor
    44 CEnvironmentalReverbUtility::~CEnvironmentalReverbUtility()
    45     {
    46 		iPresetArray.Close();
    47 		iFullPresetArray.Close();
    48 		delete iPresetRepository;
    49 		delete iTransEnvironmentalReverb;
    50 		delete iEnvironmentalReverb;
    51     }
    52 
    53 
    54 // -----------------------------------------------------------------------------
    55 // CEnvironmentalReverbUtility::ConstructL
    56 // Symbian 2nd phase constructor can leave.
    57 // -----------------------------------------------------------------------------
    58 //
    59 void CEnvironmentalReverbUtility::ConstructL(CMMFDevSound& aDevSound)
    60     {
    61 #ifdef _DEBUG
    62 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
    63 #endif
    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());
    70     }
    71 
    72 
    73 // -----------------------------------------------------------------------------
    74 // CEnvironmentalReverbUtility::ConstructL
    75 // Symbian 2nd phase constructor can leave.
    76 // -----------------------------------------------------------------------------
    77 //
    78 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioConvertUtility& aUtility)
    79     {
    80 #ifdef _DEBUG
    81 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
    82 #endif
    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());
    89     }
    90 
    91 // -----------------------------------------------------------------------------
    92 // CEnvironmentalReverbUtility::ConstructL
    93 // Symbian 2nd phase constructor can leave.
    94 // -----------------------------------------------------------------------------
    95 //
    96 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioInputStream& aUtility)
    97     {
    98 #ifdef _DEBUG
    99 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   100 #endif
   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());
   107    }
   108 
   109 // -----------------------------------------------------------------------------
   110 // CEnvironmentalReverbUtility::ConstructL
   111 // Symbian 2nd phase constructor can leave.
   112 // -----------------------------------------------------------------------------
   113 //
   114 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioOutputStream& aUtility)
   115     {
   116 #ifdef _DEBUG
   117 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   118 #endif
   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());
   125     }
   126 
   127 // -----------------------------------------------------------------------------
   128 // CEnvironmentalReverbUtility::ConstructL
   129 // Symbian 2nd phase constructor can leave.
   130 // -----------------------------------------------------------------------------
   131 //
   132 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioPlayerUtility& aUtility)
   133     {
   134 #ifdef _DEBUG
   135 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   136 #endif
   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());
   143 	}
   144 
   145 // -----------------------------------------------------------------------------
   146 // CEnvironmentalReverbUtility::ConstructL
   147 // Symbian 2nd phase constructor can leave.
   148 // -----------------------------------------------------------------------------
   149 //
   150 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioRecorderUtility& aUtility )
   151     {
   152 #ifdef _DEBUG
   153 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   154 #endif
   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());
   161    }
   162 
   163 // -----------------------------------------------------------------------------
   164 // CEnvironmentalReverbUtility::ConstructL
   165 // Symbian 2nd phase constructor can leave.
   166 // -----------------------------------------------------------------------------
   167 //
   168 void CEnvironmentalReverbUtility::ConstructL(CMdaAudioToneUtility& aUtility)
   169     {
   170 #ifdef _DEBUG
   171 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   172 #endif
   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());
   179     }
   180 
   181 // -----------------------------------------------------------------------------
   182 // CEnvironmentalReverbUtility::ConstructL
   183 // Symbian 2nd phase constructor can leave.
   184 // -----------------------------------------------------------------------------
   185 //
   186 void CEnvironmentalReverbUtility::ConstructL(CCustomCommandUtility* aUtility)
   187     {
   188 #ifdef _DEBUG
   189 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   190 #endif
   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());
   197     }
   198 
   199 // -----------------------------------------------------------------------------
   200 // CEnvironmentalReverbUtility::ConstructL
   201 // Symbian 2nd phase constructor can leave.
   202 // -----------------------------------------------------------------------------
   203 //
   204 void CEnvironmentalReverbUtility::ConstructL(MCustomInterface& aCustomInterface)
   205     {
   206 #ifdef _DEBUG
   207 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   208 #endif
   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());
   215 
   216     }
   217 
   218 // -----------------------------------------------------------------------------
   219 // CEnvironmentalReverbUtility::ConstructL
   220 // Symbian 2nd phase constructor can leave.
   221 // -----------------------------------------------------------------------------
   222 //
   223 void CEnvironmentalReverbUtility::ConstructL(CMidiClientUtility& aUtility)
   224     {
   225 #ifdef _DEBUG
   226 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   227 #endif
   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());
   234 	}
   235 
   236 // -----------------------------------------------------------------------------
   237 // CEnvironmentalReverbUtility::ConstructL
   238 // Symbian 2nd phase constructor can leave.
   239 // -----------------------------------------------------------------------------
   240 //
   241 void CEnvironmentalReverbUtility::ConstructL(CDrmPlayerUtility& aUtility)
   242     {
   243 #ifdef _DEBUG
   244 		RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   245 #endif
   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());
   252 	}
   253 
   254 // -----------------------------------------------------------------------------
   255 // CEnvironmentalReverbUtility::ConstructL
   256 // Symbian 2nd phase constructor can leave.
   257 // -----------------------------------------------------------------------------
   258 //
   259 void CEnvironmentalReverbUtility::ConstructL(CVideoPlayerUtility& aUtility)
   260     {
   261 #ifdef _DEBUG
   262 		RDebug::Print(_L("CEnvironmentalReverbUtility::ConstructL"));
   263 #endif
   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());
   270 	}
   271 	
   272 // -----------------------------------------------------------------------------
   273 // CEnvironmentalReverbUtility::NewL
   274 // Two-phased constructor.
   275 // -----------------------------------------------------------------------------
   276 //
   277 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMMFDevSound& aDevSound)
   278     {
   279 #ifdef _DEBUG
   280 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   281 #endif
   282 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   283 		CleanupStack::PushL( self );
   284 		self->ConstructL(aDevSound);
   285 		CleanupStack::Pop(self);
   286 		return self;
   287     }
   288 
   289 
   290 // -----------------------------------------------------------------------------
   291 // CEnvironmentalReverbUtility::NewL
   292 // Two-phased constructor.
   293 // -----------------------------------------------------------------------------
   294 //
   295 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioConvertUtility& aUtility)
   296     {
   297 #ifdef _DEBUG
   298 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   299 #endif
   300 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   301 		CleanupStack::PushL( self );
   302 		self->ConstructL(aUtility);
   303 		CleanupStack::Pop(self);
   304 		return self;
   305     }
   306 
   307 
   308 // -----------------------------------------------------------------------------
   309 // CEnvironmentalReverbUtility::NewL
   310 // Two-phased constructor.
   311 // -----------------------------------------------------------------------------
   312 //
   313 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioInputStream& aUtility)
   314     {
   315 #ifdef _DEBUG
   316 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   317 #endif
   318 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   319 		CleanupStack::PushL( self );
   320 		self->ConstructL(aUtility);
   321 		CleanupStack::Pop(self);
   322 		return self;
   323     }
   324 
   325 
   326 // -----------------------------------------------------------------------------
   327 // CEnvironmentalReverbUtility::NewL
   328 // Two-phased constructor.
   329 // -----------------------------------------------------------------------------
   330 //
   331 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioOutputStream& aUtility)
   332     {
   333 #ifdef _DEBUG
   334 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   335 #endif
   336 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   337 		CleanupStack::PushL( self );
   338 		self->ConstructL(aUtility);
   339 		CleanupStack::Pop(self);
   340 		return self;
   341     }
   342 
   343 
   344 // -----------------------------------------------------------------------------
   345 // CEnvironmentalReverbUtility::NewL
   346 // Two-phased constructor.
   347 // -----------------------------------------------------------------------------
   348 //
   349 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioPlayerUtility& aUtility)
   350     {
   351 #ifdef _DEBUG
   352 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   353 #endif
   354 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   355 		CleanupStack::PushL( self );
   356 		self->ConstructL(aUtility);
   357 		CleanupStack::Pop(self);
   358 		return self;
   359     }
   360 
   361 
   362 // -----------------------------------------------------------------------------
   363 // CEnvironmentalReverbUtility::NewL
   364 // Two-phased constructor.
   365 // -----------------------------------------------------------------------------
   366 //
   367 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioRecorderUtility& aUtility)
   368     {
   369 #ifdef _DEBUG
   370 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   371 #endif
   372 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   373 		CleanupStack::PushL( self );
   374 		self->ConstructL(aUtility);
   375 		CleanupStack::Pop(self);
   376 		return self;
   377     }
   378 
   379 
   380 // -----------------------------------------------------------------------------
   381 // CEnvironmentalReverbUtility::NewL
   382 // Two-phased constructor.
   383 // -----------------------------------------------------------------------------
   384 //
   385 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMdaAudioToneUtility& aUtility)
   386     {
   387 #ifdef _DEBUG
   388 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   389 #endif
   390 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   391 		CleanupStack::PushL( self );
   392 		self->ConstructL(aUtility);
   393 		CleanupStack::Pop(self);
   394 		return self;
   395     }
   396 
   397 
   398 // -----------------------------------------------------------------------------
   399 // CEnvironmentalReverbUtility::NewL
   400 // Two-phased constructor.
   401 // -----------------------------------------------------------------------------
   402 //
   403 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CCustomCommandUtility* aUtility)
   404     {
   405 #ifdef _DEBUG
   406 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   407 #endif
   408 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   409 		CleanupStack::PushL( self );
   410 		self->ConstructL(aUtility);
   411 		CleanupStack::Pop(self);
   412 		return self;
   413     }
   414 
   415 
   416 // -----------------------------------------------------------------------------
   417 // CEnvironmentalReverbUtility::NewL
   418 // Two-phased constructor.
   419 // -----------------------------------------------------------------------------
   420 //
   421 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(MCustomInterface& aCustomInterface)
   422     {
   423 #ifdef _DEBUG
   424 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   425 #endif
   426 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   427 		CleanupStack::PushL( self );
   428 		self->ConstructL(aCustomInterface);
   429 		CleanupStack::Pop(self);
   430 		return self;
   431     }
   432 
   433 
   434 
   435 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CMidiClientUtility& aUtility)
   436     {
   437 #ifdef _DEBUG
   438 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   439 #endif
   440 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   441 		CleanupStack::PushL( self );
   442 		self->ConstructL(aUtility);
   443 		CleanupStack::Pop(self);
   444 		return self;
   445     }
   446 
   447 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CDrmPlayerUtility& aUtility)
   448     {
   449 #ifdef _DEBUG
   450 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   451 #endif
   452 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   453 		CleanupStack::PushL( self );
   454 		self->ConstructL(aUtility);
   455 		CleanupStack::Pop(self);
   456 		return self;
   457     }
   458 
   459 EXPORT_C CEnvironmentalReverbUtility* CEnvironmentalReverbUtility::NewL(CVideoPlayerUtility& aUtility)
   460     {
   461 #ifdef _DEBUG
   462 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NewL"));
   463 #endif
   464 		CEnvironmentalReverbUtility* self = new( ELeave ) CEnvironmentalReverbUtility;
   465 		CleanupStack::PushL( self );
   466 		self->ConstructL(aUtility);
   467 		CleanupStack::Pop(self);
   468 		return self;
   469     }
   470     
   471 // -----------------------------------------------------------------------------
   472 // CEnvironmentalReverbUtility::ApplyPresetL()
   473 // Applies the Preset to the EnvironmentalReverb Object
   474 // (other items were commented in a header).
   475 // -----------------------------------------------------------------------------
   476 //
   477 EXPORT_C void CEnvironmentalReverbUtility::ApplyPresetL(
   478     TInt aPresetIndex)
   479     {
   480 #ifdef _DEBUG
   481 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ApplyPresetL"));
   482 #endif
   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
   486 
   487 		TBuf8<256> aDescription;
   488 		TBufC8<256> aDes;
   489 		TBool presetFound = EFalse;
   490 
   491 		if(aPresetIndex > (iPresetArray.Count() - 1))
   492 			User::Leave(KErrArgument);
   493 
   494 		UpdateFullPresetArrayFromCenRep(iFullPresetArray);
   495 
   496 		// Write the EnvironmentalReverb Data in the first available NULL Space
   497 		for( TInt j = 0; j < iFullPresetArray.Count();j++)
   498 			{
   499 				if( (iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey) &&
   500 						(iFullPresetArray[j].iPresetName.Length()))
   501 					{
   502 						iPresetRepository->Get(iFullPresetArray[j].iPresetDescriptionKey,aDescription);
   503 						aDes = aDescription;
   504 					
   505 
   506 						iEnvironmentalReverb->SetEffectData(aDes);
   507 
   508 						// Applying the Settings to the Audio EnvironmentalReverb
   509 					//	iEnvironmentalReverb->ApplyL();
   510 
   511 	                                        iEnvironmentalReverb->EnableL();
   512 
   513 						presetFound =  ETrue;
   514 						break;
   515 					}
   516 			}
   517 
   518 		if(!presetFound)
   519 			User::Leave(KErrNotFound);
   520     }
   521 
   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 // -----------------------------------------------------------------------------
   527 //
   528 
   529 EXPORT_C void CEnvironmentalReverbUtility:: CreatePresetL(
   530     TDesC& aName,
   531     CEnvironmentalReverb& aEnvironmentalReverbUI)
   532     {
   533 #ifdef _DEBUG
   534 		    RDebug::Print(_L("CEnvironmentalReverbUtility::CreatePresetL"));
   535 #endif
   536 		// Get the Preset from the UI and create a DesC using
   537 		// DoBandData() method and then store it to the
   538 		// Central Repository
   539 
   540 		 __ASSERT_ALWAYS(aName.Length() > 0,User::Leave(KErrArgument));
   541 
   542 
   543 		UpdateFullPresetArrayFromCenRep(iFullPresetArray);
   544 
   545 		iEnvironmentalReverb = &aEnvironmentalReverbUI;
   546 
   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);
   551 
   552 		HBufC8* presetHeap = HBufC8::NewL(sizeof(TEfEnvironmentalReverb));
   553 		TPtr8 des = presetHeap->Des();
   554 		des.SetLength(presetHeap->Size());
   555 		des.Append(iEnvironmentalReverb->DoEffectData());
   556 
   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
   563 		currentNumber += 1;
   564 		iPresetRepository->Set(KEnvironmentalReverbUtilityNumberOfUserDefinedPresets,currentNumber);
   565 		iPresetRepository->Get(KEnvironmentalReverbUtilityPresetsCounter,currentNumber);
   566 		iPresetRepository->Set(KEnvironmentalReverbUtilityPresetsCounter,currentNumber + 1);
   567 
   568 		// Refresh the iFullPresetArray
   569 		UpdateFullPresetArrayFromCenRep(iFullPresetArray);
   570 		delete presetHeap;
   571 		presetHeap = NULL;
   572 
   573     }
   574 
   575 // -----------------------------------------------------------------------------
   576 // CEnvironmentalReverbUtility::GetPresetL()
   577 // Gets the Preset from the Central Repository
   578 // (other items were commented in a header).
   579 // -----------------------------------------------------------------------------
   580 //
   581 EXPORT_C const TDesC& CEnvironmentalReverbUtility::GetPresetL(
   582     TInt aPresetIndex)
   583     {
   584 #ifdef _DEBUG
   585 		    RDebug::Print(_L("CEnvironmentalReverbUtility::GetPresetL"));
   586 #endif
   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
   590 
   591 
   592 		if(aPresetIndex > (iPresetArray.Count() - 1))
   593 			User::Leave(KErrArgument);
   594 
   595 		TBuf8<256> aDescription;
   596 		TBufC8<256> aDes;
   597 		TBool presetFound = EFalse;
   598 
   599 		UpdateFullPresetArrayFromCenRep(iFullPresetArray);
   600 
   601 		// Write the EnvironmentalReverb Data in the first available NULL Space
   602 		for(TInt j = 0; j < iFullPresetArray.Count();j++)
   603 			{
   604 				if( (iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey) &&
   605 						(iFullPresetArray[j].iPresetName.Length()))
   606 					{
   607 						iPresetRepository->Get(iFullPresetArray[j].iPresetDescriptionKey,aDescription);
   608 						aDes = aDescription;
   609 
   610 						iEnvironmentalReverb->SetEffectData(aDes); // The First Argument should be > 1 for getting all bands
   611 						presetFound = ETrue;
   612 						return iFullPresetArray[j].iPresetName;
   613 					}
   614 			}
   615 
   616 		if(!presetFound)
   617 		    {		    
   618 			User::Leave(KErrNotFound);
   619 		    }
   620 		    
   621 		return KNullDesC;
   622 
   623     }
   624 
   625 
   626 // -----------------------------------------------------------------------------
   627 // CEnvironmentalReverbUtility::DeletePresetL()
   628 // Deletes the Preset from the Central Repository
   629 // (other items were commented in a header).
   630 // -----------------------------------------------------------------------------
   631 //
   632 EXPORT_C void CEnvironmentalReverbUtility::DeletePresetL(
   633     TInt aPresetIndex)
   634     {
   635 #ifdef _DEBUG
   636 		    RDebug::Print(_L("CEnvironmentalReverbUtility::DeletePresetL"));
   637 #endif
   638 		// Get the Name from the PresetIndex
   639 		// This Preset Index is from the Array returned to the UI
   640 
   641 		TInt err(KErrNone);
   642 		TBool presetFound = EFalse;
   643 
   644 
   645         // Leave if it deletes a predefined preset  
   646 		TInt currentNumberOfPredefinedPresets = 0;
   647 				                
   648 	    // Get the number of User Defined Presets in the Repository
   649 		iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,currentNumberOfPredefinedPresets);
   650 
   651         if (aPresetIndex < currentNumberOfPredefinedPresets)  //it is a predefined preset, 
   652         {
   653 			User::Leave(KErrArgument);        	
   654         }
   655         
   656         
   657 		if(aPresetIndex > (iPresetArray.Count() - 1))
   658 			User::Leave(KErrArgument);
   659 
   660 		UpdateFullPresetArrayFromCenRep(iFullPresetArray);
   661 		UpdatePresetArray(iPresetArray,iFullPresetArray);
   662 
   663 #ifdef _DEBUG
   664 		RDebug::RawPrint(iPresetArray[aPresetIndex].iPresetName);
   665 #endif
   666 
   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++)
   670 			{
   671 
   672 				if( (iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey) &&
   673 						(iFullPresetArray[j].iPresetName.Length()))
   674 					{
   675 					
   676 						presetFound = ETrue;
   677 						TRAP(err,iPresetRepository->Set(iFullPresetArray[j].iPresetNameKey,KNullDesC));
   678 						TRAP(err,iPresetRepository->Set(iFullPresetArray[j].iPresetDescriptionKey,KNullDesC));
   679 						if(err != KErrNone)
   680 							{
   681 								break;
   682 							}
   683 						else
   684 							{
   685 								iFullPresetArray[j].iPresetName.FillZ(0);
   686 								iFullPresetArray[j].iPresetNameKey = 0;
   687 								iFullPresetArray[j].iPresetDescriptionKey = 0;
   688 						        break;
   689 						        
   690 							}
   691 
   692 					}
   693 #ifdef _DEBUG
   694 				RDebug::RawPrint(iFullPresetArray[j].iPresetName);
   695 #endif
   696 			}
   697 
   698 		if(!presetFound)
   699 		    {		    
   700 			User::Leave(KErrNotFound);
   701 		    }
   702 
   703 		// After This Update the iPresetArray for the UI
   704 		UpdatePresetArray(iPresetArray,iFullPresetArray);
   705     }
   706 
   707 // -----------------------------------------------------------------------------
   708 // CEnvironmentalReverbUtility::DisablePresetL()
   709 // Disable the Preset
   710 // (other items were commented in a header).
   711 // -----------------------------------------------------------------------------
   712 //
   713 
   714 EXPORT_C void CEnvironmentalReverbUtility::DisableEnvironmentalReverbL()
   715 {
   716 #ifdef _DEBUG
   717 		    RDebug::Print(_L("CEnvironmentalReverbUtility::DisableEnvironmentalReverbL"));
   718 #endif
   719 
   720 	if(iEnvironmentalReverb)
   721 	{
   722 		iEnvironmentalReverb->DisableL();
   723 	}
   724 }
   725 
   726 // -----------------------------------------------------------------------------
   727 // CEnvironmentalReverbUtility::EnvironmentalReverb()
   728 // Applies the Preset to the EnvironmentalReverb Object
   729 // (other items were commented in a header).
   730 // -----------------------------------------------------------------------------
   731 //
   732 EXPORT_C CEnvironmentalReverb& CEnvironmentalReverbUtility::EnvironmentalReverb()
   733     {
   734 #ifdef _DEBUG
   735 		    RDebug::Print(_L("CEnvironmentalReverbUtility::EnvironmentalReverb()"));
   736 #endif
   737 
   738 		return *iEnvironmentalReverb;
   739     }
   740 
   741 // -----------------------------------------------------------------------------
   742 // CEnvironmentalReverbUtility::ModifyPresetL()
   743 // Applies the Preset to the EnvironmentalReverb Object
   744 // (other items were commented in a header).
   745 // -----------------------------------------------------------------------------
   746 //
   747 EXPORT_C void CEnvironmentalReverbUtility::ModifyPresetL(
   748     TInt aPresetIndex,
   749     TDesC& aName,
   750     CEnvironmentalReverb& aEnvironmentalReverbUI)
   751     {
   752 #ifdef _DEBUG
   753 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ModifyPresetL"));
   754 #endif
   755 
   756 		 __ASSERT_ALWAYS(aName.Length() > 0,User::Leave(KErrArgument));
   757 
   758 		// Modifies the Preset Data in the Central Repository
   759 		// with the updated Name and EnvironmentalReverb Settings for the
   760 		// given PresetIndex
   761 
   762 		if(aPresetIndex > (iPresetArray.Count() - 1))
   763 			User::Leave(KErrArgument);
   764 
   765 		iEnvironmentalReverb = &aEnvironmentalReverbUI;
   766 
   767 		// Write the EnvironmentalReverb Data in the first available NULL Space
   768 		for( TInt j = 0; j < iFullPresetArray.Count();j++)
   769 			{
   770 				if( iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey)
   771 					{
   772 						iPresetRepository->Set(iFullPresetArray[j].iPresetNameKey,aName);
   773 
   774 						HBufC8* presetHeap = HBufC8::NewL(sizeof(TEfEnvironmentalReverb));
   775 						TPtr8 des = presetHeap->Des();
   776 						des.SetLength(presetHeap->Size());
   777 						des.Append(iEnvironmentalReverb->DoEffectData());
   778 
   779 						iPresetRepository->Set(iFullPresetArray[j].iPresetDescriptionKey,des);
   780 						delete presetHeap;
   781 						presetHeap = NULL;
   782 						break;
   783 					}
   784 			}
   785 		UpdateFullPresetArrayFromCenRep(iFullPresetArray);
   786     }
   787 
   788 
   789 // -----------------------------------------------------------------------------
   790 // CEnvironmentalReverbUtility::NumberOfPreDefinedPresets()
   791 // Applies the Preset to the EnvironmentalReverb Object
   792 // (other items were commented in a header).
   793 // -----------------------------------------------------------------------------
   794 //
   795 
   796 
   797 EXPORT_C TUint32 CEnvironmentalReverbUtility::NumberOfPreDefinedPresets() const
   798     {
   799 #ifdef _DEBUG
   800 		    RDebug::Print(_L("CEnvironmentalReverbUtility::NumberOfPreDefinedPresets"));
   801 #endif
   802 
   803 		TInt numberOfPresets;
   804 		iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,numberOfPresets);
   805 		return numberOfPresets;
   806     }
   807 
   808 
   809 // -----------------------------------------------------------------------------
   810 // CEnvironmentalReverbUtility::Presets()
   811 // Applies the Preset to the EnvironmentalReverb Object
   812 // (other items were commented in a header).
   813 // -----------------------------------------------------------------------------
   814 //
   815 EXPORT_C TArray<TEfEnvironmentalReverbUtilityPreset> CEnvironmentalReverbUtility::Presets()
   816     {
   817 #ifdef _DEBUG
   818 		    RDebug::Print(_L("CEnvironmentalReverbUtility::Presets"));
   819 #endif
   820 
   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();
   825     }
   826 
   827 
   828 // -----------------------------------------------------------------------------
   829 // CEnvironmentalReverbUtility::ResetPresetL(TInt aPresetIndex)
   830 // Applies the Preset to the EnvironmentalReverb Object
   831 // (other items were commented in a header).
   832 // -----------------------------------------------------------------------------
   833 //
   834 EXPORT_C void CEnvironmentalReverbUtility::ResetPresetL(TInt aPresetIndex)
   835     {
   836 #ifdef _DEBUG
   837 		    RDebug::Print(_L("CEnvironmentalReverbUtility::ResetPresetL"));
   838 #endif
   839 
   840 		if(aPresetIndex > (iPresetArray.Count() - 1))
   841 			User::Leave(KErrArgument);
   842 
   843 		TInt currentNumber = 0;
   844 		// Get the number of System Defined Presets in the Repository
   845 		iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,currentNumber);
   846 
   847 		if(aPresetIndex >= currentNumber)
   848 			User::Leave(KErrNotSupported);
   849 
   850 
   851 		for( TInt j = 0; j < currentNumber;j++)
   852 				{
   853 					if(  iFullPresetArray[j].iPresetNameKey == iPresetArray[aPresetIndex].iPresetNameKey)
   854 						{
   855 							iPresetRepository->Reset(iFullPresetArray[j].iPresetDescriptionKey);
   856 							iPresetRepository->Reset(iFullPresetArray[j].iPresetNameKey);
   857 						}
   858 				}
   859 
   860 		UpdatePresetArray(iPresetArray,iFullPresetArray);
   861 	}
   862 
   863 
   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 // -----------------------------------------------------------------------------
   869 //
   870 
   871 void CEnvironmentalReverbUtility::UpdateFullPresetArrayFromCenRep(RArray<TEfEnvironmentalReverbUtilityPreset>& aFullPresetArray)
   872 	{
   873 
   874 		aFullPresetArray.Reset();
   875  		TEfEnvironmentalReverbUtilityPreset tempPreset;
   876 
   877 
   878 		TInt numberOfUserDefinedPresets = 0;
   879 		TInt numberOfPreDefinedPresets = 0;
   880 
   881 		iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfUserDefinedPresets,numberOfUserDefinedPresets);
   882 		iPresetRepository->Get(KEnvironmentalReverbUtilityNumberOfPreDefinedPresets,numberOfPreDefinedPresets);
   883 
   884 		for( TInt j = 0; j < (numberOfPreDefinedPresets); j++)
   885 				{
   886 					tempPreset.iPresetDescriptionKey = KEnvironmentalReverbUtilityPreDefinedPresetStart + (2 * j);
   887 					tempPreset.iPresetNameKey = KEnvironmentalReverbUtilityPreDefinedPresetStartName + (2 * j);
   888 					iPresetRepository->Get((KEnvironmentalReverbUtilityPreDefinedPresetStartName + (2 * j)) ,tempPreset.iPresetName);
   889 #ifdef _DEBUG
   890 					RDebug::RawPrint(tempPreset.iPresetName);
   891 #endif
   892 					aFullPresetArray.Append(tempPreset);
   893 
   894 				}
   895 
   896 			for( TInt j = 0; j < (numberOfUserDefinedPresets); j++)
   897 				{
   898 					tempPreset.iPresetDescriptionKey = KEnvironmentalReverbUtilityUserDefinedPresetStart + (2 * j);
   899 					tempPreset.iPresetNameKey = KEnvironmentalReverbUtilityUserDefinedPresetStartName + (2 * j);
   900 					iPresetRepository->Get((KEnvironmentalReverbUtilityUserDefinedPresetStartName + (2 * j)) ,tempPreset.iPresetName);
   901 #ifdef _DEBUG
   902 					RDebug::RawPrint(tempPreset.iPresetName);
   903 #endif
   904 					aFullPresetArray.Append(tempPreset);
   905 
   906 				}
   907 
   908 	}
   909 
   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 // -----------------------------------------------------------------------------
   915 //
   916 void CEnvironmentalReverbUtility::UpdatePresetArray(RArray<TEfEnvironmentalReverbUtilityPreset>& aPresetArray,const RArray<TEfEnvironmentalReverbUtilityPreset>& aFullPresetArray)
   917 	{
   918 
   919 		aPresetArray.Reset();
   920 		TEfEnvironmentalReverbUtilityPreset	tempClientArray;
   921 
   922 		// Write the EnvironmentalReverb Data in the first available NULL Space
   923 		for( TInt j = 0; j < aFullPresetArray.Count();j++)
   924 			{
   925 				if( aFullPresetArray[j].iPresetName.Length() != 0)
   926 					{
   927 
   928 						tempClientArray.iPresetName = aFullPresetArray[j].iPresetName;
   929 						tempClientArray.iPresetNameKey = aFullPresetArray[j].iPresetNameKey;
   930 
   931 						aPresetArray.Append(tempClientArray);
   932 					}
   933 #ifdef _DEBUG
   934 				RDebug::Print(_L("Name Length %d "),aFullPresetArray[j].iPresetName.Length());
   935 				RDebug::RawPrint(aFullPresetArray[j].iPresetName);
   936 #endif
   937 			}
   938 
   939 	}
   940 
   941 
   942 // ========================== OTHER EXPORTED FUNCTIONS =========================
   943 
   944 
   945 //  End of File