Phonon

volumefadereffect.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Nokia Corporation
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#include "volumefadereffect.h"
24#include "volumefadereffect_p.h"
25#include "volumefaderinterface.h"
26#include "factory_p.h"
27
28#include <qmath.h>
29
30#define PHONON_CLASSNAME VolumeFaderEffect
31#define PHONON_INTERFACENAME VolumeFaderInterface
32
33#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT
34
35namespace Phonon
36{
37PHONON_HEIR_IMPL(Effect)
38
39PHONON_INTERFACE_GETTER(float, volume, d->currentVolume)
40PHONON_INTERFACE_SETTER(setVolume, currentVolume, float)
41PHONON_INTERFACE_GETTER(Phonon::VolumeFaderEffect::FadeCurve, fadeCurve, d->fadeCurve)
42PHONON_INTERFACE_SETTER(setFadeCurve, fadeCurve, Phonon::VolumeFaderEffect::FadeCurve)
43
44#ifndef PHONON_LOG10OVER20
45#define PHONON_LOG10OVER20
46static const double log10over20 = 0.1151292546497022842; // ln(10) / 20
47#endif // PHONON_LOG10OVER20
48
50{
51 return log(volume()) / log10over20;
52}
53
54void VolumeFaderEffect::setVolumeDecibel(double newVolumeDecibel)
55{
56 setVolume(exp(newVolumeDecibel * log10over20));
57}
58
59
60void VolumeFaderEffect::fadeIn(int fadeTime)
61{
62 fadeTo(1.0, fadeTime);
63}
64
66{
67 fadeTo(0.0, fadeTime);
68}
69
70void VolumeFaderEffect::fadeTo(float volume, int fadeTime)
71{
73 if (k_ptr->backendObject())
74 INTERFACE_CALL(fadeTo(volume, fadeTime));
75 else
76 d->currentVolume = volume;
77}
78
79bool VolumeFaderEffectPrivate::aboutToDeleteBackendObject()
80{
81 if (m_backendObject) {
82 currentVolume = pINTERFACE_CALL(volume());
83 fadeCurve = pINTERFACE_CALL(fadeCurve());
84 }
85 return true;
86}
87
88void VolumeFaderEffectPrivate::setupBackendObject()
89{
90 Q_ASSERT(m_backendObject);
91
92 // set up attributes
93 pINTERFACE_CALL(setVolume(currentVolume));
94 pINTERFACE_CALL(setFadeCurve(fadeCurve));
95}
96}
97
98
99#endif //QT_NO_PHONON_VOLUMEFADEREFFECT
100
101#include "moc_volumefadereffect.cpp"
102
103#undef PHONON_CLASSNAME
104// vim: sw=4 ts=4
Audio effect to gradually fade the audio volume.
float volume
This is the current volume of the output as voltage factor.
void fadeIn(int fadeTime)
Tells the Fader to change the volume from the current volume to 100% in fadeTime milliseconds.
double volumeDecibel
This is the current volume of the output in decibel.
void fadeTo(float volume, int fadeTime)
Tells the Fader to change the volume from the current value to volume in fadeTime milliseconds.
void fadeOut(int fadeTime)
Tells the Fader to change the volume from the current volume to 0% in fadeTime milliseconds.
void setVolume(qreal volume)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.