Jamoma API  0.6.0.a19
Implementations/Max/source/j.vimic~/Crossfade.cpp
1 // CrossFade.cpp
2 /***************************************************/
3 /*! \class CrossFade
4  \brief CrossFade class
5 
6  This class implements a crossfade event, which occurs
7  when a delay time changes quickly enough that the old
8  delay time must be crossfaded with the new delay time.
9 
10  by Tristan Matthews and Nils Peters, 2007-2008.
11  */
12 /***************************************************/
13 
14 #include "CrossFade.h"
15 #include "CrossFadeQueue.h"
16 #include "Properties.h"
17 
18 extern bool globWarningFlag;
19 extern bool globReportFlag;
20 
21 
23 owner_(owner),
24 fadeLength_(owner.fadeLength()),
25 fadeInIdx_(fadeLength_ - 1),
26 fadeOutIdx_(0)
27 {
28  // post("fadeOutIdx: %d, fadeInIdx: %d, ",fadeOutIdx_, fadeInIdx_);
29  // update fade gains
30  updateGains();
31 }
32 
33 void CrossFade::update(long fadeLength)
34 {
35  fadeLength_ = fadeLength;
36  updateGains();
37 }
38 
39 void CrossFade::updateGains()
40 {
41  // update gain values based on owner's fade table
42  fadeOutGain_ = owner_.getTblValAt(fadeOutIdx_);
43  fadeInGain_ = owner_.getTblValAt(fadeInIdx_);
44 }
45 
46 bool CrossFade::atStart() const
47 {
48  if (fadeOutIdx_ == 0)
49  return true;
50  else
51  return false;
52 }
53 
54 // vim:sw=4:et:cindent:
CrossFade(CrossFadeQueue &owner)
Class constructor, takes CrossFadeQueue that owns it.
bool atStart() const
Returns true if the CrossFade is at step 0.
CrossFadeQueue class.
double getTblValAt(int index) const
Returns crossfade table value at given index.
void update(long fadeLength)
updates the CrossFade with a new fadelength.