portemento, adsr
This commit is contained in:
34
Source/port.cpp
Normal file
34
Source/port.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
port.cpp
|
||||
Created: 25 Oct 2025 2:09:16pm
|
||||
Author: mickl
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "port.h"
|
||||
#include "math.h"
|
||||
|
||||
void Port::Init(float sample_rate, float htime)
|
||||
{
|
||||
yt1_ = 0;
|
||||
prvhtim_ = -100.0;
|
||||
htime_ = htime;
|
||||
|
||||
sample_rate_ = sample_rate;
|
||||
onedsr_ = 1.0 / sample_rate_;
|
||||
}
|
||||
|
||||
float Port::Process(float in)
|
||||
{
|
||||
if (prvhtim_ != htime_)
|
||||
{
|
||||
c2_ = powf(0.5, onedsr_ / htime_);
|
||||
c1_ = 1.0 - c2_;
|
||||
prvhtim_ = htime_;
|
||||
}
|
||||
|
||||
return yt1_ = c1_ * in + c2_ * yt1_;
|
||||
}
|
||||
Reference in New Issue
Block a user