os/mm/devsoundextensions/effects/EnvReverb/EnvironmentalReverbEffect/Src/EnvironmentalReverbBase.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: Implementation of the Environmental Reverb effect class
27 #include <EnvironmentalReverbBase.h>
28 #include <CustomInterfaceUtility.h>
29 #include "EnvironmentalReverbProxy.h"
30 #include <DrmAudioSamplePlayer.h>
31 #include <mdaaudioinputstream.h>
32 #include <mdaaudiooutputstream.h>
33 #include <mdaaudiotoneplayer.h>
34 #include <mmf/server/sounddevice.h>
37 #define DEBPRN0 RDebug::Printf( "%s", __PRETTY_FUNCTION__);
38 #define DEBPRN1(str) RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
44 // ============================ MEMBER FUNCTIONS ===============================
46 // -----------------------------------------------------------------------------
47 // CEnvironmentalReverb::CEnvironmentalReverb
48 // C++ default constructor can NOT contain any code, that
50 // -----------------------------------------------------------------------------
52 EXPORT_C CEnvironmentalReverb::CEnvironmentalReverb()
54 iDataPckgTo(iReverbData)
59 EXPORT_C CEnvironmentalReverb::~CEnvironmentalReverb()
63 // -----------------------------------------------------------------------------
64 // CEnvironmentalReverb::NewL
65 // Static function for creating an instance of the Environmental Reverb object.
66 // -----------------------------------------------------------------------------
68 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL()
70 User::Leave(KErrNotSupported);
74 // -----------------------------------------------------------------------------
75 // CEnvironmentalReverb::NewL
76 // Static function for creating an instance of the EnvironmentalReverb object.
77 // -----------------------------------------------------------------------------
79 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
80 CMdaAudioConvertUtility& aUtility )
84 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
85 CleanupStack::PushL(customInterface);
87 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
89 if ( !environmentalReverbProxy )
91 DEBPRN1("No Adaptation Support - leaving");
92 User::Leave(KErrNotSupported);
95 CleanupStack::Pop(customInterface);
97 return environmentalReverbProxy;
100 // -----------------------------------------------------------------------------
101 // CEnvironmentalReverb::NewL
102 // Static function for creating an instance of the EnvironmentalReverb object.
103 // -----------------------------------------------------------------------------
105 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
106 CMdaAudioInputStream& aUtility )
110 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)aUtility.CustomInterface(KUidEnvironmentalReverbEffect);
112 if (environmentalReverbProxy == NULL)
114 DEBPRN1("No Adaptation Support - leaving");
115 User::Leave(KErrNotSupported);
118 return environmentalReverbProxy;
121 // -----------------------------------------------------------------------------
122 // CEnvironmentalReverb::NewL
123 // Static function for creating an instance of the EnvironmentalReverb object.
124 // -----------------------------------------------------------------------------
126 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
127 CMdaAudioOutputStream& aUtility )
131 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)aUtility.CustomInterface(KUidEnvironmentalReverbEffect);
133 if (environmentalReverbProxy == NULL)
135 DEBPRN1("No Adaptation Support - leaving");
136 User::Leave(KErrNotSupported);
139 return environmentalReverbProxy;
142 // -----------------------------------------------------------------------------
143 // CEnvironmentalReverb::NewL
144 // Static function for creating an instance of the EnvironmentalReverb object.
145 // -----------------------------------------------------------------------------
147 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
148 CMdaAudioPlayerUtility& aUtility )
152 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
153 CleanupStack::PushL(customInterface);
155 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
157 if ( !environmentalReverbProxy )
159 DEBPRN1("No Adaptation Support - leaving");
160 User::Leave(KErrNotSupported);
163 CleanupStack::Pop(customInterface);
165 return environmentalReverbProxy;
168 // -----------------------------------------------------------------------------
169 // CEnvironmentalReverb::NewL
170 // Static function for creating an instance of the EnvironmentalReverb object.
171 // -----------------------------------------------------------------------------
173 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
174 CMdaAudioRecorderUtility& aUtility,
175 TBool aRecordStream )
179 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
180 CleanupStack::PushL(customInterface);
182 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
184 if ( !environmentalReverbProxy )
186 DEBPRN1("No Adaptation Support - leaving");
187 User::Leave(KErrNotSupported);
190 CleanupStack::Pop(customInterface);
192 return environmentalReverbProxy;
195 // -----------------------------------------------------------------------------
196 // CEnvironmentalReverb::NewL
197 // Static function for creating an instance of the EnvironmentalReverb object.
198 // -----------------------------------------------------------------------------
200 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
201 CMdaAudioToneUtility& aUtility )
205 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)aUtility.CustomInterface(KUidEnvironmentalReverbEffect);
207 if (environmentalReverbProxy == NULL)
209 DEBPRN1("No Adaptation Support - leaving");
210 User::Leave(KErrNotSupported);
213 return environmentalReverbProxy;
216 // -----------------------------------------------------------------------------
217 // CAudioEqualizer::NewL
218 // Static function for creating an instance of the EnvironmentalReverb object.
219 // -----------------------------------------------------------------------------
221 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
222 CMMFDevSound& aDevSound )
226 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)aDevSound.CustomInterface(KUidEnvironmentalReverbEffect);
228 if (environmentalReverbProxy == NULL)
230 DEBPRN1("No Adaptation Support - leaving");
231 User::Leave(KErrNotSupported);
234 return environmentalReverbProxy;
237 // -----------------------------------------------------------------------------
238 // CEnvironmentalReverb::NewL
239 // Static function for creating an instance of the EnvironmentalReverb object.
240 // -----------------------------------------------------------------------------
242 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
243 CCustomCommandUtility* aUtility )
247 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
248 CleanupStack::PushL(customInterface);
250 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
252 if ( !environmentalReverbProxy )
254 DEBPRN1("No Adaptation Support - leaving");
255 User::Leave(KErrNotSupported);
258 CleanupStack::Pop(customInterface);
260 return environmentalReverbProxy;
263 // -----------------------------------------------------------------------------
264 // CEnvironmentalReverb::NewL
265 // Static function for creating an instance of the EnvironmentalReverb object.
266 // -----------------------------------------------------------------------------
268 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(
269 MCustomInterface& aCustomInterface )
273 CEnvironmentalReverb* environmentalReverbProxy = (CEnvironmentalReverb*)aCustomInterface.CustomInterface(KUidEnvironmentalReverbEffect);
274 if ( !environmentalReverbProxy )
276 DEBPRN1("No Adaptation Support - leaving");
277 User::Leave(KErrNotSupported);
280 return environmentalReverbProxy;
284 // -----------------------------------------------------------------------------
285 // CEnvironmentalReverb::NewL
286 // Static function for creating an instance of the EnvironmentalReverb object.
287 // -----------------------------------------------------------------------------
289 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(CMidiClientUtility& aUtility )
293 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
294 CleanupStack::PushL(customInterface);
296 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
298 if ( !environmentalReverbProxy )
300 DEBPRN1("No Adaptation Support - leaving");
301 User::Leave(KErrNotSupported);
304 CleanupStack::Pop(customInterface);
306 return environmentalReverbProxy;
309 // -----------------------------------------------------------------------------
310 // CEnvironmentalReverb::NewL
311 // Static function for creating an instance of the EnvironmentalReverb object.
312 // -----------------------------------------------------------------------------
314 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(CDrmPlayerUtility& aUtility)
318 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
319 CleanupStack::PushL(customInterface);
321 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
323 if ( !environmentalReverbProxy )
325 DEBPRN1("No Adaptation Support - leaving");
326 User::Leave(KErrNotSupported);
329 CleanupStack::Pop(customInterface);
331 return environmentalReverbProxy;
334 // -----------------------------------------------------------------------------
335 // CEnvironmentalReverb::NewL
336 // Static function for creating an instance of the EnvironmentalReverb object.
337 // -----------------------------------------------------------------------------
339 EXPORT_C CEnvironmentalReverb* CEnvironmentalReverb::NewL(CVideoPlayerUtility& aUtility)
343 CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
344 CleanupStack::PushL(customInterface);
346 CEnvironmentalReverbProxy* environmentalReverbProxy = (CEnvironmentalReverbProxy*)customInterface->CustomInterface(KUidEnvironmentalReverbEffect);
348 if ( !environmentalReverbProxy )
350 DEBPRN1("No Adaptation Support - leaving");
351 User::Leave(KErrNotSupported);
354 CleanupStack::Pop(customInterface);
356 return environmentalReverbProxy;
359 // -----------------------------------------------------------------------------
360 // CEnvironmentalReverb::DecayHFRatio
361 // -----------------------------------------------------------------------------
363 EXPORT_C TUint32 CEnvironmentalReverb::DecayHFRatio() const
365 return iReverbData.iDecayHFRatio;
368 // -----------------------------------------------------------------------------
369 // CEnvironmentalReverb::DecayHFRatioRange
370 // -----------------------------------------------------------------------------
372 EXPORT_C void CEnvironmentalReverb::DecayHFRatioRange(
376 aMin = iReverbData.iDecayHFRatioMin;
377 aMax = iReverbData.iDecayHFRatioMax;
380 // -----------------------------------------------------------------------------
381 // CEnvironmentalReverb::DecayTime
382 // -----------------------------------------------------------------------------
384 EXPORT_C TUint32 CEnvironmentalReverb::DecayTime() const
386 return iReverbData.iDecayTime;
389 // -----------------------------------------------------------------------------
390 // CEnvironmentalReverb::DecayTimeRange
391 // -----------------------------------------------------------------------------
393 EXPORT_C void CEnvironmentalReverb::DecayTimeRange(
397 aMin = iReverbData.iDecayTimeMin;
398 aMax = iReverbData.iDecayTimeMax;
401 // -----------------------------------------------------------------------------
402 // CEnvironmentalReverb::Density
403 // -----------------------------------------------------------------------------
405 EXPORT_C TUint32 CEnvironmentalReverb::Density() const
407 return iReverbData.iDensity;
410 // -----------------------------------------------------------------------------
411 // CEnvironmentalReverb::Diffusion
412 // -----------------------------------------------------------------------------
414 EXPORT_C TUint32 CEnvironmentalReverb::Diffusion() const
416 return iReverbData.iDiffusion;
419 // -----------------------------------------------------------------------------
420 // CEnvironmentalReverb::ReflectionsDelay
421 // -----------------------------------------------------------------------------
423 EXPORT_C TUint32 CEnvironmentalReverb::ReflectionsDelay() const
425 return iReverbData.iReflectionsDelay;
428 // -----------------------------------------------------------------------------
429 // CEnvironmentalReverb::ReflectionsDelayMax
430 // -----------------------------------------------------------------------------
432 EXPORT_C TUint32 CEnvironmentalReverb::ReflectionsDelayMax() const
434 return iReverbData.iReflectionsDelayMax;
437 // -----------------------------------------------------------------------------
438 // CEnvironmentalReverb::ReflectionsLevel
439 // -----------------------------------------------------------------------------
441 EXPORT_C TInt32 CEnvironmentalReverb::ReflectionsLevel() const
443 return iReverbData.iReflectionsLevel;
446 // -----------------------------------------------------------------------------
447 // CEnvironmentalReverb::ReflectionLevelRange
448 // -----------------------------------------------------------------------------
450 EXPORT_C void CEnvironmentalReverb::ReflectionLevelRange(
454 aMin = iReverbData.iReflectionLevelMin;
455 aMax = iReverbData.iReflectionLevelMax;
458 // -----------------------------------------------------------------------------
459 // CEnvironmentalReverb::ReverbDelay
460 // -----------------------------------------------------------------------------
462 EXPORT_C TUint32 CEnvironmentalReverb::ReverbDelay() const
464 return iReverbData.iReverbDelay;
467 // -----------------------------------------------------------------------------
468 // CEnvironmentalReverb::ReverbDelayMax
469 // -----------------------------------------------------------------------------
471 EXPORT_C TUint32 CEnvironmentalReverb::ReverbDelayMax() const
473 return iReverbData.iReverbDelayMax;
477 // -----------------------------------------------------------------------------
478 // CEnvironmentalReverb::ReverbLevel
479 // -----------------------------------------------------------------------------
481 EXPORT_C TInt32 CEnvironmentalReverb::ReverbLevel() const
483 return iReverbData.iReverbLevel;
486 // -----------------------------------------------------------------------------
487 // CEnvironmentalReverb::ReverbLevelRange
488 // -----------------------------------------------------------------------------
490 EXPORT_C void CEnvironmentalReverb::ReverbLevelRange(
494 aMin = iReverbData.iReverbLevelMin;
495 aMax = iReverbData.iReverbLevelMax;
499 // -----------------------------------------------------------------------------
500 // CEnvironmentalReverb::RoomHFLevel
501 // -----------------------------------------------------------------------------
503 EXPORT_C TInt32 CEnvironmentalReverb::RoomHFLevel() const
505 return iReverbData.iRoomHFLevel;
509 // -----------------------------------------------------------------------------
510 // CEnvironmentalReverb::RoomHFLevelRange
511 // -----------------------------------------------------------------------------
513 EXPORT_C void CEnvironmentalReverb::RoomHFLevelRange(
517 aMin = iReverbData.iRoomHFLevelMin;
518 aMax = iReverbData.iRoomHFLevelMax;
522 // -----------------------------------------------------------------------------
523 // CEnvironmentalReverb::RoomLevel
524 // -----------------------------------------------------------------------------
526 EXPORT_C TInt32 CEnvironmentalReverb::RoomLevel() const
529 return iReverbData.iRoomLevel;
533 // -----------------------------------------------------------------------------
534 // CEnvironmentalReverb::RoomLevelRange
535 // -----------------------------------------------------------------------------
537 EXPORT_C void CEnvironmentalReverb::RoomLevelRange(
541 aMin = iReverbData.iRoomLevelMin;
542 aMax = iReverbData.iRoomLevelMax;
547 // -----------------------------------------------------------------------------
548 // CEnvironmentalReverb::SetDecayHFRatioL
549 // -----------------------------------------------------------------------------
551 EXPORT_C void CEnvironmentalReverb::SetDecayHFRatioL(
552 TUint32 aDecayHFRatio )
554 if ( (aDecayHFRatio >= iReverbData.iDecayHFRatioMin) && (aDecayHFRatio <= iReverbData.iDecayHFRatioMax) )
556 iReverbData.iDecayHFRatio = aDecayHFRatio;
560 User::Leave(KErrArgument);
565 // -----------------------------------------------------------------------------
566 // CEnvironmentalReverb::SetDecayTimeL
567 // -----------------------------------------------------------------------------
569 EXPORT_C void CEnvironmentalReverb::SetDecayTimeL(
572 if ( (aDecayTime >= iReverbData.iDecayTimeMin) && (aDecayTime <= iReverbData.iDecayTimeMax) )
574 iReverbData.iDecayTime = aDecayTime;
578 User::Leave(KErrArgument);
583 // -----------------------------------------------------------------------------
584 // CEnvironmentalReverb::SetDensityL
585 // -----------------------------------------------------------------------------
587 EXPORT_C void CEnvironmentalReverb::SetDensityL(
590 iReverbData.iDensity = aDensity;
593 // -----------------------------------------------------------------------------
594 // CEnvironmentalReverb::SetDiffusionL
595 // -----------------------------------------------------------------------------
597 EXPORT_C void CEnvironmentalReverb::SetDiffusionL(
600 iReverbData.iDiffusion = aDiffusion;
604 // -----------------------------------------------------------------------------
605 // CEnvironmentalReverb::SetReflectionsDelayL
606 // -----------------------------------------------------------------------------
608 EXPORT_C void CEnvironmentalReverb::SetReflectionsDelayL(
609 TUint32 aReflectionsDelay )
611 if ( aReflectionsDelay > iReverbData.iReflectionsDelayMax )
613 User::Leave(KErrArgument);
617 iReverbData.iReflectionsDelay = aReflectionsDelay;
621 // -----------------------------------------------------------------------------
622 // CEnvironmentalReverb::SetReflectionsLevelL
623 // -----------------------------------------------------------------------------
625 EXPORT_C void CEnvironmentalReverb::SetReflectionsLevelL(
626 TInt32 aReflectionsLevel )
628 if ( (aReflectionsLevel >= iReverbData.iReflectionLevelMin) && (aReflectionsLevel <= iReverbData.iReflectionLevelMax) )
630 iReverbData.iReflectionsLevel = aReflectionsLevel;
634 User::Leave(KErrArgument);
638 // -----------------------------------------------------------------------------
639 // CEnvironmentalReverb::SetReverbDelayL
640 // -----------------------------------------------------------------------------
642 EXPORT_C void CEnvironmentalReverb::SetReverbDelayL(
643 TUint32 aReverbDelay )
645 if ( aReverbDelay > iReverbData.iReverbDelayMax )
647 User::Leave(KErrArgument);
651 iReverbData.iReverbDelay = aReverbDelay;
656 // -----------------------------------------------------------------------------
657 // CEnvironmentalReverb::SetReverbLevelL
658 // -----------------------------------------------------------------------------
660 EXPORT_C void CEnvironmentalReverb::SetReverbLevelL(
661 TInt32 aReverbLevel )
663 if ( (aReverbLevel >= iReverbData.iReverbLevelMin) && (aReverbLevel <= iReverbData.iReverbLevelMax) )
665 iReverbData.iReverbLevel = aReverbLevel;
669 User::Leave(KErrArgument);
673 // -----------------------------------------------------------------------------
674 // CEnvironmentalReverb::SetRoomHFLevelL
675 // -----------------------------------------------------------------------------
677 EXPORT_C void CEnvironmentalReverb::SetRoomHFLevelL(
678 TInt32 aRoomHFLevel )
680 if ( (aRoomHFLevel >= iReverbData.iRoomHFLevelMin) && (aRoomHFLevel <= iReverbData.iRoomHFLevelMax) )
682 iReverbData.iRoomHFLevel = aRoomHFLevel;
686 User::Leave(KErrArgument);
690 // -----------------------------------------------------------------------------
691 // CEnvironmentalReverb::SetRoomLevelL
692 // -----------------------------------------------------------------------------
694 EXPORT_C void CEnvironmentalReverb::SetRoomLevelL(
697 if ( (aRoomLevel >= iReverbData.iRoomLevelMin) && (aRoomLevel <= iReverbData.iRoomLevelMax) )
699 iReverbData.iRoomLevel = aRoomLevel;
703 User::Leave(KErrArgument);
707 // -----------------------------------------------------------------------------
708 // CEnvironmentalReverb::DelayMax
709 // -----------------------------------------------------------------------------
711 EXPORT_C TUint32 CEnvironmentalReverb::DelayMax() const
713 return iReverbData.iDelayMax;
717 // -----------------------------------------------------------------------------
718 // CEnvironmentalReverb::Uid
719 // -----------------------------------------------------------------------------
721 EXPORT_C TUid CEnvironmentalReverb::Uid() const
723 return KUidEnvironmentalReverbEffect;
727 // -----------------------------------------------------------------------------
728 // CEnvironmentalReverb::DoEffectData
729 // -----------------------------------------------------------------------------
731 EXPORT_C const TDesC8& CEnvironmentalReverb::DoEffectData()
734 iDataPckgTo = iReverbData;
738 // -----------------------------------------------------------------------------
739 // CEnvironmentalReverb::SetEffectData
740 // -----------------------------------------------------------------------------
742 EXPORT_C void CEnvironmentalReverb::SetEffectData(
743 const TDesC8& aEffectDataBuffer )
746 TEfEnvReverbDataPckg dataPckg;
747 dataPckg.Copy(aEffectDataBuffer);
748 iReverbData = dataPckg();
749 iEnabled = iReverbData.iEnabled;
750 iEnforced = iReverbData.iEnforced;
751 iHaveUpdateRights = iReverbData.iHaveUpdateRights;
755 // ========================== OTHER EXPORTED FUNCTIONS =========================