| 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 |
#ifndef PHONON_VOLUMEFADEREFFECT_H |
| 24 |
#define PHONON_VOLUMEFADEREFFECT_H |
| 25 |
|
| 26 |
#include "phonon_export.h" |
| 27 |
#include "effect.h" |
| 28 |
|
| 29 |
QT_BEGIN_HEADER |
| 30 |
QT_BEGIN_NAMESPACE |
| 31 |
|
| 32 |
#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT |
| 33 |
|
| 34 |
namespace Phonon |
| 35 |
{ |
| 36 |
class VolumeFaderEffectPrivate; |
| 37 |
|
| 38 |
/** \class VolumeFaderEffect volumefadereffect.h Phonon/VolumeFaderEffect |
| 39 |
* Audio effect to gradually fade the audio volume. |
| 40 |
* |
| 41 |
* This effect differs from gradually changing the output volume in that |
| 42 |
* a dedicated effect can change the volume in the smallest possible |
| 43 |
* steps while every other volume control will make more or less |
| 44 |
* noticeable steps. |
| 45 |
* |
| 46 |
* \ingroup PhononEffects |
| 47 |
* \author Matthias Kretz <kretz@kde.org> |
| 48 |
* \see AudioOutput::volume |
| 49 |
*/ |
| 50 |
class PHONON_EXPORT VolumeFaderEffect : public Effect |
| 51 |
{ |
| 52 |
Q_OBJECT |
| 53 |
K_DECLARE_PRIVATE(VolumeFaderEffect) |
| 54 |
PHONON_HEIR(VolumeFaderEffect) |
| 55 |
Q_ENUMS(FadeCurve) |
| 56 |
/** |
| 57 |
* This is the current volume of the output as voltage factor. |
| 58 |
* Setting this property changes the volume immediately. |
| 59 |
* |
| 60 |
* 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% |
| 61 |
* |
| 62 |
* \see volumeDecibel |
| 63 |
*/ |
| 64 |
Q_PROPERTY(float volume READ volume WRITE setVolume) |
| 65 |
/** |
| 66 |
* This is the current volume of the output in decibel. |
| 67 |
* Setting this property changes the volume immediately. |
| 68 |
* |
| 69 |
* 0 dB means no change in volume, -6dB means an attenuation of the |
| 70 |
* voltage to 50% and an attenuation of the power to 25%, -inf dB means |
| 71 |
* silence. |
| 72 |
* |
| 73 |
* \see volume |
| 74 |
*/ |
| 75 |
Q_PROPERTY(double volumeDecibel READ volumeDecibel WRITE setVolumeDecibel) |
| 76 |
/** |
| 77 |
* This property holds the fade curve to be used for the fadeIn(), fadeOut() |
| 78 |
* and fadeTo() slots. |
| 79 |
* |
| 80 |
* Defaults to Fade3Decibel. |
| 81 |
* |
| 82 |
* \see FadeCurve |
| 83 |
*/ |
| 84 |
Q_PROPERTY(FadeCurve fadeCurve READ fadeCurve WRITE setFadeCurve) |
| 85 |
public: |
| 86 |
/** |
| 87 |
* Determines the curve of the volume change. |
| 88 |
*/ |
| 89 |
enum FadeCurve { |
| 90 |
/** |
| 91 |
* "Crossfade curve" / "fast" fade out |
| 92 |
* |
| 93 |
* Often the best fade for a crossfade, as after half of the |
| 94 |
* time the volume reached -3dB. This means that half the |
| 95 |
* possible power (which is proportional to the square of the |
| 96 |
* voltage) is reached. Summed, the maximum power of two audio |
| 97 |
* signals fading with a -3dB curve will always be equal. |
| 98 |
* |
| 99 |
* For fading in or out the -3dB curve is too abrupt in the end. |
| 100 |
* |
| 101 |
* This is the default fade curve. |
| 102 |
*/ |
| 103 |
Fade3Decibel, |
| 104 |
/** |
| 105 |
* "Linear" fade out |
| 106 |
* |
| 107 |
* With a -6dB fade curve after half of the fading time -6dB has |
| 108 |
* been reached. -6dB is equal to half of the voltage meaning |
| 109 |
* that the voltage multiplier changes linearly from the start |
| 110 |
* of the fade to the end. |
| 111 |
*/ |
| 112 |
Fade6Decibel, |
| 113 |
/** |
| 114 |
* "slow" fade out |
| 115 |
* |
| 116 |
* After half of the fade time -9dB are reached. So the fade is |
| 117 |
* fast in the beginning and slow in the end. This is a good |
| 118 |
* fade for ending music. |
| 119 |
*/ |
| 120 |
Fade9Decibel, |
| 121 |
/** |
| 122 |
* more extreme version of the -9dB fade |
| 123 |
*/ |
| 124 |
Fade12Decibel |
| 125 |
}; |
| 126 |
|
| 127 |
float volume() const; |
| 128 |
double volumeDecibel() const; |
| 129 |
|
| 130 |
FadeCurve fadeCurve() const; |
| 131 |
|
| 132 |
public Q_SLOTS: |
| 133 |
/** |
| 134 |
* Tells the Fader to change the volume from the current volume to 100% |
| 135 |
* in \p fadeTime milliseconds. |
| 136 |
* Short for \c fadeTo(1.0, fadeTime). |
| 137 |
* |
| 138 |
* \param fadeTime the fade duration in milliseconds |
| 139 |
* |
| 140 |
* \see fadeTo |
| 141 |
* \see volume |
| 142 |
*/ |
| 143 |
void fadeIn(int fadeTime); |
| 144 |
|
| 145 |
/** |
| 146 |
* Tells the Fader to change the volume from the current volume to 0% |
| 147 |
* in \p fadeTime milliseconds. |
| 148 |
* Short for \c fadeTo(0.0, fadeTime). |
| 149 |
* |
| 150 |
* \param fadeTime the fade duration in milliseconds |
| 151 |
* |
| 152 |
* \see fadeTo |
| 153 |
*/ |
| 154 |
void fadeOut(int fadeTime); |
| 155 |
|
| 156 |
void setVolume(float volume); |
| 157 |
void setVolumeDecibel(double volumeDecibel); |
| 158 |
|
| 159 |
void setFadeCurve(FadeCurve curve); |
| 160 |
|
| 161 |
/** |
| 162 |
* Tells the Fader to change the volume from the current value to |
| 163 |
* \p volume in \p fadeTime milliseconds |
| 164 |
* |
| 165 |
* \see fadeIn |
| 166 |
* \see fadeOut |
| 167 |
*/ |
| 168 |
void fadeTo(float volume, int fadeTime); |
| 169 |
}; |
| 170 |
} //namespace Phonon |
| 171 |
|
| 172 |
#endif //QT_NO_PHONON_VOLUMEFADEREFFECT |
| 173 |
|
| 174 |
QT_END_NAMESPACE |
| 175 |
QT_END_HEADER |
| 176 |
|
| 177 |
// vim: sw=4 ts=4 tw=80 |
| 178 |
#endif // PHONON_VOLUMEFADEREFFECT_H |