Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
aa7d527fbThis file is pinned to the selected release. Download the original to open it in your design tool.
COMP(sim);
HAL_PIN(amp) = M_PI;
HAL_PIN(freq) = 1.0;
HAL_PIN(sin) = 0.0;
HAL_PIN(msin) = 0.0;
HAL_PIN(square) = 0.0;
HAL_PIN(vel) = 0.0;
HAL_PIN(res) = 100000.0;
MEM(float time) = 0.0;
MEM(float amp_) = 0.0;
MEM(float freq_) = 0.0;
RT(
amp_ = PIN(amp) * 0.001 + amp_ * 0.999;
freq_ = ABS(PIN(freq)) * 0.001 + freq_ * 0.999;
float sin_;
float r = PIN(res);
time += period;
if(freq_ * time >= 1.0){ // TODO
time = 0.0;
}
sin_ = amp_ * sinf(freq_ * time * 2.0 * M_PI);
float s = ((int)(sin_ * r)) / r;
PIN(sin) = s;
PIN(msin) = mod(s);
PIN(square) = (sin_ > 0.0) ? (amp_) : (-amp_);
PIN(vel) = mod(((int)(freq_ * time * r * 2.0 * M_PI)) / r);
);
ENDCOMP;