mpxplugins/viewplugins/views/audioeffectsview/src/mpxaudioeffectsmodel.cpp
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Engine class that uses the Effects API and saves changes.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include  <s32file.h>
       
    21 #include  <s32std.h>
       
    22 
       
    23 #include  "mpxaudioeffectproperties.h"
       
    24 #include  <mpxaudioeffectsview.rsg>
       
    25 #include  <mpxplaybackutility.h>
       
    26 #include  <mpxlog.h>
       
    27 
       
    28 #include  "mpxaudioeffects.hrh"
       
    29 #include  "mpxaudioeffectsmodel.h"
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KAudioEffectsCustomCommand = 0x101FFC02;
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35    
       
    36 // -----------------------------------------------------------------------------
       
    37 // CMPXAudioEffectsModel::NewL()
       
    38 // (other items were commented in a header).
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CMPXAudioEffectsModel* CMPXAudioEffectsModel::NewL(
       
    42     MMPXPlaybackUtility& aPlaybackUtility)
       
    43     {
       
    44     CMPXAudioEffectsModel* self = new( ELeave ) 
       
    45                                         CMPXAudioEffectsModel(aPlaybackUtility);
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51  
       
    52 // -----------------------------------------------------------------------------
       
    53 // CMPXAudioEffectsModel::CMPXAudioEffectsModel()
       
    54 // (other items were commented in a header).
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CMPXAudioEffectsModel::CMPXAudioEffectsModel(MMPXPlaybackUtility& aPlaybackUtility)
       
    58     :iPlaybackUtility(aPlaybackUtility)
       
    59     {
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CMPXAudioEffectsModel::~CMPXAudioEffectsModel()
       
    64 // (other items were commented in a header).
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CMPXAudioEffectsModel::~CMPXAudioEffectsModel()
       
    68     {
       
    69     if (iProp)
       
    70         {
       
    71         delete iProp;
       
    72         }
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CMPXAudioEffectsModel::ConstructL()
       
    77 // (other items were commented in a header).
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CMPXAudioEffectsModel::ConstructL()
       
    81     {
       
    82     iProp = new(ELeave) CMPXAudioEffectProperties();   
       
    83     MPX_TRAPD( err, iProp->LoadFromFileL() ); //Loads saved settings if available
       
    84     if( err != KErrNone )
       
    85         {
       
    86         MPX_DEBUG1("CMPXAudioEffectsModel::ConstructL -- load error");
       
    87         iProp->Reset();
       
    88         iBalance = 0;
       
    89         iReverb = 0;
       
    90         iStereo = EFalse;
       
    91         iBassBoost = EFalse;
       
    92         iLoudness = EFalse;
       
    93 #if 1 // VCPCC_MOD
       
    94         iLoudness=EFalse; 
       
    95 #endif // VCPCC_MOD   
       
    96         MPX_DEBUG1("CMPXAudioEffectsModel::ConstructL -- save to file");
       
    97         iProp->SaveToFileL();        
       
    98         }
       
    99     else
       
   100         {
       
   101         iBalance = iProp->Balance();
       
   102         iReverb = iProp->Reverb();
       
   103         iStereo = iProp->Stereo();
       
   104         iBassBoost = iProp->BassBoost(); 
       
   105         iLoudness = iProp->Loudness();   
       
   106         }
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CMPXAudioEffectsModel::SetBalanceL()
       
   112 // (other items were commented in a header).
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CMPXAudioEffectsModel::SetBalanceL()
       
   116     {
       
   117     iProp->SetBalance(iBalance);
       
   118     MPX_DEBUG1("CMPXAudioEffectsModel::SetBalanceL -- save to file");
       
   119     iProp->SaveToFileL();
       
   120 
       
   121     iPlaybackUtility.CommandL( EPbApplyEffect, KAudioEffectsCustomCommand );
       
   122     }
       
   123   
       
   124   
       
   125 // -----------------------------------------------------------------------------
       
   126 // CMPXAudioEffectsModel::SetReverberationL()
       
   127 // (other items were commented in a header).
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CMPXAudioEffectsModel::SetReverberationL()
       
   131     {
       
   132     iProp->SetReverb(iReverb);
       
   133     MPX_DEBUG1("CMPXAudioEffectsModel::SetReverberationL -- reverb save to file");
       
   134     iProp->SaveToFileL();
       
   135     
       
   136     iPlaybackUtility.CommandL( EPbApplyEffect, KAudioEffectsCustomCommand );
       
   137     }
       
   138   
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CMPXAudioEffectsModel::SetStereoWideningL()
       
   142 // (other items were commented in a header).
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CMPXAudioEffectsModel::SetStereoWideningL()
       
   146     {
       
   147     iProp->SetStereo(iStereo);
       
   148     MPX_DEBUG1("CMPXAudioEffectsModel::SetStereoWideningL -- set stereo save to file");
       
   149     iProp->SaveToFileL();
       
   150     
       
   151     iPlaybackUtility.CommandL( EPbApplyEffect, KAudioEffectsCustomCommand );
       
   152     }
       
   153 
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CMPXAudioEffectsModel::SetBassBoostL()
       
   157 // (other items were commented in a header).
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void CMPXAudioEffectsModel::SetBassBoostL()
       
   161     {
       
   162 #if 0 // VCPCC_MOD    
       
   163     iProp->SetBassBoost(iBassBoost);
       
   164     iProp->SaveToFileL();
       
   165 
       
   166     iPlaybackUtility.CommandL( EPbApplyEffect, KAudioEffectsCustomCommand );
       
   167 #endif // VCPCC_MOD   
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CMPXAudioEffectsModel::SetLoudnessL()
       
   172 // (other items were commented in a header).
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void CMPXAudioEffectsModel::SetLoudnessL()
       
   176     {
       
   177     iProp->SetLoudness(iLoudness);
       
   178     
       
   179     MPX_DEBUG1("CMPXAudioEffectsModel::SetLoudnessL -- save to file");
       
   180     iProp->SaveToFileL();
       
   181     
       
   182     iPlaybackUtility.CommandL( EPbApplyEffect, KAudioEffectsCustomCommand );
       
   183     }
       
   184 
       
   185 // End of file
       
   186 
       
   187 
       
   188 
       
   189 
       
   190