1 #ifndef __AUTO_SPEED_CONTROL_H__
2 #define __AUTO_SPEED_CONTROL_H__
4 #include "DasherComponent.h"
5 #include "DasherTypes.h"
6 #include "DasherView.h"
10 using namespace Dasher
;
12 /// \defgroup AutoSpeed Auto speed control
14 class CAutoSpeedControl
: public Dasher::CDasherComponent
{
16 CAutoSpeedControl(Dasher::CEventHandler
* pEventHandler
, CSettingsStore
* pSettingsStore
, double dFrameRate
);
19 /// AUTO-SPEED-CONTROL
20 /// This is the main speed control function and drives all of auto speed control.
21 /// \param iDasherX non-linear Dasher x coord
22 /// \param iDasherY non-linear Dasher y coord
23 /// \param dFrameRate The current frame rate
24 /// \param pView The current Dasher view class
26 void SpeedControl(myint iDasherX
, myint iDasherY
, double dFrameRate
, CDasherView
*pView
);
28 virtual void HandleEvent(Dasher::CEvent
*pEvent
) {
34 /// AUTO-SPEED-CONTROL
35 /// Calculates the running variance of the angle between the +ve x-axis and the line joining
36 /// the cross hair to the mouse position.
38 inline double Variance();
41 /// AUTO-SPEED-CONTROL
42 /// Updates the exclusion radius for auto speed control.
44 inline double UpdateMinRadius();
47 /// AUTO-SPEED-CONTROL
48 /// Applies changes to the max bit rate depending on the running variance
49 /// of the angle between the +ve x-axis and the line joining
50 /// the cross hair to the mouse position.
52 double UpdateBitrate();
55 /// AUTO-SPEED-CONTROL
56 /// Adapts the number of samples taken so that auto speed control
57 /// is invariant to clock rate and user ability (!!!).
60 inline int UpdateSampleSize(double dFrameRate
);
63 /// AUTO-SPEED-CONTROL
64 /// Updates the *variances* of the two populations of mixture-of-2-Gaussians
65 /// distribution of radii. These are used to calculate the exclusion radius.
67 /// \param dFrameRate The current frame rate
69 void UpdateSigmas(double r
, double dFrameRate
);
71 double m_dBitrate
; // stores max bit rate internally
72 double m_dSampleScale
, m_dSampleOffset
; // internal, control sample size
73 unsigned int m_nSpeedCounter
; // keep track of how many samples
74 unsigned int m_nSpeedSamples
; // upper limit on #samples
75 double m_dSpeedMax
, m_dSpeedMin
; // bit rate always within this range
76 double m_dTier1
, m_dTier2
, m_dTier3
, m_dTier4
; // variance tolerance tiers
77 double m_dChange1
, m_dChange2
, m_dChange3
, m_dChange4
; // fractional changes to bit rate
78 double m_dMinRRate
; // controls rate at which min. r adapts HIGHER===SLOWER!
79 double m_dSensitivity
; // not used, control sensitivity of auto speed control
80 typedef std::deque
<double> DOUBLE_DEQUE
;
81 DOUBLE_DEQUE m_dequeAngles
; // store angles for statistics
83 //variables for adaptive radius calculations...
84 double m_dSigma1
, m_dSigma2
, m_dMinRadius
;