2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: This is the definition of the Audio Equalizer effect class.
19 #ifndef CAUDIOEQUALIZER_H
20 #define CAUDIOEQUALIZER_H
25 #include <AudioEffectBase.h>
26 #include <AudioEqualizerData.h>
27 #include <MCustomInterface.h>
30 const TUid KUidAudioEqualizerEffect = {0x1020382A};
32 // FORWARD DELCARATION
33 class CMdaAudioConvertUtility;
34 class CMdaAudioPlayerUtility;
35 class CMdaAudioRecorderUtility;
36 class CMdaAudioInputStream;
37 class CMdaAudioOutputStream;
38 class CMdaAudioToneUtility;
39 class CCustomCommandUtility;
40 class CCustomInterfaceUtility;
42 class CMidiClientUtility;
43 class CDrmPlayerUtility;
44 class CVideoPlayerUtility;
49 * This is the Equalizer effect class for managing audio equalizer settings.
51 * @lib AudioEqualizerEffect.lib
55 class CAudioEqualizer : public CAudioEffect
58 public: //New Functions
61 * Factory function for creating the audio equalizer object.
63 * @return pointer to CAudioEqualizer object
65 IMPORT_C static CAudioEqualizer* NewL();
68 * Factory function for creating the audio equalizer object.
70 * @param aUtility A reference to a convert utility
71 * @return pointer to CAudioEqualizer object
73 IMPORT_C static CAudioEqualizer* NewL( CMdaAudioConvertUtility& aUtility );
76 * Factory function for creating the audio equalizer object.
78 * @param aUtility A reference to an audio input stream utility
79 * @return pointer to CAudioEqualizer object
81 IMPORT_C static CAudioEqualizer* NewL( CMdaAudioInputStream& aUtility );
84 * Factory function for creating the audio equalizer object.
86 * @param aUtility A reference to an audio output stream utility
87 * @return pointer to CAudioEqualizer object
89 IMPORT_C static CAudioEqualizer* NewL( CMdaAudioOutputStream& aUtility );
92 * Factory function for creating the audio equalizer object.
94 * @param aUtility A reference to an audio player utility
95 * @return pointer to CAudioEqualizer object
97 IMPORT_C static CAudioEqualizer* NewL( CMdaAudioPlayerUtility& aUtility );
100 * Factory function for creating the audio equalizer object.
102 * @param aUtility A reference to an audio record utility
103 * @param aRecordStream ETrue if the effect is to be applied to the recording,
104 * EFalse if the effect is to be applied only to the playback
105 * @return pointer to CAudioEqualizer object
107 IMPORT_C static CAudioEqualizer* NewL( CMdaAudioRecorderUtility& aUtility, TBool aRecordStream );
110 * Factory function for creating the audio equalizer object.
112 * @param aUtility A reference to an audio tone utility
113 * @return pointer to CAudioEqualizer object
115 IMPORT_C static CAudioEqualizer* NewL( CMdaAudioToneUtility& aUtility );
118 * Factory function for creating the audio equalizer object.
120 * @param aDevSound A reference to a DevSound instance
121 * @return pointer to CAudioEqualizer object
123 IMPORT_C static CAudioEqualizer* NewL( CMMFDevSound& aDevSound );
126 * Factory function for creating the audio equalizer object.
128 * @param aUtility A reference to a custom command utility
129 * @return pointer to CAudioEqualizer object
131 IMPORT_C static CAudioEqualizer* NewL( CCustomCommandUtility* aUtility );
134 * Factory function for creating the audio equalizer object.
136 * @param aCustomInterface A reference to a custom interface
137 * @return pointer to CAudioEqualizer object
139 IMPORT_C static CAudioEqualizer* NewL( MCustomInterface& aCustomInterface );
143 * Factory function for creating the audio equalizer object.
145 * @param CMidiClientUtility A reference to a CMidiClientUtility object
146 * @return pointer to CAudioEqualizer object
148 IMPORT_C static CAudioEqualizer* NewL( CMidiClientUtility& aUtility );
151 * Factory function for creating the audio equalizer object.
153 * @param CDrmPlayerUtility A reference to a CDrmPlayerUtility object
154 * @return pointer to CAudioEqualizer object
156 IMPORT_C static CAudioEqualizer* NewL( CDrmPlayerUtility& aUtility );
159 * Factory function for creating the audio equalizer object.
161 * @param CVideoPlayerUtility A reference to a CVideoPlayerUtility object
162 * @return pointer to CAudioEqualizer object
164 IMPORT_C static CAudioEqualizer* NewL( CVideoPlayerUtility& aUtility );
170 IMPORT_C virtual ~CAudioEqualizer();
173 * Get the band level in mB for the specified band
175 * @param aBand Frequency Band
176 * @return Returns the band level in mB for the specified band
178 IMPORT_C TInt32 BandLevel( TUint8 aBand ) const;
181 * Get the band width in Hz for the specified band.
183 * @param aBand Frequency Band
184 * @return The band width in Hz for the specified band
186 IMPORT_C TInt32 BandWidth( TUint8 aBand ) const;
189 * Get the center frequency in Hz for a given band
191 * @param aBand Frequency Band
192 * @return The center frequency in Hz for a given band.
194 IMPORT_C TInt32 CenterFrequency( TUint8 aBand ) const;
197 * Get the cross-over frequency between the given frequency band (aBand) and the next band
199 * @param aBand Frequency Band
200 * @return Crossover frequency.
202 IMPORT_C TInt32 CrossoverFrequency( TUint8 aBand ) const;
205 * Get the dB range in mB for the equalizer
207 * @param aMin Minimum level in dB
208 * @param aMin Maximum level in dB
210 IMPORT_C void DbLevelLimits( TInt32& aMin, TInt32& aMax );
213 * Get number of equalizer bands.
216 * @return The number of equalizer bands.
218 IMPORT_C TUint8 NumberOfBands() const;
221 * Sets the equalizer band level value in mB, ranging from Min to Max
223 * @param aBand Frequency Band
224 * @param aLevel band level in dB, ranges from DbLevelLimits()
227 IMPORT_C void SetBandLevelL( TInt8 aBand, TInt32 aLevel );
229 public: // functions from base class
233 * Get the unique identifier of the audio effect
235 * @return Unique identifier
237 IMPORT_C TUid Uid() const;
240 protected: // Functions from base classes
244 * Create a package of the effect data
246 * @return A descriptor containing the effect data.
248 IMPORT_C const TDesC8& DoEffectData();
252 * Internal function to unpack effect data
254 * @param aEffectDataBuffer Descriptor containing packed effect data
257 IMPORT_C void SetEffectData( const TDesC8& aEffectDataBuffer );
262 * Private C++ constructor for this class.
266 IMPORT_C CAudioEqualizer();
269 * Create a descriptor containing data for the specified band(s).
271 * @param aBand The frequency band data to package. Valid if aAllBands = EFalse.
272 * @param aAllBands Indicate if data for all bands is requested.
273 * @return A descriptor containing data for specified band.
275 IMPORT_C const TDesC8& DoBandDataL( TUint8 aBand, TBool aAllBands );
278 * Unpack band data from the specified descriptor.
280 * @param aNumberOfBands Number of bands contained in the descriptor.
281 * @param aBandDataBuffer Descriptor containing band data
283 IMPORT_C void SetBandDataL( TInt aNumberOfBands, const TDesC8& aBandDataBuffer );
287 // Equalizer data structure
288 TEfAudioEqualizer iAudioEqualizerData;
289 // Equalizer Band data structure
290 RArray<TEfAudioEqualizerBand> iBandsData;
291 // Data package sent to server
292 TEfAudioEqualizerDataPckg iDataPckgTo;
293 // Band Data package sent to server
294 TEfAudioEqualizerBandDataPckg iBandDataPckgTo;
295 // Bitmask used to indicate change in band data
298 HBufC8* iBandDataBuf;
300 protected: // Friend classes
302 friend class CAudioEqualizerMessageHandler;
303 friend class CAudioEqualizerUtility;
307 #endif // of CAUDIOEQUALIZER_H