|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 // System includes |
|
23 // User includes |
|
24 #include <e32math.h> |
|
25 |
|
26 #include "SampleArrayHandler.h" |
|
27 #include "VideoEditorCommon.h" // Video Editor UID |
|
28 |
|
29 #include "VideoEditorDebugUtils.h" |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 CSampleArrayHandler* CSampleArrayHandler::NewL() |
|
33 { |
|
34 CSampleArrayHandler* self = CSampleArrayHandler::NewLC(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CSampleArrayHandler* CSampleArrayHandler::NewLC() |
|
40 { |
|
41 CSampleArrayHandler* self = new( ELeave )CSampleArrayHandler(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 void CSampleArrayHandler::ConstructL() |
|
48 { |
|
49 } |
|
50 |
|
51 CSampleArrayHandler::CSampleArrayHandler() |
|
52 { |
|
53 } |
|
54 |
|
55 |
|
56 CSampleArrayHandler::~CSampleArrayHandler() |
|
57 { |
|
58 delete [] iVisualization; |
|
59 } |
|
60 |
|
61 void CSampleArrayHandler::SetVisualizationArray(TInt8* aVisualization, TInt aResolution) |
|
62 { |
|
63 LOG( KVideoEditorLogFile, "CSampleArrayHandler::SetVisualizationArray, In" ); |
|
64 iVisualization = aVisualization; |
|
65 iVisualizationSize = aResolution; |
|
66 |
|
67 // for testing |
|
68 /* for (TInt i = 0; i < iVisualizationSize; i++) |
|
69 { |
|
70 if (i == 127) |
|
71 iVisualization[i] = i - 127; |
|
72 else |
|
73 iVisualization[i] = i; |
|
74 } |
|
75 */ |
|
76 TInt8 temp = 0; // help variable used in finding the biggest current sample value |
|
77 for ( TInt i = 0; i < iVisualizationSize; i++ ) |
|
78 { |
|
79 if ( iVisualization[i] > temp ) |
|
80 { |
|
81 temp = iVisualization[i]; |
|
82 } |
|
83 //LOGFMT2(KVideoEditorLogFile, "CSampleArrayHandler::SetVisualizationArray, SAMPLE[%d]:%d", i, iVisualization[i]); |
|
84 } |
|
85 iMaxSample = temp; |
|
86 |
|
87 iScaleFactor = 1.0; // TReal |
|
88 LOG( KVideoEditorLogFile, "CSampleArrayHandler::SetVisualizationArray, Out" ); |
|
89 } |
|
90 |
|
91 void CSampleArrayHandler::ScaleAudioVisualization( const TInt8& aNewMaxValue ) |
|
92 { |
|
93 if ( iVisualization && ( aNewMaxValue != iMaxSampleInCurrentScale )) |
|
94 { |
|
95 iMaxSampleInCurrentScale = aNewMaxValue; |
|
96 if ( !Math::IsZero(( TReal64 )iMaxSampleInCurrentScale )) |
|
97 { |
|
98 iScaleFactor = ( TReal64 )iMaxSampleInCurrentScale / ( TReal64 )iMaxSample; |
|
99 |
|
100 } |
|
101 |
|
102 /* |
|
103 //for testing |
|
104 if (1 > coeff) |
|
105 { |
|
106 for (TInt i = 0; i < iVisualizationSize; i++) |
|
107 { |
|
108 LOGFMT(KVideoEditorLogFile, "before scaling:%d", iVisualization[i]); |
|
109 iVisualization[i] *= coeff; |
|
110 LOGFMT(KVideoEditorLogFile, "after scaling:%d", iVisualization[i]); |
|
111 } |
|
112 }*/ |
|
113 } |
|
114 } |
|
115 |
|
116 TInt8 CSampleArrayHandler::Sample( const TInt aIndex )const |
|
117 { |
|
118 // must be scaled down in order to fit into screen |
|
119 if ( iScaleFactor < 1 ) |
|
120 { |
|
121 return (( iVisualization[aIndex]* 1000 )*( iScaleFactor* 1000 )) / 1000000; |
|
122 |
|
123 } |
|
124 else |
|
125 { |
|
126 return iVisualization[aIndex]; |
|
127 } |
|
128 } |
|
129 |
|
130 TInt CSampleArrayHandler::Size()const |
|
131 { |
|
132 return iVisualizationSize; |
|
133 } |
|
134 |
|
135 TInt CSampleArrayHandler::CurrentPoint()const |
|
136 { |
|
137 return iCurrentIndex; |
|
138 } |
|
139 |
|
140 void CSampleArrayHandler::SetCurrentPoint(const TTimeIntervalMicroSeconds& aCurrentTime) |
|
141 { |
|
142 iCurrentTime = aCurrentTime; |
|
143 iCurrentIndex = ( iCurrentTime.Int64() / 1000 ) / KAudioSampleInterval; |
|
144 } |
|
145 |
|
146 void CSampleArrayHandler::SetCutInPoint(const TTimeIntervalMicroSeconds& aCutInTime) |
|
147 { |
|
148 iCutInTime = aCutInTime; |
|
149 iCutInSampleIndex = ( iCutInTime.Int64() / 1000 ) / KAudioSampleInterval; |
|
150 } |
|
151 |
|
152 void CSampleArrayHandler::SetCutOutPoint(const TTimeIntervalMicroSeconds& aCutOutTime) |
|
153 { |
|
154 iCutOutTime = aCutOutTime; |
|
155 iCutOutSampleIndex = ( iCutOutTime.Int64() / 1000 ) / KAudioSampleInterval; |
|
156 } |
|
157 |
|
158 TBool CSampleArrayHandler::SampleCutted( const TInt aIndex )const |
|
159 { |
|
160 return ( iCutInSampleIndex < aIndex ) && ( aIndex < iCutOutSampleIndex ); |
|
161 } |
|
162 |
|
163 // End of File |