Sayonara Player
Fadeable.h
1/* CrossFader.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21/* CrossFader.h */
22
23#ifndef CROSSFADER_H
24#define CROSSFADER_H
25
26#include "Utils/Pimpl.h"
27#include <QThread>
28
29
30namespace PipelineExtensions
31{
32 class Fadeable;
33
39 public QObject
40 {
41 Q_OBJECT
43
44 public:
47 void start(MilliSeconds ms);
48 void stop();
49
50 private slots:
51 void timedOut();
52 };
53
54
60 {
61 PIMPL(Fadeable)
62
63 public:
64
65 enum class FadeMode : unsigned char
66 {
67 NoFading=0,
68 FadeIn,
69 FadeOut
70 };
71
72 Fadeable();
73 Fadeable(const Fadeable& other)=delete;
74
75 virtual ~Fadeable();
76
82 MilliSeconds fadingTimeMs() const;
83
87 void fadeIn();
88
92 void fadeOut();
93
94
95 private:
96 bool initFader(FadeMode mode);
97
98 protected:
99 virtual void stop()=0;
100 virtual void play()=0;
101
106 virtual void postProcessFadeOut()=0;
107
112 virtual void postProcessFadeIn()=0;
113
118 virtual double internalVolume() const=0;
119
124 virtual void setInternalVolume(double vol)=0;
125
130
131
132 private:
133 friend class CrossFadeableTimer;
134 void timedOut();
135 };
136}
137
138#endif // CROSSFADER_H
The CrossFadeableTimer class.
Definition: Fadeable.h:40
The CrossFader class.
Definition: Fadeable.h:60
virtual void setInternalVolume(double vol)=0
set current volume of pipeline
virtual void postProcessFadeIn()=0
Some additional stuff the implementation class wants to do when fading in.
virtual double internalVolume() const =0
get current volume of pipeline
virtual void postProcessFadeOut()=0
Some additional stuff the implementation class wants to do when fading out.
void fadeOut()
start to fade out
MilliSeconds fadingTimeMs() const
get fading time in ms. This is useful to calculate the beginning of the next track
void fadeIn()
start to fade in
void abortFader()
Stops the current fader process.