|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32std.h> |
|
17 #include "mmfSwCodecUtility.h" |
|
18 |
|
19 |
|
20 |
|
21 /****************************************************************** |
|
22 * CMMFSwCodecUtility |
|
23 ******************************************************************/ |
|
24 CMMFSwCodecUtility::CMMFSwCodecUtility() |
|
25 { |
|
26 } |
|
27 |
|
28 |
|
29 CMMFSwCodecUtility::~CMMFSwCodecUtility() |
|
30 { |
|
31 } |
|
32 |
|
33 CMMFSwCodecUtility* CMMFSwCodecUtility::NewL() |
|
34 { |
|
35 CMMFSwCodecUtility* self = new(ELeave) CMMFSwCodecUtility(); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 void CMMFSwCodecUtility::ConstructL() |
|
43 { |
|
44 } |
|
45 |
|
46 void CMMFSwCodecUtility::ConfigAudioRamper(TInt64 aRampTime, TInt aSampleRate, TInt aChannels) |
|
47 { |
|
48 iRampSamples = I64LOW(((TInt64(aSampleRate) * aRampTime) /1000000 )); // Add this |
|
49 iRampSamplesLeft = iRampSamples; |
|
50 iChannels = aChannels; |
|
51 iRampIncr = 0; |
|
52 iSkip = ETrue; |
|
53 } |
|
54 |
|
55 TBool CMMFSwCodecUtility::RampAudio(CMMFDataBuffer* aBuffer) |
|
56 { |
|
57 TInt i=0; |
|
58 TInt length = aBuffer->Data().Length()>>1; |
|
59 TInt16* sample = REINTERPRET_CAST(TInt16*,&aBuffer->Data()[0]); |
|
60 TInt64 theResult(0); |
|
61 while ((i < length) && (iRampIncr < iRampSamples)) |
|
62 { |
|
63 theResult = sample[i]; |
|
64 theResult *= iRampIncr; |
|
65 theResult /= iRampSamples; |
|
66 sample[i] = STATIC_CAST(TInt16, I64LOW(theResult) ); |
|
67 |
|
68 if ((iChannels == 1) || (!iSkip)) |
|
69 { |
|
70 iRampIncr++; |
|
71 } |
|
72 iSkip = !iSkip; |
|
73 i++; |
|
74 } |
|
75 |
|
76 if (iRampIncr < iRampSamples) |
|
77 return ETrue; |
|
78 else |
|
79 return EFalse; |
|
80 |
|
81 } |
|
82 |