You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
760 B
41 lines
760 B
#include "line.h"
|
|
|
|
using namespace daisysp;
|
|
|
|
void Line::Init(float sample_rate)
|
|
{
|
|
sample_rate_ = sample_rate;
|
|
dur_ = 0.5f;
|
|
end_ = 0.0f;
|
|
start_ = 1.0f;
|
|
val_ = 1.0f;
|
|
}
|
|
|
|
void Line::Start(float start, float end, float dur)
|
|
{
|
|
start_ = start;
|
|
end_ = end;
|
|
dur_ = dur;
|
|
inc_ = (end - start) / ((sample_rate_ * dur_));
|
|
val_ = start_;
|
|
finished_ = 0;
|
|
}
|
|
|
|
float Line::Process(uint8_t *finished)
|
|
{
|
|
float out;
|
|
out = val_;
|
|
|
|
if((end_ > start_ && out >= end_) || (end_ < start_ && out <= end_))
|
|
{
|
|
finished_ = 1;
|
|
val_ = end_;
|
|
out = end_;
|
|
}
|
|
else
|
|
{
|
|
val_ += inc_;
|
|
}
|
|
*finished = finished_;
|
|
return out;
|
|
}
|
|
|