34 lines
662 B
C++
34 lines
662 B
C++
/*
|
|
==============================================================================
|
|
|
|
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_;
|
|
} |