|
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 #ifndef PHONON_MMF_ABSTRACTEFFECT_H |
|
20 #define PHONON_MMF_ABSTRACTEFFECT_H |
|
21 |
|
22 #include "mmf_medianode.h" |
|
23 |
|
24 #include <QScopedPointer> |
|
25 |
|
26 #include <AudioEffectBase.h> |
|
27 |
|
28 #include <Phonon/EffectInterface> |
|
29 #include <Phonon/EffectParameter> |
|
30 #include "audioplayer.h" |
|
31 |
|
32 QT_BEGIN_NAMESPACE |
|
33 |
|
34 namespace Phonon |
|
35 { |
|
36 namespace MMF |
|
37 { |
|
38 |
|
39 /** |
|
40 * @short Base class for all effects for MMF. |
|
41 * |
|
42 * Adhering to Phonon with MMF is cumbersome because of a number of reasons: |
|
43 * |
|
44 * - MMF has no concept of effect chaining. Simply, an effect is a applied |
|
45 * to PlayerUtility, that's it. This means that the order of effects is |
|
46 * undefined. |
|
47 * - We apply an effect to a PlayerUtility, and MediaObject has that one. |
|
48 * However, effects might be created before MediaObject, but nevertheless |
|
49 * needs to work. We solve this by that we are aware of the whole connection |
|
50 * chain, and whenever a connection happens, we walk the chain, find effects |
|
51 * that aren't applied, and apply it if we have a media object. |
|
52 * - There are plenty of corner cases which we don't handle and where behavior |
|
53 * are undefined. For instance, graphs with more than one MediaObject. |
|
54 */ |
|
55 class AbstractAudioEffect : public MediaNode |
|
56 , public EffectInterface |
|
57 { |
|
58 Q_OBJECT |
|
59 Q_INTERFACES(Phonon::EffectInterface) |
|
60 public: |
|
61 AbstractAudioEffect(QObject *parent, |
|
62 const QList<EffectParameter> ¶ms); |
|
63 |
|
64 virtual QList<EffectParameter> parameters() const; |
|
65 virtual QVariant parameterValue(const EffectParameter ¶m) const; |
|
66 virtual void setParameterValue(const EffectParameter &, |
|
67 const QVariant &newValue); |
|
68 |
|
69 virtual bool disconnectMediaNode(MediaNode *target); |
|
70 |
|
71 enum Type |
|
72 { |
|
73 EffectAudioEqualizer = 1, |
|
74 EffectBassBoost, |
|
75 EffectDistanceAttenuation, |
|
76 EffectEnvironmentalReverb, |
|
77 EffectListenerOrientation, |
|
78 EffectLoudness, |
|
79 EffectSourceOrientation, |
|
80 EffectStereoWidening |
|
81 }; |
|
82 |
|
83 protected: |
|
84 virtual bool activateOn(CPlayerType *player) = 0; |
|
85 virtual void parameterChanged(const int id, |
|
86 const QVariant &value) = 0; |
|
87 |
|
88 /** |
|
89 * Part of the implementation of AbstractAudioEffect. Forwards the call to |
|
90 * activateOn(), essentially. |
|
91 */ |
|
92 virtual bool activateOnMediaObject(MediaObject *mo); |
|
93 |
|
94 QScopedPointer<CAudioEffect> m_effect; |
|
95 private: |
|
96 const QList<EffectParameter> m_params; |
|
97 QHash<int, QVariant> m_values; |
|
98 }; |
|
99 } |
|
100 } |
|
101 |
|
102 QT_END_NAMESPACE |
|
103 |
|
104 #endif |
|
105 |