diff options
author | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2009-12-10 17:44:39 (GMT) |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-01-11 17:57:19 (GMT) |
commit | f42624c9f88cbbb71d6857566e00348b119d486c (patch) | |
tree | 51b0c64820e77b6db02325ff3841890616343a38 /src | |
parent | bc0e4aa8aec231b43a6033f3f4f12037b02ee64e (diff) | |
download | Qt-f42624c9f88cbbb71d6857566e00348b119d486c.zip Qt-f42624c9f88cbbb71d6857566e00348b119d486c.tar.gz Qt-f42624c9f88cbbb71d6857566e00348b119d486c.tar.bz2 |
Implemented stereo widening effect in Phonon MMF backend
Task-number: QTBUG-4659
Reviewed-by: Espen Riskedal
Diffstat (limited to 'src')
-rw-r--r-- | src/3rdparty/phonon/mmf/effectfactory.cpp | 6 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/stereowidening.cpp | 94 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/stereowidening.h | 62 | ||||
-rw-r--r-- | src/plugins/phonon/mmf/mmf.pro | 2 |
4 files changed, 163 insertions, 1 deletions
diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index ef2ddf7..081f6a3 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -25,6 +25,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "bassboost.h" #include "environmentalreverb.h" #include "loudness.h" +#include "stereowidening.h" #include "effectfactory.h" @@ -80,12 +81,14 @@ AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, case TypeLoudness: effect = new Loudness(parent, parameters); break; + case TypeStereoWidening: + effect = new StereoWidening(parent, parameters); + break; // Not implemented case TypeDistanceAttenuation: case TypeListenerOrientation: case TypeSourceOrientation: - case TypeStereoWidening: // Fall through default: Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); @@ -137,6 +140,7 @@ void EffectFactory::initialize() INITIALIZE_EFFECT(BassBoost) INITIALIZE_EFFECT(EnvironmentalReverb) INITIALIZE_EFFECT(Loudness) + INITIALIZE_EFFECT(StereoWidening) m_initialized = true; } diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp new file mode 100644 index 0000000..4fee1aa --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -0,0 +1,94 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <StereoWideningBase.h> +#include "stereowidening.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(StereoWidening) + +/*! \class MMF::StereoWidening + \internal +*/ + +StereoWidening::StereoWidening(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +void StereoWidening::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); + + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); + + TRAPD(err, concreteEffect()->SetStereoWideningLevelL(internalLevel)); + + // TODO: handle audio effect errors + Q_UNUSED(err); +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* StereoWidening::description() +{ + return "Stereo widening"; +} + +bool StereoWidening::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) +{ + bool supported = false; + + QScopedPointer<CStereoWidening> effect; + TRAPD(err, effect.reset(CStereoWidening::NewL(*stream))); + + if (KErrNone == err) { + supported = true; + + const qreal defaultValue = + Phonon::MMF::EffectParameter::toExternalValue + (effect->StereoWideningLevel(), 0, 100); + + EffectParameter param( + /* parameterId */ 0, + /* name */ tr("Level (%)"), + /* hints */ EffectParameter::IntegerHint, + /* defaultValue */ QVariant(defaultValue), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); + + param.setInternalRange(0, 100); + parameters.append(param); + } + + return supported; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/stereowidening.h b/src/3rdparty/phonon/mmf/stereowidening.h new file mode 100644 index 0000000..249c279 --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_STEREOWIDENING_H +#define PHONON_MMF_STEREOWIDENING_H + +#include "abstractaudioeffect.h" + +class CStereoWidening; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A "bass boost" effect. + */ +class StereoWidening : public AbstractAudioEffect +{ + Q_OBJECT +public: + StereoWidening(QObject *parent, const QList<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual void parameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CStereoWidening *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 78e23d9..cfaca9d 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -41,6 +41,7 @@ HEADERS += \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/mmf_medianode.h \ $$PHONON_MMF_DIR/mmf_videoplayer.h \ + $$PHONON_MMF_DIR/stereowidening.h \ $$PHONON_MMF_DIR/objectdump.h \ $$PHONON_MMF_DIR/objectdump_symbian.h \ $$PHONON_MMF_DIR/objecttree.h \ @@ -66,6 +67,7 @@ SOURCES += \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/mmf_medianode.cpp \ $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ + $$PHONON_MMF_DIR/stereowidening.cpp \ $$PHONON_MMF_DIR/objectdump.cpp \ $$PHONON_MMF_DIR/objectdump_symbian.cpp \ $$PHONON_MMF_DIR/objecttree.cpp \ |