shithub: neindaw

Download patch

ref: db0af510f00edfee776a0c68f36a245830d00c06
parent: c95bf4bfce31c128bc251d3c43122b61fc090747
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Jan 14 20:33:55 EST 2020

kick drum: impulsify gate to reset A's phase

--- a/kick_drum.c
+++ b/kick_drum.c
@@ -31,7 +31,7 @@
 
 typedef struct {
 	
-	int iRec1[2];
+	int iRec0[2];
 	
 } KickDrumSIG0;
 
@@ -85,9 +85,9 @@
 	USED(dsp);
 	/* C99 loop */
 	{
-		int l1;
-		for (l1 = 0; (l1 < 2); l1 = (l1 + 1)) {
-			dsp->iRec1[l1] = 0;
+		int l0;
+		for (l0 = 0; (l0 < 2); l0 = (l0 + 1)) {
+			dsp->iRec0[l0] = 0;
 			
 		}
 		
@@ -101,9 +101,9 @@
 	{
 		int i;
 		for (i = 0; (i < count); i = (i + 1)) {
-			dsp->iRec1[0] = (dsp->iRec1[1] + 1);
-			output[i] = sinf((9.58738019e-05f * (float)(dsp->iRec1[0] + -1)));
-			dsp->iRec1[1] = dsp->iRec1[0];
+			dsp->iRec0[0] = (dsp->iRec0[1] + 1);
+			output[i] = sinf((9.58738019e-05f * (float)(dsp->iRec0[0] + -1)));
+			dsp->iRec0[1] = dsp->iRec0[0];
 			
 		}
 		
@@ -124,7 +124,6 @@
 typedef struct {
 	
 	FAUSTFLOAT fHslider0;
-	float fRec0[2];
 	FAUSTFLOAT fButton0;
 	float fVec0[2];
 	int fSamplingFreq;
@@ -136,15 +135,15 @@
 	FAUSTFLOAT fHslider3;
 	FAUSTFLOAT fHslider4;
 	float fVec1[2];
-	float fRec3[2];
-	float fConst2;
 	float fRec2[2];
+	float fConst2;
+	float fRec1[2];
 	FAUSTFLOAT fHslider5;
-	float fRec4[2];
+	float fRec3[2];
 	FAUSTFLOAT fHslider6;
 	FAUSTFLOAT fHslider7;
-	float fRec6[2];
 	float fRec5[2];
+	float fRec4[2];
 	
 } KickDrum;
 
@@ -176,8 +175,6 @@
 	m->declare(m->metaInterface, "name", "Kick Drum");
 	m->declare(m->metaInterface, "oscillators.lib/name", "Faust Oscillator Library");
 	m->declare(m->metaInterface, "oscillators.lib/version", "0.0");
-	m->declare(m->metaInterface, "signals.lib/name", "Faust Signal Routing Library");
-	m->declare(m->metaInterface, "signals.lib/version", "0.0");
 }
 
 int getSampleRateKickDrum(KickDrum* dsp) {
@@ -252,9 +249,9 @@
 	USED(dsp);
 	/* C99 loop */
 	{
-		int l0;
-		for (l0 = 0; (l0 < 2); l0 = (l0 + 1)) {
-			dsp->fRec0[l0] = 0.0f;
+		int l1;
+		for (l1 = 0; (l1 < 2); l1 = (l1 + 1)) {
+			dsp->fVec0[l1] = 0.0f;
 			
 		}
 		
@@ -263,7 +260,7 @@
 	{
 		int l2;
 		for (l2 = 0; (l2 < 2); l2 = (l2 + 1)) {
-			dsp->fVec0[l2] = 0.0f;
+			dsp->fVec1[l2] = 0.0f;
 			
 		}
 		
@@ -272,7 +269,7 @@
 	{
 		int l3;
 		for (l3 = 0; (l3 < 2); l3 = (l3 + 1)) {
-			dsp->fVec1[l3] = 0.0f;
+			dsp->fRec2[l3] = 0.0f;
 			
 		}
 		
@@ -281,7 +278,7 @@
 	{
 		int l4;
 		for (l4 = 0; (l4 < 2); l4 = (l4 + 1)) {
-			dsp->fRec3[l4] = 0.0f;
+			dsp->fRec1[l4] = 0.0f;
 			
 		}
 		
@@ -290,7 +287,7 @@
 	{
 		int l5;
 		for (l5 = 0; (l5 < 2); l5 = (l5 + 1)) {
-			dsp->fRec2[l5] = 0.0f;
+			dsp->fRec3[l5] = 0.0f;
 			
 		}
 		
@@ -299,7 +296,7 @@
 	{
 		int l6;
 		for (l6 = 0; (l6 < 2); l6 = (l6 + 1)) {
-			dsp->fRec4[l6] = 0.0f;
+			dsp->fRec5[l6] = 0.0f;
 			
 		}
 		
@@ -308,20 +305,11 @@
 	{
 		int l7;
 		for (l7 = 0; (l7 < 2); l7 = (l7 + 1)) {
-			dsp->fRec6[l7] = 0.0f;
+			dsp->fRec4[l7] = 0.0f;
 			
 		}
 		
 	}
-	/* C99 loop */
-	{
-		int l8;
-		for (l8 = 0; (l8 < 2); l8 = (l8 + 1)) {
-			dsp->fRec5[l8] = 0.0f;
-			
-		}
-		
-	}
 	
 }
 
@@ -395,54 +383,52 @@
 	USED(inputs);
 	USED(dsp);
 	FAUSTFLOAT* output0 = outputs[0];
-	float fSlow0 = (0.00100000005f * (float)dsp->fHslider0);
+	float fSlow0 = (float)dsp->fHslider0;
 	float fSlow1 = (float)dsp->fButton0;
-	int iSlow2 = ((fSlow1 == 0.0f) > 0);
-	int iSlow3 = (1 - iSlow2);
-	float fSlow4 = (float)dsp->fHslider1;
-	float fSlow5 = ((float)dsp->fHslider2 * (float)dsp->fCheckbox0);
-	float fSlow6 = (float)dsp->fHslider3;
-	float fSlow7 = (fSlow6 + (float)dsp->fHslider4);
-	float fSlow8 = (dsp->fConst0 * fSlow7);
-	float fSlow9 = (dsp->fConst0 * fSlow6);
-	float fSlow10 = (1.0f / (0.0f - (dsp->fConst0 * (fSlow6 - fSlow7))));
-	float fSlow11 = (dsp->fConst2 / fSlow6);
-	int iSlow12 = (fSlow1 > 0.0f);
-	int iSlow13 = (iSlow12 > 0);
-	float fSlow14 = (float)dsp->fHslider5;
-	float fSlow15 = (dsp->fConst0 * fSlow14);
-	float fSlow16 = (float)dsp->fHslider6;
-	float fSlow17 = (fSlow16 + (float)dsp->fHslider7);
-	float fSlow18 = (dsp->fConst0 * fSlow17);
-	float fSlow19 = (dsp->fConst0 * fSlow16);
-	float fSlow20 = (9.99999997e-07f * fSlow1);
-	float fSlow21 = ((fSlow20 + -1.0f) / (0.0f - (dsp->fConst0 * (fSlow16 - fSlow17))));
-	float fSlow22 = (dsp->fConst2 / fSlow16);
-	float fSlow23 = (dsp->fConst2 / fSlow14);
+	float fSlow2 = (float)dsp->fHslider1;
+	float fSlow3 = ((float)dsp->fHslider2 * (float)dsp->fCheckbox0);
+	float fSlow4 = (float)dsp->fHslider3;
+	float fSlow5 = (fSlow4 + (float)dsp->fHslider4);
+	float fSlow6 = (dsp->fConst0 * fSlow5);
+	float fSlow7 = (dsp->fConst0 * fSlow4);
+	float fSlow8 = (1.0f / (0.0f - (dsp->fConst0 * (fSlow4 - fSlow5))));
+	float fSlow9 = (dsp->fConst2 / fSlow4);
+	int iSlow10 = (fSlow1 > 0.0f);
+	int iSlow11 = (iSlow10 > 0);
+	float fSlow12 = (float)dsp->fHslider5;
+	float fSlow13 = (dsp->fConst0 * fSlow12);
+	int iSlow14 = ((fSlow1 == 0.0f) > 0);
+	float fSlow15 = (float)dsp->fHslider6;
+	float fSlow16 = (fSlow15 + (float)dsp->fHslider7);
+	float fSlow17 = (dsp->fConst0 * fSlow16);
+	float fSlow18 = (dsp->fConst0 * fSlow15);
+	float fSlow19 = (9.99999997e-07f * fSlow1);
+	float fSlow20 = ((fSlow19 + -1.0f) / (0.0f - (dsp->fConst0 * (fSlow15 - fSlow16))));
+	float fSlow21 = (dsp->fConst2 / fSlow15);
+	float fSlow22 = (dsp->fConst2 / fSlow12);
 	/* C99 loop */
 	{
 		int i;
 		for (i = 0; (i < count); i = (i + 1)) {
-			dsp->fRec0[0] = (fSlow0 + (0.999000013f * dsp->fRec0[1]));
 			dsp->fVec0[0] = fSlow1;
-			dsp->fVec1[0] = fSlow7;
-			dsp->fRec3[0] = ((((fSlow1 - dsp->fVec0[1]) > 0.0f) > 0)?0.0f:min(fSlow8, ((dsp->fRec3[1] + (dsp->fConst0 * (fSlow7 - dsp->fVec1[1]))) + 1.0f)));
-			int iTemp0 = (dsp->fRec3[0] < fSlow9);
-			float fTemp1 = (((float)iSlow3 * dsp->fRec2[1]) + (dsp->fConst1 * (fSlow4 + (fSlow5 * (iTemp0?((dsp->fRec3[0] < 0.0f)?0.0f:(iTemp0?(fSlow11 * dsp->fRec3[0]):1.0f)):((dsp->fRec3[0] < fSlow8)?((fSlow10 * (0.0f - (dsp->fRec3[0] - fSlow9))) + 1.0f):0.0f))))));
-			dsp->fRec2[0] = (fTemp1 - floorf(fTemp1));
-			dsp->fRec4[0] = (iSlow13?0.0f:min(fSlow15, (dsp->fRec4[1] + 1.0f)));
-			dsp->fRec6[0] = (iSlow2?0.0f:min(fSlow18, (dsp->fRec6[1] + 1.0f)));
-			int iTemp2 = (dsp->fRec6[0] < fSlow19);
-			dsp->fRec5[0] = (iSlow12?((float)iSlow12 * (iTemp2?((dsp->fRec6[0] < 0.0f)?0.0f:(iTemp2?(fSlow22 * dsp->fRec6[0]):1.0f)):((dsp->fRec6[0] < fSlow18)?((fSlow21 * (dsp->fRec6[0] - fSlow19)) + 1.0f):fSlow20))):dsp->fRec5[1]);
-			output0[i] = (FAUSTFLOAT)((dsp->fRec0[0] * ftbl0KickDrumSIG0[(int)(65536.0f * dsp->fRec2[0])]) * ((dsp->fRec4[0] < 0.0f)?dsp->fRec5[0]:((dsp->fRec4[0] < fSlow15)?(dsp->fRec5[0] + (fSlow23 * (dsp->fRec4[0] * (0.0f - dsp->fRec5[0])))):0.0f)));
-			dsp->fRec0[1] = dsp->fRec0[0];
+			int iTemp0 = (((fSlow1 - dsp->fVec0[1]) > 0.0f) > 0);
+			dsp->fVec1[0] = fSlow5;
+			dsp->fRec2[0] = (iTemp0?0.0f:min(fSlow6, ((dsp->fRec2[1] + (dsp->fConst0 * (fSlow5 - dsp->fVec1[1]))) + 1.0f)));
+			int iTemp1 = (dsp->fRec2[0] < fSlow7);
+			float fTemp2 = ((dsp->fRec1[1] * (float)(1 - iTemp0)) + (dsp->fConst1 * (fSlow2 + (fSlow3 * (iTemp1?((dsp->fRec2[0] < 0.0f)?0.0f:(iTemp1?(fSlow9 * dsp->fRec2[0]):1.0f)):((dsp->fRec2[0] < fSlow6)?((fSlow8 * (0.0f - (dsp->fRec2[0] - fSlow7))) + 1.0f):0.0f))))));
+			dsp->fRec1[0] = (fTemp2 - floorf(fTemp2));
+			dsp->fRec3[0] = (iSlow11?0.0f:min(fSlow13, (dsp->fRec3[1] + 1.0f)));
+			dsp->fRec5[0] = (iSlow14?0.0f:min(fSlow17, (dsp->fRec5[1] + 1.0f)));
+			int iTemp3 = (dsp->fRec5[0] < fSlow18);
+			dsp->fRec4[0] = (iSlow10?((float)iSlow10 * (iTemp3?((dsp->fRec5[0] < 0.0f)?0.0f:(iTemp3?(fSlow21 * dsp->fRec5[0]):1.0f)):((dsp->fRec5[0] < fSlow17)?((fSlow20 * (dsp->fRec5[0] - fSlow18)) + 1.0f):fSlow19))):dsp->fRec4[1]);
+			output0[i] = (FAUSTFLOAT)(fSlow0 * (ftbl0KickDrumSIG0[(int)(65536.0f * dsp->fRec1[0])] * ((dsp->fRec3[0] < 0.0f)?dsp->fRec4[0]:((dsp->fRec3[0] < fSlow13)?(dsp->fRec4[0] + (fSlow22 * (dsp->fRec3[0] * (0.0f - dsp->fRec4[0])))):0.0f))));
 			dsp->fVec0[1] = dsp->fVec0[0];
 			dsp->fVec1[1] = dsp->fVec1[0];
-			dsp->fRec3[1] = dsp->fRec3[0];
 			dsp->fRec2[1] = dsp->fRec2[0];
-			dsp->fRec4[1] = dsp->fRec4[0];
-			dsp->fRec6[1] = dsp->fRec6[0];
+			dsp->fRec1[1] = dsp->fRec1[0];
+			dsp->fRec3[1] = dsp->fRec3[0];
 			dsp->fRec5[1] = dsp->fRec5[0];
+			dsp->fRec4[1] = dsp->fRec4[0];
 			
 		}
 		
--- a/kick_drum.dsp
+++ b/kick_drum.dsp
@@ -14,4 +14,4 @@
 gain = hslider("v:Control/[0]Gain[style:knob]", 1, 0, 1, 0.01);
 gate = button("v:Control/[1]Gate");
 
-process = os.hs_oscsin(aFreq + bFreq*en.ar(bA, bR, gate), gate == 0) * si.smoo(gain) * en.adsr(aA, aD, 0.000001, aR, gate);
+process = os.hs_oscsin(aFreq + bFreq*en.ar(bA, bR, gate), gate : ba.impulsify) * gain * en.adsr(aA, aD, 0.000001, aR, gate);