Analog synthesis engine for Klang Modular
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.
 
 
 

34 lines
719 B

#ifndef __PHYS_H__
#define __PHYS_H__
#include "../util.h"
#include "delayline.h"
class Physical {
private:
DelayLine<MAX_SAMPLE_PERIOD> dl;
float lp = 0, lp2 = 0;
public:
inline float tick(float pitch) {
int period = roundf(cvToPeriod(pitch));
dl.size = period;
float out = dl.get();
lp *= 0.99f;
lp += 0.90f * (out - lp);
dl.inject(lp, 0);
dl.tick();
lp2 += 0.01f * (out - lp2);
return lp2;
}
inline void pluck() {
float tmp[512];
for(int i = 0; i < 512; ++i) {
tmp[i] = 8.f * (whiteNoise() + whiteNoise() + whiteNoise() + whiteNoise());
}
dl.inject(tmp, 512);
}
};
#endif