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
#ifndef Phonon_QT7_AUDIOMIXER_H
19
#define Phonon_QT7_AUDIOMIXER_H
20
21
#include <QtCore/QObject>
22
#include <QtCore/QTime>
23
#include <QtCore/QEvent>
24
#include <phonon/effectinterface.h>
25
#include <phonon/effectparameter.h>
26
#include <phonon/volumefaderinterface.h>
27
#include "medianode.h"
28
#include "audionode.h"
29
30
QT_BEGIN_NAMESPACE
31
32
namespace Phonon
33
{
34
namespace QT7
35
{
36
    class AudioMixerAudioNode : public AudioNode
37
    {
38
        public:
39
            AudioMixerAudioNode();
40
            void setVolume(float volume, int bus = 0);
41
            float volume(int bus = 0);
42
43
        protected:
44
            ComponentDescription getAudioNodeDescription() const;
45
            void initializeAudioUnit();
46
47
        private:
48
            friend class AudioMixer;
49
            int m_numberOfBusses;
50
            float m_volume;
51
    };
52
53
    class AudioMixer : public MediaNode, Phonon::EffectInterface, Phonon::VolumeFaderInterface
54
    {
55
        Q_OBJECT
56
        Q_INTERFACES(Phonon::EffectInterface Phonon::VolumeFaderInterface)
57
58
        public:
59
            AudioMixer(QObject *parent = 0);
60
            ~AudioMixer();
61
            AudioMixerAudioNode *m_audioNode;
62
            Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve;
63
64
            int m_fadeTimer;
65
            int m_fadeDuration;
66
            float m_fadeToVolume;
67
            float m_fadeFromVolume;
68
            QTime m_fadeStartTime;
69
70
            // EffectInterface:
71
            QList<Phonon::EffectParameter> parameters() const;
72
            QVariant parameterValue(const Phonon::EffectParameter &parameter) const;
73
            void setParameterValue(const Phonon::EffectParameter &parameter, const QVariant &newValue);
74
75
            // VolumeFaderInterface:
76
            float volume() const;
77
            void setVolume(float volume);
78
            Phonon::VolumeFaderEffect::FadeCurve fadeCurve() const;
79
            void setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve fadeCurve);
80
            void fadeTo(float volume, int fadeTime);
81
            void updateFade();
82
83
        protected:
84
            bool event(QEvent *event);
85
    };
86
87
}} //namespace Phonon::QT7
88
89
QT_END_NAMESPACE
90
91
#endif // Phonon_QT7_AUDIOMIXER_H