| 1 |
/* This file is part of the KDE project. |
| 2 |
|
| 3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
|
| 5 |
This library is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU Lesser General Public License as published by |
| 7 |
the Free Software Foundation, either version 2.1 or 3 of the License. |
| 8 |
|
| 9 |
This library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
*/ |
| 18 |
|
| 19 |
#include <AudioEqualizerBase.h> |
| 20 |
#include "audioequalizer.h" |
| 21 |
|
| 22 |
QT_BEGIN_NAMESPACE |
| 23 |
|
| 24 |
using namespace Phonon; |
| 25 |
using namespace Phonon::MMF; |
| 26 |
|
| 27 |
/*! \class MMF::AudioEqualizer |
| 28 |
\internal |
| 29 |
*/ |
| 30 |
|
| 31 |
// Define functions which depend on concrete native effect class name |
| 32 |
PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(AudioEqualizer) |
| 33 |
|
| 34 |
AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& parameters) |
| 35 |
: AbstractAudioEffect::AbstractAudioEffect(parent, parameters) |
| 36 |
{ |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
int AudioEqualizer::effectParameterChanged(const EffectParameter ¶m, |
| 41 |
const QVariant &value) |
| 42 |
{ |
| 43 |
const int band = param.id() - ParameterBase + 1; |
| 44 |
|
| 45 |
const qreal externalLevel = value.toReal(); |
| 46 |
const int internalLevel = param.toInternalValue(externalLevel); |
| 47 |
|
| 48 |
TRAPD(err, concreteEffect()->SetBandLevelL(band, internalLevel)); |
| 49 |
return err; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
//----------------------------------------------------------------------------- |
| 54 |
// Static functions |
| 55 |
//----------------------------------------------------------------------------- |
| 56 |
|
| 57 |
const char* AudioEqualizer::description() |
| 58 |
{ |
| 59 |
return "Audio equalizer"; |
| 60 |
} |
| 61 |
|
| 62 |
bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream, |
| 63 |
QList<EffectParameter>& parameters) |
| 64 |
{ |
| 65 |
bool supported = false; |
| 66 |
|
| 67 |
QScopedPointer<CAudioEqualizer> effect; |
| 68 |
TRAPD(err, effect.reset(CAudioEqualizer::NewL(*stream))); |
| 69 |
|
| 70 |
if (KErrNone == err) { |
| 71 |
supported = true; |
| 72 |
|
| 73 |
TInt32 dbMin; |
| 74 |
TInt32 dbMax; |
| 75 |
effect->DbLevelLimits(dbMin, dbMax); |
| 76 |
|
| 77 |
const int bandCount = effect->NumberOfBands(); |
| 78 |
|
| 79 |
for (int i = 0; i < bandCount; ++i) { |
| 80 |
// For some reason, band IDs are 1-based, as opposed to the |
| 81 |
// 0-based indices used in just about other Symbian API...! |
| 82 |
const int band = i + 1; |
| 83 |
|
| 84 |
const qint32 hz = effect->CenterFrequency(band); |
| 85 |
|
| 86 |
// We pass a floating-point parameter range of -1.0 to +1.0 for |
| 87 |
// each band in order to work around a limitation in |
| 88 |
// Phonon::EffectWidget. See documentation of EffectParameter |
| 89 |
// for more details. |
| 90 |
EffectParameter param( |
| 91 |
/* parameterId */ ParameterBase + i, |
| 92 |
/* name */ tr("%1 Hz").arg(hz), |
| 93 |
/* hints */ EffectParameter::LogarithmicHint, |
| 94 |
/* defaultValue */ QVariant(qreal(0.0)), |
| 95 |
/* minimumValue */ QVariant(qreal(-1.0)), |
| 96 |
/* maximumValue */ QVariant(qreal(+1.0))); |
| 97 |
|
| 98 |
param.setInternalRange(dbMin, dbMax); |
| 99 |
parameters.append(param); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
return supported; |
| 104 |
} |
| 105 |
|
| 106 |
QT_END_NAMESPACE |