|
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 |
|
22 #ifndef __AUDCLIP_H__ |
|
23 #define __AUDCLIP_H__ |
|
24 |
|
25 |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <f32file.h> |
|
29 |
|
30 |
|
31 #include "AudCommon.h" |
|
32 #include "AudObservers.h" |
|
33 |
|
34 /* |
|
35 * Forward declarations. |
|
36 */ |
|
37 |
|
38 class CAudSong; |
|
39 class CAudSongObserver; |
|
40 class CAudClipInfo; |
|
41 class MAudClipInfoObserver; |
|
42 |
|
43 |
|
44 /* |
|
45 * Constant definitions. |
|
46 */ |
|
47 |
|
48 |
|
49 /** |
|
50 * Individual audio clip stored as a single bitstream. |
|
51 * |
|
52 * @see CAudSong |
|
53 */ |
|
54 class CAudClip : public CBase |
|
55 { |
|
56 public: |
|
57 |
|
58 /* Property methods. */ |
|
59 |
|
60 /** |
|
61 * Returns an audio clip info object to get detailed information about |
|
62 * the original audio clip. Note that the specified editing operations |
|
63 * (for example, cutting or muting) do <em>not</em> |
|
64 * affect the values returned by the info object. |
|
65 * |
|
66 * @return pointer to an audio clip info instance |
|
67 */ |
|
68 IMPORT_C CAudClipInfo* Info() const; |
|
69 |
|
70 /** |
|
71 * Returns a boolean value that indicates whether this clip is normalized |
|
72 * |
|
73 * @return ETrue if normalized, EFalse otherwise |
|
74 */ |
|
75 IMPORT_C TBool Normalizing() const; |
|
76 |
|
77 /** |
|
78 * Returns a dynamic level mark at the specified index |
|
79 * If the index is illegal, the method panics with the code |
|
80 * <code>EIllegalDynamicLevelMarkIndex</code> |
|
81 * |
|
82 * @return A dynamic level mark |
|
83 */ |
|
84 IMPORT_C TAudDynamicLevelMark DynamicLevelMark(TInt aIndex) const; |
|
85 |
|
86 /** |
|
87 * Returns the number of dynamic level marks |
|
88 * |
|
89 * @return The number of dynamic level mark |
|
90 */ |
|
91 IMPORT_C TInt DynamicLevelMarkCount() const; |
|
92 |
|
93 /** |
|
94 * Returns whether this clip is muted or not |
|
95 * |
|
96 * @return muting |
|
97 */ |
|
98 IMPORT_C TBool Muting() const; |
|
99 |
|
100 /** |
|
101 * Sets the start time of this audio clip in clip timebase. |
|
102 * Panics with <code>EAudioClipIllegalStartTime</code> if |
|
103 * cut in time is illegal (negative). |
|
104 * |
|
105 * @param aCutInTime cut in time in microseconds in clip timebase |
|
106 */ |
|
107 IMPORT_C void SetStartTime(TTimeIntervalMicroSeconds aStartTime); |
|
108 |
|
109 /** |
|
110 * Returns the start time of this audio clip in song timebase. |
|
111 * |
|
112 * @return start time in microseconds in song timebase |
|
113 */ |
|
114 IMPORT_C TTimeIntervalMicroSeconds StartTime() const; |
|
115 |
|
116 /** |
|
117 * Returns the start time of this audio clip in song timebase. |
|
118 * |
|
119 * @return start time in milliseconds in song timebase |
|
120 */ |
|
121 TInt32 StartTimeMilliSeconds() const; |
|
122 |
|
123 |
|
124 /** |
|
125 * Returns the end time of this audio clip in song timebase. |
|
126 * |
|
127 * @return end time in microseconds in song timebase |
|
128 */ |
|
129 IMPORT_C TTimeIntervalMicroSeconds EndTime() const; |
|
130 |
|
131 /** |
|
132 * Returns the duration of this audio clip with the specified |
|
133 * editing operations applied (for example, cutting) |
|
134 * |
|
135 * @return duration in microseconds |
|
136 */ |
|
137 IMPORT_C TTimeIntervalMicroSeconds EditedDuration() const; |
|
138 |
|
139 /** |
|
140 * Returns the priority of this audio clip |
|
141 * |
|
142 * @return priority |
|
143 */ |
|
144 IMPORT_C TInt Priority() const; |
|
145 |
|
146 /** |
|
147 * Returns the index of this audio clip __on a track__ |
|
148 * |
|
149 * @return index |
|
150 */ |
|
151 IMPORT_C TInt IndexOnTrack() const; |
|
152 |
|
153 |
|
154 /** |
|
155 * Returns the track index of this audio clip in CAudSong |
|
156 * |
|
157 * @return track index |
|
158 */ |
|
159 IMPORT_C TInt TrackIndex() const; |
|
160 |
|
161 |
|
162 |
|
163 /* Song methods. */ |
|
164 |
|
165 /** |
|
166 * Returns the song that this audio clip is part of. |
|
167 * |
|
168 * @return song |
|
169 */ |
|
170 IMPORT_C CAudSong* Song() const; |
|
171 |
|
172 /* Timing methods. */ |
|
173 |
|
174 /** |
|
175 * Returns the cut in time of this audio clip in clip timebase. |
|
176 * |
|
177 * @return cut in time in microseconds in clip timebase |
|
178 */ |
|
179 IMPORT_C TTimeIntervalMicroSeconds CutInTime() const; |
|
180 |
|
181 /** |
|
182 * Returns the cut in time of this audio clip in clip timebase. |
|
183 * |
|
184 * @return cut in time in milliseconds in clip timebase |
|
185 */ |
|
186 TInt32 CutInTimeMilliSeconds() const; |
|
187 |
|
188 /** |
|
189 * Sets the cut in time of this audio clip in clip timebase. |
|
190 * Panics with <code>EAudioClipIllegalCutInTime</code> if |
|
191 * cut in time is illegal. |
|
192 * |
|
193 * @param aCutInTime cut in time in microseconds in clip timebase |
|
194 */ |
|
195 IMPORT_C void SetCutInTime(TTimeIntervalMicroSeconds aCutInTime); |
|
196 |
|
197 /** |
|
198 * Returns the cut out time of this audio clip in clip timebase. |
|
199 * |
|
200 * @return cut out time in microseconds in clip timebase |
|
201 */ |
|
202 IMPORT_C TTimeIntervalMicroSeconds CutOutTime() const; |
|
203 |
|
204 /** |
|
205 * Returns the cut out time of this audio clip in clip timebase. |
|
206 * |
|
207 * @return cut out time in milliseconds in clip timebase |
|
208 */ |
|
209 TInt32 CutOutTimeMilliSeconds() const; |
|
210 |
|
211 /** |
|
212 * Sets the cut out time of this audio clip in clip timebase. |
|
213 * Panics with <code>EAudioClipIllegalCutOutTime</code> if |
|
214 * cut out time is illegal. |
|
215 * |
|
216 * @param aCutOutTime cut out time in microseconds in clip timebase |
|
217 */ |
|
218 IMPORT_C void SetCutOutTime(TTimeIntervalMicroSeconds aCutOutTime); |
|
219 |
|
220 /** |
|
221 * Sets the priority of this audio clip |
|
222 * |
|
223 * @param aPriority priority, >= 0 |
|
224 * |
|
225 * @return ETrue if aPriority >= 0 |
|
226 * EFalse if aPriority < 0, priority not set |
|
227 * |
|
228 */ |
|
229 IMPORT_C TBool SetPriority(TInt aPriority); |
|
230 |
|
231 |
|
232 /* Processing methods */ |
|
233 |
|
234 /** |
|
235 * Inserts a dynamic level mark to a clip. |
|
236 * If time of the given mark is illegal |
|
237 * <code>EIllegalDynamicLevelMark</code>-panic is raised |
|
238 * |
|
239 * Possible leave codes: |
|
240 * - <code>KErrNoMemory</code> if memory allocation fails |
|
241 * |
|
242 * @param aMark mark to be added in clip time domain |
|
243 * @return index of the mark inserted |
|
244 */ |
|
245 IMPORT_C TInt InsertDynamicLevelMarkL(const TAudDynamicLevelMark& aMark); |
|
246 |
|
247 /** |
|
248 * Removes a dynamic level mark in a clip. |
|
249 * Panics with code <code>EAudioClipIllegalIndex</code> |
|
250 * if the clip index is invalid. |
|
251 * |
|
252 * @param aIndex index of the removed mark in this clip |
|
253 * @return ETrue if mark was removed, EFalse otherwise |
|
254 */ |
|
255 IMPORT_C TBool RemoveDynamicLevelMark(TInt aIndex); |
|
256 |
|
257 /** |
|
258 * Sets whether this clip is muted or not. |
|
259 * |
|
260 * @param aMuting <code>ETrue</code> to mute the audio clip; |
|
261 * <code>EFalse</code> not to mute the audio clip |
|
262 */ |
|
263 IMPORT_C void SetMuting(TBool aMuted); |
|
264 |
|
265 /** |
|
266 * Sets whether this clip is normalized |
|
267 * |
|
268 * @param aNormalizing <code>ETrue</code> if normalized |
|
269 * <code>EFalse</code> otherwise |
|
270 */ |
|
271 IMPORT_C void SetNormalizing(TBool aNormalizing); |
|
272 |
|
273 IMPORT_C void Reset(TBool aNotify); |
|
274 |
|
275 /** |
|
276 * Sets common volume gain for the clip. It is used to store |
|
277 * the gain; the actual processing will be based on dynamic level |
|
278 * marks which are set based on the gain value just before processing. |
|
279 * Since global gain setting may affect the dynamic level mark, |
|
280 * we need different variable to store the clip-specific gain also after the processing. |
|
281 * I.e. dynamic level marks do not have effect to this value. |
|
282 * |
|
283 * @param aVolumeGain |
|
284 */ |
|
285 IMPORT_C void SetVolumeGain(TInt aVolumeGain); |
|
286 |
|
287 /** |
|
288 * Gets common volume gain for the clip. |
|
289 * Since global gain setting may affect the dynamic level mark, |
|
290 * we need different variable to store the clip-specific gain also after the processing. |
|
291 * |
|
292 * @param aVolumeGain |
|
293 */ |
|
294 IMPORT_C TInt GetVolumeGain(); |
|
295 |
|
296 /** |
|
297 * |
|
298 * Compare is used by RPointerArray::Sort() |
|
299 * |
|
300 */ |
|
301 static TInt Compare(const CAudClip &c1, const CAudClip &c2); |
|
302 |
|
303 |
|
304 protected: |
|
305 |
|
306 |
|
307 private: |
|
308 |
|
309 |
|
310 |
|
311 /* Constructors. */ |
|
312 |
|
313 static CAudClip* NewL(CAudSong* aSong, const TDesC& aFileName, |
|
314 TTimeIntervalMicroSeconds aStartTime, |
|
315 MAudClipInfoObserver& aObserver, TInt aTrackIndex); |
|
316 |
|
317 static CAudClip* NewL(CAudSong* aSong, RFile* aFileHandle, |
|
318 TTimeIntervalMicroSeconds aStartTime, |
|
319 MAudClipInfoObserver& aObserver, TInt aTrackIndex); |
|
320 |
|
321 CAudClip(CAudSong* aSong); |
|
322 |
|
323 void ConstructL(const TDesC& aFileName, |
|
324 TTimeIntervalMicroSeconds aStartTime, |
|
325 MAudClipInfoObserver& aObserver, TInt aTrackIndex); |
|
326 |
|
327 void ConstructL(RFile* aFileHandle, |
|
328 TTimeIntervalMicroSeconds aStartTime, |
|
329 MAudClipInfoObserver& aObserver, TInt aTrackIndex); |
|
330 |
|
331 /* Destructor. */ |
|
332 |
|
333 /** |
|
334 * Destroys the object and releases all resources. |
|
335 */ |
|
336 virtual ~CAudClip(); |
|
337 |
|
338 private: |
|
339 // Member variables |
|
340 |
|
341 // Song class this clip is part of. |
|
342 CAudSong* iSong; |
|
343 // File of the audio clip. |
|
344 RFile iFile; |
|
345 |
|
346 |
|
347 // Info class of this audio clip. |
|
348 CAudClipInfo* iInfo; |
|
349 |
|
350 // Cut in time of this audio clip. |
|
351 TTimeIntervalMicroSeconds iCutInTime; |
|
352 // Cut out time of this audio clip. |
|
353 TTimeIntervalMicroSeconds iCutOutTime; |
|
354 // Start time of this audio clip. |
|
355 TTimeIntervalMicroSeconds iStartTime; |
|
356 |
|
357 // Muting of this audio clip. |
|
358 // If ETrue, the clip is to be muted |
|
359 TBool iMute; |
|
360 |
|
361 // Normalizing of this audio clip. |
|
362 // If ETrue, the clip is to be normalized |
|
363 TBool iNormalize; |
|
364 |
|
365 // Priority of this audio clip. |
|
366 TInt iPriority; |
|
367 |
|
368 // index of this clip in CAudSong |
|
369 TInt iIndex; |
|
370 |
|
371 // track index of this clip |
|
372 TInt iTrackIndex; |
|
373 |
|
374 TInt iVolumeGain; |
|
375 |
|
376 // Marks used for manual level controlling |
|
377 RPointerArray<TAudDynamicLevelMark> iDynamicLevelMarkArray; |
|
378 |
|
379 friend class CAudSong; |
|
380 friend class CAudSongAddClipOperation; |
|
381 friend class RPointerArray<CAudClip>; |
|
382 |
|
383 }; |
|
384 |
|
385 |
|
386 #endif // __AUDCLIP_H__ |
|
387 |