wavelength 1.0.0
Loading...
Searching...
No Matches
ramp.h
Go to the documentation of this file.
1#pragma once
2
3#include "math/interpolator.h"
4#include "os/command.h"
5#include "os/ptr.h"
6#include "os/scheduler.h"
7
14class Ramp {
15public:
24 Ramp(Scheduler *pScheduler, float fValue);
25
32 virtual ~Ramp();
33
40 virtual void Apply(float fValue, int nTick) = 0;
41
51 void MoveTo(int nTicks, int nStepTicks, float fTarget);
52
65 void Move(int nTicks, int nStepTicks, float fFrom, float fTarget);
66
73 void Stop();
74
82 float GetValue() const;
83
84private:
93 void Step();
94
95 float mValue; // The current value.
96 Scheduler *mScheduler; // The scheduler the steps are queued on.
97 Ptr<Command> mStepCommand; // The command that runs Step().
98 int mMoving; // Non-zero while a step is queued.
99 LinearInterpolator mInterp; // The value at each tick of the move.
100 int mEndTick; // The tick the move ends at, or -1.
101 int mStepTicks; // The ticks between steps, or -1.
102};
Straight-line interpolator.
Definition interpolator.h:99
Owner of one reference to an Attachment.
Definition ptr.h:16
Ramp(Scheduler *pScheduler, float fValue)
Construct a ramp that holds a value.
float GetValue() const
Report the current value.
void Stop()
Withdraw the next step, leaving the value where it is.
virtual ~Ramp()
Stop the ramp.
void MoveTo(int nTicks, int nStepTicks, float fTarget)
Move from the current value to a target.
void Move(int nTicks, int nStepTicks, float fFrom, float fTarget)
Move from one value to another.
virtual void Apply(float fValue, int nTick)=0
Apply a new value.
Queue of commands that run when the song clock reaches their tick.
Definition scheduler.h:20