Jamoma API  0.6.0.a19
CrossFadeQueue.h
1 // CrossFadeQueue.h
2 /***************************************************/
3 /*! \class CrossFadeQueue
4  \brief CrossFadeQueue class
5 
6  This class implements a sound source, which consists
7  of variables that are common to all crossfades, as well as the
8  queue of crossfade events.
9 
10  by Tristan Matthews and Nils Peters, 2007-2008.
11  */
12 /***************************************************/
13 
14 #ifndef _CROSS_FADE_QUEUE_H_
15 #define _CROSS_FADE_QUEUE_H_
16 
17 #include "Properties.h"
18 #include <deque>
19 #include <vector>
20 
21 class CrossFade;
22 
24  private:
25  bool changed_;
26  long fadeThreshold_;
27  long fadeLength_;
28  std::vector<double> fadeTbl_;
29  double sampleRate_;
30  Properties::fadeMode fadeType_;
31  void computeFadeTbl();
32  void notifyCrossFades();
33  std::deque<CrossFade*> fadeQueue_;
34 
35  public:
36  /*! Class constructor, taking a value that determines how great a change in delay time (in samples)
37  there must be to trigger a crossfade, as well as the length of the crossfade, the type of crossfade,
38  and the sample rate.
39  */
40  CrossFadeQueue(long fadeThreshold, long fadeLength, Properties::fadeMode fadeType, double sampleRate);
41 
42  //! Triggers a crossfade, returns true if fade has started.
43  bool startFade();
44 
45  //! Manages cleanup and end of crossfade.
46  void finishFade();
47 
48  //! Returns crossfade table value at given index.
49  double getTblValAt(int index) const;
50 
51  //! Get fade threshold in samples.
52  long fadeThreshold() const;
53  //! Set fade threshold in samples.
54  void fadeThreshold(long newThreshold);
55 
56  //! Get fade time in samples.
57  double fadeLength() const;
58  //! Set fade time in samples.
59  void fadeLength(long newLength);
60 
61  //! Set fade type (LINEAR, COS, COS_SQUARED, TANH, SQRT, LOG, SIGMOID)
62  void fadeFunction(Properties::fadeMode fadeType);
63 
64  //! Out value of crossfade.
65  double tick(double fadeInInput, double fadeOutInput);
66 
67  //! Increment top level crossfade.
68  void increment();
69 
70  //! Return number of crossfades being queued.
71  int size();
72 
73  //! True if a crossfade is underway, false othewise.
74  bool isActive() const;
75 
76  //! True if at beginning of crossfade.
77  bool atStart() const;
78 
79  //! Class destructor.
81 };
82 
83 #endif
84 // vim:sw=4:et:cindent:
long fadeThreshold() const
Get fade threshold in samples.
bool atStart() const
True if at beginning of crossfade.
~CrossFadeQueue()
Class destructor.
bool isActive() const
True if a crossfade is underway, false othewise.
void fadeFunction(Properties::fadeMode fadeType)
Set fade type (LINEAR, COS, COS_SQUARED, TANH, SQRT, LOG, SIGMOID)
CrossFadeQueue(long fadeThreshold, long fadeLength, Properties::fadeMode fadeType, double sampleRate)
CrossFade class.
Definition: CrossFade.h:21
double fadeLength() const
Get fade time in samples.
bool startFade()
Triggers a crossfade, returns true if fade has started.
CrossFadeQueue class.
double getTblValAt(int index) const
Returns crossfade table value at given index.
void increment()
Increment top level crossfade.
void finishFade()
Manages cleanup and end of crossfade.
int size()
Return number of crossfades being queued.
double tick(double fadeInInput, double fadeOutInput)
Out value of crossfade.