Sayonara Player
CrossFader.h
1 /* CrossFader.h */
2 
3 /* Copyright (C) 2011-2016 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 
22 
23 /* CrossFader.h */
24 
25 #ifndef CROSSFADER_H
26 #define CROSSFADER_H
27 
28 #include <QtGlobal>
29 #include <thread>
30 
31 class FaderThreadData;
32 class FaderThread;
34 {
35 
36 public:
37 
38  enum class FadeMode : quint8 {
39  NoFading=0,
40  FadeIn,
41  FadeOut
42  };
43 
44  CrossFader();
45 
46  virtual double get_current_volume() const =0;
47  virtual void set_current_volume(double vol)=0;
48 
49  quint64 get_fading_time() const;
50 
51  void fade_in();
52  void fade_out();
53 
54  void fader_timed_out();
55 
56 
57 private:
58  FadeMode _fade_mode;
59  double _fade_step;
60  FaderThread* _fader=nullptr;
61 
62  FaderThreadData* _fader_data=nullptr;
63 
64 
65 private:
66  void increase_volume();
67  void decrease_volume();
68 
69  void init_fader();
70 
71 
72 protected:
73 
74  void abort_fader();
75 
76 };
77 
78 
79 #endif // CROSSFADER_H
Definition: CrossFader.h:33