1
/* This file is part of the KDE project.
3
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
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.
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.
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/>.
19
#include <EnvironmentalReverbBase.h>
20
#include "environmentalreverb.h"
24
using namespace Phonon;
25
using namespace Phonon::MMF;
27
/*! \class MMF::EnvironmentalReverb
31
// Define functions which depend on concrete native effect class name
32
PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(EnvironmentalReverb)
36
DecayHFRatio = AbstractAudioEffect::ParameterBase,
48
EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList<EffectParameter>& parameters)
49
: AbstractAudioEffect::AbstractAudioEffect(parent, parameters)
54
int EnvironmentalReverb::effectParameterChanged(const EffectParameter ¶m,
55
const QVariant &value)
57
const qreal externalLevel = value.toReal();
58
const int internalLevel = param.toInternalValue(externalLevel);
64
TRAP(err, concreteEffect()->SetDecayHFRatioL(internalLevel));
67
TRAP(err, concreteEffect()->SetDecayTimeL(internalLevel));
70
TRAP(err, concreteEffect()->SetDensityL(internalLevel));
73
TRAP(err, concreteEffect()->SetDiffusionL(internalLevel));
75
case ReflectionsDelay:
76
TRAP(err, concreteEffect()->SetReflectionsDelayL(internalLevel));
78
case ReflectionsLevel:
79
TRAP(err, concreteEffect()->SetReflectionsLevelL(internalLevel));
82
TRAP(err, concreteEffect()->SetReverbDelayL(internalLevel));
85
TRAP(err, concreteEffect()->SetReverbLevelL(internalLevel));
88
TRAP(err, concreteEffect()->SetRoomHFLevelL(internalLevel));
91
TRAP(err, concreteEffect()->SetRoomLevelL(internalLevel));
94
Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown parameter");
101
//-----------------------------------------------------------------------------
103
//-----------------------------------------------------------------------------
105
const char* EnvironmentalReverb::description()
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)
115
const qreal externalDefaultValue =
116
Phonon::MMF::EffectParameter::toExternalValue
117
(defaultValue, minValue, maxValue);
119
Phonon::MMF::EffectParameter param(id, name, hint,
120
/* defaultValue */ QVariant(externalDefaultValue),
121
/* minimumValue */ QVariant(qreal(-1.0)),
122
/* maximumValue */ QVariant(qreal(+1.0)));
124
param.setInternalRange(minValue, maxValue);
128
bool EnvironmentalReverb::getParameters(CMdaAudioOutputStream *stream,
129
QList<EffectParameter>& parameters)
131
bool supported = false;
133
QScopedPointer<CEnvironmentalReverb> effect;
134
TRAPD(err, effect.reset(CEnvironmentalReverb::NewL(*stream)));
136
if (KErrNone == err) {
142
effect->DecayHFRatioRange(umin, umax);
143
//: DecayHFRatio: Ratio of high-frequency decay time to the value specified by
145
parameters.append(createParameter(
146
DecayHFRatio, tr("Decay HF ratio (%)"), effect->DecayHFRatio(),
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(),
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));
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));
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()));
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));
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()));
187
effect->ReverbLevelRange(min, max);
188
//: ReverbLevel Amplitude of reverberations. This value is
189
//: corrected by the RoomLevel to give the final reverberation
191
parameters.append(createParameter(
192
ReverbLevel, tr("Reverb level (mB)"), effect->ReverbLevel(),
193
min, max, EffectParameter::LogarithmicHint));
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(),
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));