summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/audioequalizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/phonon/mmf/audioequalizer.cpp')
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.cpp103
1 files changed, 51 insertions, 52 deletions
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp
index c2936c5..1d2bbd4 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.cpp
+++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp
@@ -28,80 +28,79 @@ using namespace Phonon::MMF;
\internal
*/
-AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, createParams())
+// Define functions which depend on concrete native effect class name
+PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(AudioEqualizer)
+
+AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& parameters)
+ : AbstractAudioEffect::AbstractAudioEffect(parent, parameters)
{
+
}
-void AudioEqualizer::parameterChanged(const int pid,
+int AudioEqualizer::effectParameterChanged(const EffectParameter &param,
const QVariant &value)
{
- if (m_effect.data()) {
- const int band = pid;
- const int level = value.toInt();
- setBandLevel(band, level);
- }
-}
+ const int band = param.id() - ParameterBase + 1;
-void AudioEqualizer::connectAudioPlayer(AudioPlayer::NativePlayer *player)
-{
- CAudioEqualizer *ptr = 0;
- QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player));
- m_effect.reset(ptr);
-}
+ const qreal externalLevel = value.toReal();
+ const int internalLevel = param.toInternalValue(externalLevel);
-void AudioEqualizer::applyParameters()
-{
- if (m_effect.data()) {
- EffectParameter param;
- foreach (param, parameters()) {
- const int band = param.id();
- const int level = parameterValue(param).toInt();
- setBandLevel(band, level);
- }
- }
+ TRAPD(err, concreteEffect()->SetBandLevelL(band, internalLevel));
+ return err;
}
-void AudioEqualizer::setBandLevel(int band, int level)
+
+//-----------------------------------------------------------------------------
+// Static functions
+//-----------------------------------------------------------------------------
+
+const char* AudioEqualizer::description()
{
- CAudioEqualizer *const effect = static_cast<CAudioEqualizer *>(m_effect.data());
- // TODO: handle audio effect errors
- TRAP_IGNORE(effect->SetBandLevelL(band, level));
+ return "Audio equalizer";
}
-QList<EffectParameter> AudioEqualizer::createParams()
+bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream,
+ QList<EffectParameter>& parameters)
{
- QList<EffectParameter> retval;
+ bool supported = false;
+
+ QScopedPointer<CAudioEqualizer> effect;
+ TRAPD(err, effect.reset(CAudioEqualizer::NewL(*stream)));
- // We temporarily create an AudioPlayer, and run the effect on it, so
- // we can extract the readonly data we need.
- AudioPlayer dummyPlayer;
+ if (KErrNone == err) {
+ supported = true;
- CAudioEqualizer *eqPtr = 0;
- QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.nativePlayer()));
- QScopedPointer<CAudioEqualizer> e(eqPtr);
+ TInt32 dbMin;
+ TInt32 dbMax;
+ effect->DbLevelLimits(dbMin, dbMax);
- TInt32 dbMin;
- TInt32 dbMax;
- e->DbLevelLimits(dbMin, dbMax);
+ const int bandCount = effect->NumberOfBands();
- const int bandCount = e->NumberOfBands();
+ for (int i = 0; i < bandCount; ++i) {
+ // For some reason, band IDs are 1-based, as opposed to the
+ // 0-based indices used in just about other Symbian API...!
+ const int band = i + 1;
- for (int i = 0; i < bandCount; ++i) {
- const qint32 hz = e->CenterFrequency(i);
+ const qint32 hz = effect->CenterFrequency(band);
- const qint32 defVol = e->BandLevel(i);
+ // We pass a floating-point parameter range of -1.0 to +1.0 for
+ // each band in order to work around a limitation in
+ // Phonon::EffectWidget. See documentation of EffectParameter
+ // for more details.
+ EffectParameter param(
+ /* parameterId */ ParameterBase + i,
+ /* name */ tr("%1 Hz").arg(hz),
+ /* hints */ EffectParameter::LogarithmicHint,
+ /* defaultValue */ QVariant(qreal(0.0)),
+ /* minimumValue */ QVariant(qreal(-1.0)),
+ /* maximumValue */ QVariant(qreal(+1.0)));
- retval.append(EffectParameter(i,
- tr("Frequency band, %1 Hz").arg(hz),
- EffectParameter::LogarithmicHint,
- QVariant(qint32(defVol)),
- QVariant(qint32(dbMin)),
- QVariant(qint32(dbMax)),
- QVariantList(),
- QString()));
+ param.setInternalRange(dbMin, dbMax);
+ parameters.append(param);
+ }
}
- return retval;
+ return supported;
}
QT_END_NAMESPACE