~ubuntu-branches/ubuntu/oneiric/phonon/oneiric-201108111512

« back to all changes in this revision

Viewing changes to mmf/environmentalreverb.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2011-01-24 10:12:11 UTC
  • mfrom: (0.5.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110124101211-w9rew7q0dmwbwhqx
Tags: 4:4.7.0really4.4.4-0ubuntu1
* New upstream release
* Xine and GStreamer backends now split out source, remove build-deps and
  binary packages from debian/control
* Remove 02_no_rpath.patch, now upstream
* Disable kubuntu04_no_va_mangle.patch, no longer applies
* Remove kubuntu_05_gst_codec_installer_window_id.diff, kubuntu_06_forward_events.diff,
  kubuntu_07_include_fix.diff, gstreamer now separate

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 <EnvironmentalReverbBase.h>
20
 
#include "environmentalreverb.h"
21
 
 
22
 
QT_BEGIN_NAMESPACE
23
 
 
24
 
using namespace Phonon;
25
 
using namespace Phonon::MMF;
26
 
 
27
 
/*! \class MMF::EnvironmentalReverb
28
 
  \internal
29
 
*/
30
 
 
31
 
// Define functions which depend on concrete native effect class name
32
 
PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(EnvironmentalReverb)
33
 
 
34
 
enum Parameters
35
 
{
36
 
    DecayHFRatio = AbstractAudioEffect::ParameterBase,
37
 
    DecayTime,
38
 
    Density,
39
 
    Diffusion,
40
 
    ReflectionsDelay,
41
 
    ReflectionsLevel,
42
 
    ReverbDelay,
43
 
    ReverbLevel,
44
 
    RoomHFLevel,
45
 
    RoomLevel
46
 
};
47
 
 
48
 
EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList<EffectParameter>& parameters)
49
 
    :   AbstractAudioEffect::AbstractAudioEffect(parent, parameters)
50
 
{
51
 
 
52
 
}
53
 
 
54
 
int EnvironmentalReverb::effectParameterChanged(const EffectParameter &param,
55
 
                                      const QVariant &value)
56
 
{
57
 
    const qreal externalLevel = value.toReal();
58
 
    const int internalLevel = param.toInternalValue(externalLevel);
59
 
 
60
 
    TInt err = 0;
61
 
 
62
 
    switch(param.id()) {
63
 
    case DecayHFRatio:
64
 
        TRAP(err, concreteEffect()->SetDecayHFRatioL(internalLevel));
65
 
        break;
66
 
    case DecayTime:
67
 
        TRAP(err, concreteEffect()->SetDecayTimeL(internalLevel));
68
 
        break;
69
 
    case Density:
70
 
        TRAP(err, concreteEffect()->SetDensityL(internalLevel));
71
 
        break;
72
 
    case Diffusion:
73
 
        TRAP(err, concreteEffect()->SetDiffusionL(internalLevel));
74
 
        break;
75
 
    case ReflectionsDelay:
76
 
        TRAP(err, concreteEffect()->SetReflectionsDelayL(internalLevel));
77
 
        break;
78
 
    case ReflectionsLevel:
79
 
        TRAP(err, concreteEffect()->SetReflectionsLevelL(internalLevel));
80
 
        break;
81
 
    case ReverbDelay:
82
 
        TRAP(err, concreteEffect()->SetReverbDelayL(internalLevel));
83
 
        break;
84
 
    case ReverbLevel:
85
 
        TRAP(err, concreteEffect()->SetReverbLevelL(internalLevel));
86
 
        break;
87
 
    case RoomHFLevel:
88
 
        TRAP(err, concreteEffect()->SetRoomHFLevelL(internalLevel));
89
 
        break;
90
 
    case RoomLevel:
91
 
        TRAP(err, concreteEffect()->SetRoomLevelL(internalLevel));
92
 
        break;
93
 
    default:
94
 
        Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown parameter");
95
 
    }
96
 
 
97
 
    return err;
98
 
}
99
 
 
100
 
 
101
 
//-----------------------------------------------------------------------------
102
 
// Static functions
103
 
//-----------------------------------------------------------------------------
104
 
 
105
 
const char* EnvironmentalReverb::description()
106
 
{
107
 
    return "Reverb";
108
 
}
109
 
 
110
 
// Internal helper function
111
 
Phonon::MMF::EffectParameter createParameter(int id, const QString &name,
112
 
    int defaultValue, int minValue, int maxValue,
113
 
    Phonon::EffectParameter::Hint hint = Phonon::EffectParameter::IntegerHint)
114
 
{
115
 
    const qreal externalDefaultValue =
116
 
        Phonon::MMF::EffectParameter::toExternalValue
117
 
            (defaultValue, minValue, maxValue);
118
 
 
119
 
    Phonon::MMF::EffectParameter param(id, name, hint,
120
 
        /* defaultValue */       QVariant(externalDefaultValue),
121
 
        /* minimumValue */       QVariant(qreal(-1.0)),
122
 
        /* maximumValue */       QVariant(qreal(+1.0)));
123
 
 
124
 
    param.setInternalRange(minValue, maxValue);
125
 
    return param;
126
 
}
127
 
 
128
 
bool EnvironmentalReverb::getParameters(CMdaAudioOutputStream *stream,
129
 
    QList<EffectParameter>& parameters)
130
 
{
131
 
    bool supported = false;
132
 
 
133
 
    QScopedPointer<CEnvironmentalReverb> effect;
134
 
    TRAPD(err, effect.reset(CEnvironmentalReverb::NewL(*stream)));
135
 
 
136
 
    if (KErrNone == err) {
137
 
        supported = true;
138
 
 
139
 
        TInt32 min, max;
140
 
        TUint32 umin, umax;
141
 
 
142
 
        effect->DecayHFRatioRange(umin, umax);
143
 
        //: DecayHFRatio: Ratio of high-frequency decay time to the value specified by
144
 
        //: DecayTime.
145
 
        parameters.append(createParameter(
146
 
            DecayHFRatio, tr("Decay HF ratio (%)"), effect->DecayHFRatio(),
147
 
            umin, umax));
148
 
 
149
 
        effect->DecayTimeRange(umin, umax);
150
 
        //: DecayTime: Time over which reverberation is diminished.
151
 
        parameters.append(createParameter(
152
 
            DecayTime, tr("Decay time (ms)"), effect->DecayTime(),
153
 
            umin, umax));
154
 
 
155
 
        //: Density Delay between first and subsequent reflections.
156
 
        //: Note that the S60 platform documentation does not make clear
157
 
        //: the distinction between this value and the Diffusion value.
158
 
        parameters.append(createParameter(
159
 
            Density, tr("Density (%)"), effect->Density(), 0, 100));
160
 
 
161
 
        //: Diffusion: Delay between first and subsequent reflections.
162
 
        //: Note that the S60 platform documentation does not make clear
163
 
        //: the distinction between this value and the Density value.
164
 
        parameters.append(createParameter(
165
 
            Diffusion, tr("Diffusion (%)"), effect->Diffusion(), 0, 100));
166
 
 
167
 
        //: ReflectionsDelay: Amount of delay between the arrival the direct
168
 
        //: path from the source and the arrival of the first reflection.
169
 
        parameters.append(createParameter(
170
 
            ReflectionsDelay, tr("Reflections delay (ms)"),
171
 
            effect->ReflectionsDelay(), 0, effect->ReflectionsDelayMax()));
172
 
 
173
 
        effect->ReflectionLevelRange(min, max);
174
 
        //: ReflectionsLevel: Amplitude of reflections. This value is
175
 
        //: corrected by the RoomLevel to give the final reflection amplitude.
176
 
        parameters.append(createParameter(
177
 
            ReflectionsLevel, tr("Reflections level (mB)"),
178
 
            effect->ReflectionsLevel(),
179
 
            min, max, EffectParameter::LogarithmicHint));
180
 
 
181
 
        //: ReverbDelay: Amount of time between arrival of the first
182
 
        //: reflection and start of the late reverberation.
183
 
        parameters.append(createParameter(
184
 
            ReverbDelay, tr("Reverb delay (ms)"), effect->ReverbDelay(),
185
 
            0, effect->ReverbDelayMax()));
186
 
 
187
 
        effect->ReverbLevelRange(min, max);
188
 
        //: ReverbLevel Amplitude of reverberations.  This value is
189
 
        //: corrected by the RoomLevel to give the final reverberation
190
 
        //: amplitude.
191
 
        parameters.append(createParameter(
192
 
            ReverbLevel, tr("Reverb level (mB)"), effect->ReverbLevel(),
193
 
            min, max, EffectParameter::LogarithmicHint));
194
 
 
195
 
        effect->RoomHFLevelRange(min, max);
196
 
        //: RoomHFLevel: Amplitude of low-pass filter used to attenuate the
197
 
        //: high frequency component of reflected sound.
198
 
        parameters.append(createParameter(
199
 
            RoomHFLevel, tr("Room HF level"), effect->RoomHFLevel(),
200
 
            min, max));
201
 
 
202
 
        effect->RoomLevelRange(min, max);
203
 
        //: RoomLevel: Master volume control for all reflected sound.
204
 
        parameters.append(createParameter(
205
 
            RoomLevel, tr("Room level (mB)"), effect->RoomLevel(),
206
 
            min, max, EffectParameter::LogarithmicHint));
207
 
    }
208
 
 
209
 
    return supported;
210
 
}
211
 
 
212
 
QT_END_NAMESPACE