~rantlivelintkale/kantan.lv2

638babf33fc49687f1273d38e824f5588216d355 — Veikka Valtteri Kallinen 4 months ago 8945da6 master
adjust distortion scaling
1 files changed, 8 insertions(+), 6 deletions(-)

M src/main.c
M src/main.c => src/main.c +8 -6
@@ 45,16 45,18 @@ static float distort(const float x, const float d, const float a)
{
	float k;
	if (x > 0.f) {
		k = d*(1.f - a * 0.01);
		k = d*(1.f - a * 0.01f);
	} else {
		k = d;
	}

	k = k - 10.f;
	float y;
	if (k < 0.01f) {
	if (k < -10.f) {
		y = x;
	} else {
		y = 1 / k * atanf(k * x);
		float k_1 = powf(10.0f, -k*0.05f);
		float k_2 = powf(10.0f, k*0.05f);
		y = k_1 * atanf(k_2 * x);
	}

	return y;


@@ 69,9 71,9 @@ static float rms(const float d, const float a, DCFilter *filter)
		const float y_nodc = blockdc(y, filter);
		accm += y_nodc*y_nodc;
	}
	

	const float result = sqrtf(accm / 49);
	

	return result;
}