javauis/amms_qt/ammscontrol/audio3D/src/cammsdistanceattenuationcontrolgroup.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Group for distance attenuation controls
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "cammsdistanceattenuationcontrolgroup.h"
       
    22 #include "cammsbasedistanceattenuationcontrol.h"
       
    23 
       
    24 // CONSTANTS
       
    25 static const TInt KAMMSMinDistance = 1000;
       
    26 static const TInt KAMMSRolloffFactor = 1000;
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CAMMSDistanceAttenuationControlGroup::NewLC
       
    32 // Two-phased constructor.
       
    33 // -----------------------------------------------------------------------------
       
    34 CAMMSDistanceAttenuationControlGroup*
       
    35 CAMMSDistanceAttenuationControlGroup::NewLC()
       
    36 {
       
    37     CAMMSDistanceAttenuationControlGroup* self =
       
    38         new(ELeave) CAMMSDistanceAttenuationControlGroup;
       
    39 
       
    40     CleanupStack::PushL(self);
       
    41     // calls base class ConstructL
       
    42     self->ConstructL();
       
    43 
       
    44     return self;
       
    45 }
       
    46 
       
    47 //Destructor
       
    48 CAMMSDistanceAttenuationControlGroup::~CAMMSDistanceAttenuationControlGroup()
       
    49 {
       
    50 }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CAMMSDistanceAttenuationControlGroup::MaxDistance
       
    54 // Returns the maximum distance.
       
    55 // (other items were commented in a header).
       
    56 // -----------------------------------------------------------------------------
       
    57 TInt32 CAMMSDistanceAttenuationControlGroup::MaxDistance() const
       
    58 {
       
    59     return iCommited.iMaxDistance;
       
    60 }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CAMMSDistanceAttenuationControlGroup::MinDistance
       
    64 // Returns the distance where the source is loudest.
       
    65 // (other items were commented in a header).
       
    66 // -----------------------------------------------------------------------------
       
    67 TInt32 CAMMSDistanceAttenuationControlGroup::MinDistance() const
       
    68 {
       
    69     return iCommited.iMinDistance;
       
    70 }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CAMMSDistanceAttenuationControlGroup::MuteAfterMax
       
    74 // Returns how the distance gain behaves for distances beyond
       
    75 // the maximum distance.
       
    76 // (other items were commented in a header).
       
    77 // -----------------------------------------------------------------------------
       
    78 TBool CAMMSDistanceAttenuationControlGroup::MuteAfterMax() const
       
    79 {
       
    80     return iCommited.iMuteAfterMax;
       
    81 }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CAMMSDistanceAttenuationControlGroup::RolloffFactor
       
    85 // Returns the rolloff factor for the distance gain.
       
    86 // (other items were commented in a header).
       
    87 // -----------------------------------------------------------------------------
       
    88 TUint32 CAMMSDistanceAttenuationControlGroup::RolloffFactor() const
       
    89 {
       
    90     return iCommited.iRolloffFactor;
       
    91 }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CAMMSDistanceAttenuationControlGroup::SetParametersL
       
    95 // Sets all the 3D audio distance attenuation parameters simultaneously
       
    96 // (other items were commented in a header).
       
    97 // -----------------------------------------------------------------------------
       
    98 void CAMMSDistanceAttenuationControlGroup::SetParametersL(
       
    99     TInt32 aMinDistance,
       
   100     TInt32 aMaxDistance,
       
   101     TBool aMuteAfterMax,
       
   102     TUint32 aRolloffFactor)
       
   103 {
       
   104     // temporary values, moved to the commited variables in CommitL() method
       
   105     iUncommited.iMinDistance = aMinDistance;
       
   106     iUncommited.iMaxDistance = aMaxDistance;
       
   107     iUncommited.iMuteAfterMax = aMuteAfterMax;
       
   108     iUncommited.iRolloffFactor = aRolloffFactor;
       
   109 
       
   110     UpdateL(EDistance);
       
   111 }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CAMMSDistanceAttenuationControlGroup::TypeSafeControl
       
   115 // Get and cast a control. Ownership is not tranferred.
       
   116 // (other items were commented in a header).
       
   117 // -----------------------------------------------------------------------------
       
   118 CAMMSBaseDistanceAttenuationControl*
       
   119 CAMMSDistanceAttenuationControlGroup::TypeSafeControl(TInt aIndex) const
       
   120 {
       
   121     return static_cast<CAMMSBaseDistanceAttenuationControl*>(Control(aIndex));
       
   122 }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CAMMSDistanceAttenuationControlGroup::ClassName
       
   126 // Returns class name that identifies this control group.
       
   127 // (other items were commented in a header).
       
   128 // -----------------------------------------------------------------------------
       
   129 const TDesC16& CAMMSDistanceAttenuationControlGroup::ClassName()
       
   130 {
       
   131     return KAMMSDistanceAttenuationClassName;
       
   132 }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CAMMSDistanceAttenuationControlGroup::CommitL
       
   136 // Transfers all the pending parameters to the audio processing system.
       
   137 // (other items were commented in a header).
       
   138 // -----------------------------------------------------------------------------
       
   139 void CAMMSDistanceAttenuationControlGroup::CommitL(TInt aCommit)
       
   140 {
       
   141     if (aCommit & EDistance)
       
   142     {
       
   143         TInt controls = ControlCount();
       
   144         for (TInt i = 0; i < controls; i++)
       
   145         {
       
   146             TypeSafeControl(i)->SetParametersL(
       
   147                 iUncommited.iMinDistance,
       
   148                 iUncommited.iMaxDistance,
       
   149                 iUncommited.iMuteAfterMax,
       
   150                 iUncommited.iRolloffFactor);
       
   151         }
       
   152         iCommited = iUncommited;
       
   153     }
       
   154 }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CAMMSDistanceAttenuationControlGroup::NotifyPlayerAddedL
       
   158 // Called by when a new player is added
       
   159 // (other items were commented in a header).
       
   160 // -----------------------------------------------------------------------------
       
   161 void CAMMSDistanceAttenuationControlGroup::NotifyPlayerAddedL(
       
   162     CMMAPlayer* aPlayer,
       
   163     CMMAControl* aControl)
       
   164 {
       
   165     CAMMSAudio3DControlGroup::NotifyPlayerAddedL(aPlayer, aControl);
       
   166 
       
   167     CAMMSBaseDistanceAttenuationControl* control =
       
   168         static_cast<CAMMSBaseDistanceAttenuationControl*>(aControl);
       
   169 
       
   170     // set the current parameters
       
   171     control->SetParametersL(
       
   172         iCommited.iMinDistance,
       
   173         iCommited.iMaxDistance,
       
   174         iCommited.iMuteAfterMax,
       
   175         iCommited.iRolloffFactor);
       
   176 }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CAMMSDistanceAttenuationControlGroup::CAMMSDistanceAttenuationControlGroup
       
   180 // C++ default constructor can NOT contain any code, that
       
   181 // might leave.
       
   182 // -----------------------------------------------------------------------------
       
   183 CAMMSDistanceAttenuationControlGroup::CAMMSDistanceAttenuationControlGroup()
       
   184         : CAMMSAudio3DControlGroup(KAMMSBaseDistanceAttenuationControl)
       
   185 {
       
   186     iCommited.iMinDistance = KAMMSMinDistance;
       
   187     iCommited.iMaxDistance = KMaxTInt;
       
   188     iCommited.iMuteAfterMax = ETrue;
       
   189     iCommited.iRolloffFactor = KAMMSRolloffFactor;
       
   190 }
       
   191 
       
   192 
       
   193 //  End of File