ref: b76149637b10bffdd86e62b86730c4f51922fad6
parent: 9368ed952223b1e15427cbbf8860700ae02ce8e6
parent: 738fd333b9a5a40175a6e6a8b3488cd6aeee7789
author: Jeff Snyder <jeff@snyderphonics.com>
date: Thu Feb 21 06:28:13 EST 2019
added crusher
binary files a/.DS_Store b/.DS_Store differ
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-*.DS_Store
+.DS_Store
*.app
*.a
*.appex
binary files a/LEAF/.DS_Store b/LEAF/.DS_Store differ
--- a/LEAF/Externals/atkdetect.h
+++ b/LEAF/Externals/atkdetect.h
@@ -1,6 +1,10 @@
#ifndef atkdetect_h
#define atkdetect_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*************************************
atkdetect lib written for DSP2G project
@@ -96,5 +100,8 @@
// find largest transient in input block, return index of attack
int atkDetect_detect(t_atkDetect *a, t_float *in);
+#ifdef __cplusplus
+}
+#endif
#endif
--- a/LEAF/Externals/d_fft_mayer.cpp
+++ /dev/null
@@ -1,420 +1,0 @@
-/*
-** FFT and FHT routines
-** Copyright 1988, 1993; Ron Mayer
-**
-** mayer_fht(fz,n);
-** Does a hartley transform of "n" points in the array "fz".
-** mayer_fft(n,real,imag)
-** Does a fourier transform of "n" points of the "real" and
-** "imag" arrays.
-** mayer_ifft(n,real,imag)
-** Does an inverse fourier transform of "n" points of the "real"
-** and "imag" arrays.
-** mayer_realfft(n,real)
-** Does a real-valued fourier transform of "n" points of the
-** "real" array. The real part of the transform ends
-** up in the first half of the array and the imaginary part of the
-** transform ends up in the second half of the array.
-** mayer_realifft(n,real)
-** The inverse of the realfft() routine above.
-**
-**
-** NOTE: This routine uses at least 2 patented algorithms, and may be
-** under the restrictions of a bunch of different organizations.
-** Although I wrote it completely myself, it is kind of a derivative
-** of a routine I once authored and released under the GPL, so it
-** may fall under the free software foundation's restrictions;
-** it was worked on as a Stanford Univ project, so they claim
-** some rights to it; it was further optimized at work here, so
-** I think this company claims parts of it. The patents are
-** held by R. Bracewell (the FHT algorithm) and O. Buneman (the
-** trig generator), both at Stanford Univ.
-** If it were up to me, I'd say go do whatever you want with it;
-** but it would be polite to give credit to the following people
-** if you use this anywhere:
-** Euler - probable inventor of the fourier transform.
-** Gauss - probable inventor of the FFT.
-** Hartley - probable inventor of the hartley transform.
-** Buneman - for a really cool trig generator
-** Mayer(me) - for authoring this particular version and
-** including all the optimizations in one package.
-** Thanks,
-** Ron Mayer; mayer@acuson.com
-**
-*/
-
-/* This is a slightly modified version of Mayer's contribution; write
-* msp@ucsd.edu for the original code. Kudos to Mayer for a fine piece
-* of work. -msp
-*/
-
-/*
- * This, in turn, is an even more slightly modified version of MSP's adaptation
- * of Mayer's contribution. Kudos to all. -Mike Mulshine, Jeff Snyder, Princeton University
- */
-
-#include "../Externals/d_fft_mayer.h"
-
-#define REAL t_sample
-#define GOOD_TRIG
-
-#ifdef GOOD_TRIG
-#else
-#define FAST_TRIG
-#endif
-
-#if defined(GOOD_TRIG)
-#define FHT_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);}
-#define TRIG_VARS \
- int t_lam=0;
-#define TRIG_INIT(k,c,s) \
- { \
- int i; \
- for (i=2 ; i<=k ; i++) \
- {coswrk[i]=costab[i];sinwrk[i]=sintab[i];} \
- t_lam = 0; \
- c = 1; \
- s = 0; \
- }
-#define TRIG_NEXT(k,c,s) \
- { \
- int i,j; \
- (t_lam)++; \
- for (i=0 ; !((1<<i)&t_lam) ; i++); \
- i = k-i; \
- s = sinwrk[i]; \
- c = coswrk[i]; \
- if (i>1) \
- { \
- for (j=k-i+2 ; (1<<j)&t_lam ; j++); \
- j = k - j; \
- sinwrk[i] = halsec[i] * (sinwrk[i-1] + sinwrk[j]); \
- coswrk[i] = halsec[i] * (coswrk[i-1] + coswrk[j]); \
- } \
- }
-#define TRIG_RESET(k,c,s)
-#endif
-
-#if defined(FAST_TRIG)
-#define TRIG_VARS \
- REAL t_c,t_s;
-#define TRIG_INIT(k,c,s) \
- { \
- t_c = costab[k]; \
- t_s = sintab[k]; \
- c = 1; \
- s = 0; \
- }
-#define TRIG_NEXT(k,c,s) \
- { \
- REAL t = c; \
- c = t*t_c - s*t_s; \
- s = t*t_s + s*t_c; \
- }
-#define TRIG_RESET(k,c,s)
-#endif
-
-static REAL halsec[20]=
- {
- 0,
- 0,
- .54119610014619698439972320536638942006107206337801,
- .50979557910415916894193980398784391368261849190893,
- .50241928618815570551167011928012092247859337193963,
- .50060299823519630134550410676638239611758632599591,
- .50015063602065098821477101271097658495974913010340,
- .50003765191554772296778139077905492847503165398345,
- .50000941253588775676512870469186533538523133757983,
- .50000235310628608051401267171204408939326297376426,
- .50000058827484117879868526730916804925780637276181,
- .50000014706860214875463798283871198206179118093251,
- .50000003676714377807315864400643020315103490883972,
- .50000000919178552207366560348853455333939112569380,
- .50000000229794635411562887767906868558991922348920,
- .50000000057448658687873302235147272458812263401372
- };
-static REAL costab[20]=
- {
- .00000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768847,
- .92387953251128675612818318939678828682241662586364,
- .98078528040323044912618223613423903697393373089333,
- .99518472667219688624483695310947992157547486872985,
- .99879545620517239271477160475910069444320361470461,
- .99969881869620422011576564966617219685006108125772,
- .99992470183914454092164649119638322435060646880221,
- .99998117528260114265699043772856771617391725094433,
- .99999529380957617151158012570011989955298763362218,
- .99999882345170190992902571017152601904826792288976,
- .99999970586288221916022821773876567711626389934930,
- .99999992646571785114473148070738785694820115568892,
- .99999998161642929380834691540290971450507605124278,
- .99999999540410731289097193313960614895889430318945,
- .99999999885102682756267330779455410840053741619428
- };
-static REAL sintab[20]=
- {
- 1.0000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768846,
- .38268343236508977172845998403039886676134456248561,
- .19509032201612826784828486847702224092769161775195,
- .09801714032956060199419556388864184586113667316749,
- .04906767432741801425495497694268265831474536302574,
- .02454122852291228803173452945928292506546611923944,
- .01227153828571992607940826195100321214037231959176,
- .00613588464915447535964023459037258091705788631738,
- .00306795676296597627014536549091984251894461021344,
- .00153398018628476561230369715026407907995486457522,
- .00076699031874270452693856835794857664314091945205,
- .00038349518757139558907246168118138126339502603495,
- .00019174759731070330743990956198900093346887403385,
- .00009587379909597734587051721097647635118706561284,
- .00004793689960306688454900399049465887274686668768
- };
-static REAL coswrk[20]=
- {
- .00000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768847,
- .92387953251128675612818318939678828682241662586364,
- .98078528040323044912618223613423903697393373089333,
- .99518472667219688624483695310947992157547486872985,
- .99879545620517239271477160475910069444320361470461,
- .99969881869620422011576564966617219685006108125772,
- .99992470183914454092164649119638322435060646880221,
- .99998117528260114265699043772856771617391725094433,
- .99999529380957617151158012570011989955298763362218,
- .99999882345170190992902571017152601904826792288976,
- .99999970586288221916022821773876567711626389934930,
- .99999992646571785114473148070738785694820115568892,
- .99999998161642929380834691540290971450507605124278,
- .99999999540410731289097193313960614895889430318945,
- .99999999885102682756267330779455410840053741619428
- };
-static REAL sinwrk[20]=
- {
- 1.0000000000000000000000000000000000000000000000000,
- .70710678118654752440084436210484903928483593768846,
- .38268343236508977172845998403039886676134456248561,
- .19509032201612826784828486847702224092769161775195,
- .09801714032956060199419556388864184586113667316749,
- .04906767432741801425495497694268265831474536302574,
- .02454122852291228803173452945928292506546611923944,
- .01227153828571992607940826195100321214037231959176,
- .00613588464915447535964023459037258091705788631738,
- .00306795676296597627014536549091984251894461021344,
- .00153398018628476561230369715026407907995486457522,
- .00076699031874270452693856835794857664314091945205,
- .00038349518757139558907246168118138126339502603495,
- .00019174759731070330743990956198900093346887403385,
- .00009587379909597734587051721097647635118706561284,
- .00004793689960306688454900399049465887274686668768
- };
-
-
-#define SQRT2_2 0.70710678118654752440084436210484
-#define SQRT2 2*0.70710678118654752440084436210484
-
-void mayer_fht(REAL *fz, int n)
-{
-/* REAL a,b;
-REAL c1,s1,s2,c2,s3,c3,s4,c4;
- REAL f0,g0,f1,g1,f2,g2,f3,g3; */
- int k,k1,k2,k3,k4,kx;
- REAL *fi,*fn,*gi;
- TRIG_VARS;
-
- for (k1=1,k2=0;k1<n;k1++)
- {
- REAL aa;
- for (k=n>>1; (!((k2^=k)&k)); k>>=1);
- if (k1>k2)
- {
- aa=fz[k1];fz[k1]=fz[k2];fz[k2]=aa;
- }
- }
- for ( k=0 ; (1<<k)<n ; k++ );
- k &= 1;
- if (k==0)
- {
- for (fi=fz,fn=fz+n;fi<fn;fi+=4)
- {
- REAL f0,f1,f2,f3;
- f1 = fi[0 ]-fi[1 ];
- f0 = fi[0 ]+fi[1 ];
- f3 = fi[2 ]-fi[3 ];
- f2 = fi[2 ]+fi[3 ];
- fi[2 ] = (f0-f2);
- fi[0 ] = (f0+f2);
- fi[3 ] = (f1-f3);
- fi[1 ] = (f1+f3);
- }
- }
- else
- {
- for (fi=fz,fn=fz+n,gi=fi+1;fi<fn;fi+=8,gi+=8)
- {
- REAL bs1,bc1,bs2,bc2,bs3,bc3,bs4,bc4,
- bg0,bf0,bf1,bg1,bf2,bg2,bf3,bg3;
- bc1 = fi[0 ] - gi[0 ];
- bs1 = fi[0 ] + gi[0 ];
- bc2 = fi[2 ] - gi[2 ];
- bs2 = fi[2 ] + gi[2 ];
- bc3 = fi[4 ] - gi[4 ];
- bs3 = fi[4 ] + gi[4 ];
- bc4 = fi[6 ] - gi[6 ];
- bs4 = fi[6 ] + gi[6 ];
- bf1 = (bs1 - bs2);
- bf0 = (bs1 + bs2);
- bg1 = (bc1 - bc2);
- bg0 = (bc1 + bc2);
- bf3 = (bs3 - bs4);
- bf2 = (bs3 + bs4);
- bg3 = SQRT2*bc4;
- bg2 = SQRT2*bc3;
- fi[4 ] = bf0 - bf2;
- fi[0 ] = bf0 + bf2;
- fi[6 ] = bf1 - bf3;
- fi[2 ] = bf1 + bf3;
- gi[4 ] = bg0 - bg2;
- gi[0 ] = bg0 + bg2;
- gi[6 ] = bg1 - bg3;
- gi[2 ] = bg1 + bg3;
- }
- }
- if (n<16) return;
-
- do
- {
- REAL s1,c1;
- int ii;
- k += 2;
- k1 = 1 << k;
- k2 = k1 << 1;
- k4 = k2 << 1;
- k3 = k2 + k1;
- kx = k1 >> 1;
- fi = fz;
- gi = fi + kx;
- fn = fz + n;
- do
- {
- REAL g0,f0,f1,g1,f2,g2,f3,g3;
- f1 = fi[0 ] - fi[k1];
- f0 = fi[0 ] + fi[k1];
- f3 = fi[k2] - fi[k3];
- f2 = fi[k2] + fi[k3];
- fi[k2] = f0 - f2;
- fi[0 ] = f0 + f2;
- fi[k3] = f1 - f3;
- fi[k1] = f1 + f3;
- g1 = gi[0 ] - gi[k1];
- g0 = gi[0 ] + gi[k1];
- g3 = SQRT2 * gi[k3];
- g2 = SQRT2 * gi[k2];
- gi[k2] = g0 - g2;
- gi[0 ] = g0 + g2;
- gi[k3] = g1 - g3;
- gi[k1] = g1 + g3;
- gi += k4;
- fi += k4;
- } while (fi<fn);
- TRIG_INIT(k,c1,s1);
- for (ii=1;ii<kx;ii++)
- {
- REAL c2,s2;
- TRIG_NEXT(k,c1,s1);
- c2 = c1*c1 - s1*s1;
- s2 = 2*(c1*s1);
- fn = fz + n;
- fi = fz +ii;
- gi = fz +k1-ii;
- do
- {
- REAL a,b,g0,f0,f1,g1,f2,g2,f3,g3;
- b = s2*fi[k1] - c2*gi[k1];
- a = c2*fi[k1] + s2*gi[k1];
- f1 = fi[0 ] - a;
- f0 = fi[0 ] + a;
- g1 = gi[0 ] - b;
- g0 = gi[0 ] + b;
- b = s2*fi[k3] - c2*gi[k3];
- a = c2*fi[k3] + s2*gi[k3];
- f3 = fi[k2] - a;
- f2 = fi[k2] + a;
- g3 = gi[k2] - b;
- g2 = gi[k2] + b;
- b = s1*f2 - c1*g3;
- a = c1*f2 + s1*g3;
- fi[k2] = f0 - a;
- fi[0 ] = f0 + a;
- gi[k3] = g1 - b;
- gi[k1] = g1 + b;
- b = c1*g2 - s1*f3;
- a = s1*g2 + c1*f3;
- gi[k2] = g0 - a;
- gi[0 ] = g0 + a;
- fi[k3] = f1 - b;
- fi[k1] = f1 + b;
- gi += k4;
- fi += k4;
- } while (fi<fn);
- }
- TRIG_RESET(k,c1,s1);
- } while (k4<n);
-}
-
-void mayer_fft(int n, REAL *real, REAL *imag)
-{
- REAL a,b,c,d;
- REAL q,r,s,t;
- int i,j,k;
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i]; b = real[j]; q=a+b; r=a-b;
- c = imag[i]; d = imag[j]; s=c+d; t=c-d;
- real[i] = (q+t)*.5; real[j] = (q-t)*.5;
- imag[i] = (s-r)*.5; imag[j] = (s+r)*.5;
- }
- mayer_fht(real,n);
- mayer_fht(imag,n);
-}
-
-void mayer_ifft(int n, REAL *real, REAL *imag)
-{
- REAL a,b,c,d;
- REAL q,r,s,t;
- int i,j,k;
- mayer_fht(real,n);
- mayer_fht(imag,n);
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i]; b = real[j]; q=a+b; r=a-b;
- c = imag[i]; d = imag[j]; s=c+d; t=c-d;
- imag[i] = (s+r)*0.5; imag[j] = (s-r)*0.5;
- real[i] = (q-t)*0.5; real[j] = (q+t)*0.5;
- }
-}
-
-void mayer_realfft(int n, REAL *real)
-{
- REAL a,b,c,d;
- int i,j,k;
- mayer_fht(real,n);
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i];
- b = real[j];
- real[j] = (a-b)*0.5;
- real[i] = (a+b)*0.5;
- }
-}
-
-void mayer_realifft(int n, REAL *real)
-{
- REAL a,b,c,d;
- int i,j,k;
- for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
- a = real[i];
- b = real[j];
- real[j] = (a-b);
- real[i] = (a+b);
- }
- mayer_fht(real,n);
-}
--- a/LEAF/Externals/d_fft_mayer.h
+++ b/LEAF/Externals/d_fft_mayer.h
@@ -7,7 +7,11 @@
#ifndef D_FFT_MAYER_H_
-#define D_FFT_MAYER_H_
+#define D_FFT_MAYER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
typedef float t_sample; /* a float type at most the same size */
@@ -20,6 +24,8 @@
void mayer_realifft(int n, REAL *real);
+#ifdef __cplusplus
+}
+#endif
-
-#endif /* D_FFT_MAYER_H_ */
\ No newline at end of file
+#endif /* D_FFT_MAYER_H_ */
--- a/LEAF/Externals/trigtbl.h
+++ b/LEAF/Externals/trigtbl.h
@@ -7,6 +7,10 @@
** Ron Mayer
*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifdef REAL
#else
#define REAL double
@@ -162,4 +166,8 @@
.00019174759731070330743990956198900093346887403385,
.00009587379909597734587051721097647635118706561284,
.00004793689960306688454900399049465887274686668768
- };
\ No newline at end of file
+ };
+
+#ifdef __cplusplus
+}
+#endif
--- a/LEAF/Inc/leaf-808.h
+++ b/LEAF/Inc/leaf-808.h
@@ -8,7 +8,11 @@
==============================================================================
*/
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#include "leaf-globals.h"
#include "leaf-math.h"
@@ -15,8 +19,10 @@
#include "leaf-oscillator.h"
#include "leaf-utilities.h"
-#include "leaf-filter.h"
+#include "leaf-filter.h"
+
+
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// 808 Cowbell
@@ -165,7 +171,11 @@
void t808Kick_setChirpAmount (t808Kick* const, float chirp);
void t808Kick_setToneNoiseMix (t808Kick* const, float toneNoiseMix);
void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq);
-void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);
+void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);
+
+#ifdef __cplusplus
+}
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
--- a/LEAF/Inc/leaf-delay.h
+++ b/LEAF/Inc/leaf-delay.h
@@ -9,7 +9,11 @@
*/
#ifndef LEAFDELAY_H_INCLUDED
-#define LEAFDELAY_H_INCLUDED
+#define LEAFDELAY_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -111,6 +115,40 @@
float tDelayA_getLastOut (tDelayA* const);
float tDelayA_getLastIn (tDelayA* const);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+/* Linear interpolating delay with fixed read and write pointers, variable rate. */
+typedef struct _tTapeDelay
+{
+ float gain;
+ float* buff;
+
+ float lastOut, lastIn;
+
+ uint32_t inPoint;
+
+ uint32_t maxDelay;
+
+ float delay, inc, idx;
+
+ float apInput;
+
+} tTapeDelay;
+
+void tTapeDelay_init (tTapeDelay* const, float delay, uint32_t maxDelay);
+void tTapeDelay_free (tTapeDelay* const);
+
+int tTapeDelay_setDelay (tTapeDelay* const, float delay);
+float tTapeDelay_getDelay (tTapeDelay* const);
+void tTapeDelay_tapIn (tTapeDelay* const, float in, uint32_t tapDelay);
+float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay);
+float tTapeDelay_addTo (tTapeDelay* const, float value, uint32_t tapDelay);
+float tTapeDelay_tick (tTapeDelay* const, float sample);
+float tTapeDelay_getLastOut (tTapeDelay* const);
+float tTapeDelay_getLastIn (tTapeDelay* const);
+
+#ifdef __cplusplus
+}
+#endif
#endif // LEAFDELAY_H_INCLUDED
--- a/LEAF/Inc/leaf-filter.h
+++ b/LEAF/Inc/leaf-filter.h
@@ -9,7 +9,11 @@
*/
#ifndef LEAFFILTER_H_INCLUDED
-#define LEAFFILTER_H_INCLUDED
+#define LEAFFILTER_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -296,5 +300,9 @@
void tButterworth_setFreqs (tButterworth* const, float f1, float f2);
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
#endif // LEAFFILTER_H_INCLUDED
--- a/LEAF/Inc/leaf-formant.h
+++ b/LEAF/Inc/leaf-formant.h
@@ -6,7 +6,11 @@
Author: airship
==============================================================================
-*/
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -49,5 +53,9 @@
float tFormantShifter_add (tFormantShifter* const, float input, float fwarp);
void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
--- a/LEAF/Inc/leaf-globals.h
+++ b/LEAF/Inc/leaf-globals.h
@@ -20,7 +20,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "leaf-mempool.h"
-
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct _LEAF
{
float sampleRate;
--- a/LEAF/Inc/leaf-math.h
+++ b/LEAF/Inc/leaf-math.h
@@ -15,7 +15,11 @@
#include "math.h"
#include "stdint.h"
-#include "stdlib.h"
+#include "stdlib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
//==============================================================================
@@ -98,7 +102,11 @@
// dope af
float LEAF_chebyshevT(float in, int n);
float LEAF_CompoundChebyshevT(float in, int n, float* amps);
-
+
+
+// Hermite interpolation
+float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
+float LEAF_interpolation_linear (float A, float B, float t);
// Hermite interpolation
float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
--- a/LEAF/Inc/leaf-mempool.h
+++ b/LEAF/Inc/leaf-mempool.h
@@ -42,7 +42,11 @@
#include <stdbool.h>
#define MPOOL_POOL_SIZE 500000
-#define MPOOL_ALIGN_SIZE (8)
+#define MPOOL_ALIGN_SIZE (8)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
//#define size_t unsigned long
@@ -83,7 +87,10 @@
size_t leaf_pool_get_used(void);
void* leaf_pool_get_pool(void);
-
+
+#ifdef __cplusplus
+}
+#endif
#endif
--- a/LEAF/Inc/leaf-midi.h
+++ b/LEAF/Inc/leaf-midi.h
@@ -6,8 +6,12 @@
Author: airship
==============================================================================
-*/
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include "leaf-globals.h"
@@ -106,5 +110,9 @@
int tMPoly_getVelocity(tMPoly* const, uint8_t voice);
int tMPoly_isOn(tMPoly* const, uint8_t voice);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
--- a/LEAF/Inc/leaf-oscillator.h
+++ b/LEAF/Inc/leaf-oscillator.h
@@ -9,7 +9,11 @@
*/
#ifndef LEAFOSCILLATOR_H_INCLUDED
-#define LEAFOSCILLATOR_H_INCLUDED
+#define LEAFOSCILLATOR_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -169,6 +173,10 @@
float tNoise_tick (tNoise* const);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // LEAFOSCILLATOR_H_INCLUDED
--- a/LEAF/Inc/leaf-pitch.h
+++ b/LEAF/Inc/leaf-pitch.h
@@ -6,7 +6,11 @@
Author: airship
==============================================================================
-*/
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -225,4 +229,8 @@
float tPitchShift_shiftToFreq (tPitchShift* const, float freq);
void tPitchShift_setPitchFactor (tPitchShift* const, float pf);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
--- a/LEAF/Inc/leaf-reverb.h
+++ b/LEAF/Inc/leaf-reverb.h
@@ -9,7 +9,11 @@
*/
#ifndef LEAFREVERB_H_INCLUDED
-#define LEAFREVERB_H_INCLUDED
+#define LEAFREVERB_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -20,7 +24,7 @@
#include "leaf-filter.h"
#include "leaf-oscillator.h"
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
/* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */
typedef struct _tPRCRev
@@ -81,7 +85,6 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
typedef struct _tDattorro
{
float predelay;
@@ -90,37 +93,40 @@
float feedback_gain;
float mix;
- float size, t;
+ float size, size_max, t;
+
float f1_delay_2_last,
- f2_delay_2_last;
+ f2_delay_2_last;
float f1_last,
- f2_last;
+ f2_last;
// INPUT
- tDelayL in_delay;
+ tTapeDelay in_delay;
tOnePole in_filter;
tAllpass in_allpass[4];
// FEEDBACK 1
tAllpass f1_allpass;
- tDelayL f1_delay_1;
+ tTapeDelay f1_delay_1;
tOnePole f1_filter;
- tDelayL f1_delay_2;
- tDelayL f1_delay_3;
+ tTapeDelay f1_delay_2;
+ tTapeDelay f1_delay_3;
+ tHighpass f1_hp;
tCycle f1_lfo;
// FEEDBACK 2
tAllpass f2_allpass;
- tDelayL f2_delay_1;
+ tTapeDelay f2_delay_1;
tOnePole f2_filter;
- tDelayL f2_delay_2;
- tDelayL f2_delay_3;
+ tTapeDelay f2_delay_2;
+ tTapeDelay f2_delay_3;
+ tHighpass f2_hp;
tCycle f2_lfo;
-
+
} tDattorro;
void tDattorro_init (tDattorro* const);
@@ -134,6 +140,9 @@
void tDattorro_setInputFilter (tDattorro* const, float freq);
void tDattorro_setFeedbackFilter (tDattorro* const, float freq);
void tDattorro_setFeedbackGain (tDattorro* const, float gain);
-
+
+#ifdef __cplusplus
+}
+#endif
#endif // LEAFREVERB_H_INCLUDED
--- a/LEAF/Inc/leaf-string.h
+++ b/LEAF/Inc/leaf-string.h
@@ -7,7 +7,11 @@
==============================================================================
*/
-
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include "leaf-globals.h"
@@ -126,4 +130,8 @@
// tStifKarp utilities.
float tStifKarp_getLastOut (tStifKarp* const);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
--- a/LEAF/Inc/leaf-utilities.h
+++ b/LEAF/Inc/leaf-utilities.h
@@ -9,7 +9,11 @@
*/
#ifndef LEAFUTILITIES_H_INCLUDED
-#define LEAFUTILITIES_H_INCLUDED
+#define LEAFUTILITIES_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -242,7 +246,11 @@
float tEnv_tick (tEnv* const);
void tEnv_processBlock (tEnv* const, float* in);
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
#endif // LEAFUTILITIES_H_INCLUDED
--- a/LEAF/Inc/leaf-vocoder.h
+++ b/LEAF/Inc/leaf-vocoder.h
@@ -9,7 +9,11 @@
*/
#ifndef LEAFINSTRUMENT_H_INCLUDED
-#define LEAFINSTRUMENT_H_INCLUDED
+#define LEAFINSTRUMENT_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -76,5 +80,9 @@
void tVocoder_suspend (tVocoder* const);
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // LEAFINSTRUMENT_H_INCLUDED
--- a/LEAF/Inc/leaf-wavefolder.h
+++ b/LEAF/Inc/leaf-wavefolder.h
@@ -6,7 +6,11 @@
Author: airship
==============================================================================
-*/
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -39,5 +43,9 @@
void tLockhartWavefolder_free (tLockhartWavefolder* const);
float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);
-
+
+
+#ifdef __cplusplus
+}
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
--- a/LEAF/Inc/leaf-wavetables.h
+++ b/LEAF/Inc/leaf-wavetables.h
@@ -9,7 +9,11 @@
*/
#ifndef WAVETABLES_H_INCLUDED
-#define WAVETABLES_H_INCLUDED
+#define WAVETABLES_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@@ -69,6 +73,10 @@
extern const float squarewave[11][SQR_TABLE_SIZE];
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#ifdef __cplusplus
+}
+#endif
#endif // WAVETABLES_H_INCLUDED
binary files a/LEAF/Inc_cpp/.DS_Store /dev/null differ
--- a/LEAF/Inc_cpp/leaf-808.hpp
+++ /dev/null
@@ -1,170 +1,0 @@
-/*
- ==============================================================================
-
- leaf_808.h
- Created: 30 Nov 2018 10:24:44am
- Author: airship
-
- ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-oscillator.h"
-#include "leaf-utilities.h"
-#include "leaf-filter.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// 808 Cowbell
-typedef struct _t808Cowbell {
-
- tSquare p[2];
- tNoise stick;
- tSVF bandpassOsc;
- tSVF bandpassStick;
- tEnvelope envGain;
- tEnvelope envStick;
- tEnvelope envFilter;
- tHighpass highpass;
- float oscMix;
- float filterCutoff;
-
-} t808Cowbell;
-
-void t808Cowbell_init (t808Cowbell* const);
-void t808Cowbell_free (t808Cowbell* const);
-float t808Cowbell_tick (t808Cowbell* const);
-void t808Cowbell_on (t808Cowbell* const, float vel);
-void t808Cowbell_setDecay (t808Cowbell* const, float decay);
-void t808Cowbell_setHighpassFreq (t808Cowbell* const, float freq);
-void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq);
-void t808Cowbell_setFreq (t808Cowbell* const, float freq);
-void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// 808 Hihat
-typedef struct _t808Hihat {
-
- // 6 Square waves
- tSquare p[6];
- tNoise n;
- tSVF bandpassOsc;
- tSVF bandpassStick;
- tEnvelope envGain;
- tEnvelope envStick;
- tEnvelope noiseFMGain;
- tHighpass highpass;
- tNoise stick;
-
- float freq;
- float stretch;
- float FM_amount;
- float oscNoiseMix;
-
-} t808Hihat;
-
-void t808Hihat_init (t808Hihat* const);
-void t808Hihat_free (t808Hihat* const);
-
-float t808Hihat_tick (t808Hihat* const);
-void t808Hihat_on (t808Hihat* const, float vel);
-void t808Hihat_setOscNoiseMix (t808Hihat* const, float oscNoiseMix);
-void t808Hihat_setDecay (t808Hihat* const, float decay);
-void t808Hihat_setHighpassFreq (t808Hihat* const, float freq);
-void t808Hihat_setOscBandpassFreq (t808Hihat* const, float freq);
-void t808Hihat_setOscBandpassQ (t808Hihat* const hihat, float Q);
-void t808Hihat_setStickBandPassFreq (t808Hihat* const, float freq);
-void t808Hihat_setOscFreq (t808Hihat* const, float freq);
-void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);
-void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// 808 Snare
-typedef struct _t808Snare {
-
- // Tone 1, Tone 2, Noise
- tTriangle tone[2]; // Tri (not yet antialiased or wavetabled)
- tNoise noiseOsc;
- tSVF toneLowpass[2];
- tSVF noiseLowpass; // Lowpass from SVF filter
- tEnvelope toneEnvOsc[2];
- tEnvelope toneEnvGain[2];
- tEnvelope noiseEnvGain;
- tEnvelope toneEnvFilter[2];
- tEnvelope noiseEnvFilter;
-
- float toneGain[2];
- float noiseGain;
-
- float toneNoiseMix;
-
- float tone1Freq, tone2Freq;
-
- float noiseFilterFreq;
-
-
-} t808Snare;
-
-void t808Snare_init (t808Snare* const);
-void t808Snare_free (t808Snare* const);
-
-float t808Snare_tick (t808Snare* const);
-void t808Snare_on (t808Snare* const, float vel);
-void t808Snare_setTone1Freq (t808Snare* const, float freq);
-void t808Snare_setTone2Freq (t808Snare* const, float freq);
-void t808Snare_setTone1Decay (t808Snare* const, float decay);
-void t808Snare_setTone2Decay (t808Snare* const, float decay);
-void t808Snare_setNoiseDecay (t808Snare* const, float decay);
-void t808Snare_setToneNoiseMix (t808Snare* const, float toneNoiseMix);
-void t808Snare_setNoiseFilterFreq (t808Snare* const, float noiseFilterFreq);
-void t808Snare_setNoiseFilterQ (t808Snare* const, float noiseFilterQ);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// 808 Kick
-typedef struct _t808Kick {
-
-
- tCycle tone; // Tri
- tNoise noiseOsc;
- tSVF toneLowpass;
- tEnvelope toneEnvOscChirp;
- tEnvelope toneEnvOscSigh;
- tEnvelope toneEnvGain;
- tEnvelope noiseEnvGain;
- tEnvelope toneEnvFilter;
-
- float toneGain;
- float noiseGain;
-
- float toneInitialFreq;
- float sighAmountInHz;
- float chirpRatioMinusOne;
- float noiseFilterFreq;
-
-
-} t808Kick;
-
-void t808Kick_init (t808Kick* const);
-void t808Kick_free (t808Kick* const);
-
-float t808Kick_tick (t808Kick* const);
-void t808Kick_on (t808Kick* const, float vel);
-void t808Kick_setToneFreq (t808Kick* const, float freq);
-void t808Kick_setToneDecay (t808Kick* const, float decay);
-void t808Kick_setNoiseDecay (t808Kick* const, float decay);
-void t808Kick_setSighAmount (t808Kick* const, float sigh);
-void t808Kick_setChirpAmount (t808Kick* const, float chirp);
-void t808Kick_setToneNoiseMix (t808Kick* const, float toneNoiseMix);
-void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq);
-void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
--- a/LEAF/Inc_cpp/leaf-delay.hpp
+++ /dev/null
@@ -1,116 +1,0 @@
-/*
- ==============================================================================
-
- LEAFDelay.h
- Created: 20 Jan 2017 12:01:24pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFDELAY_H_INCLUDED
-#define LEAFDELAY_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */
-typedef struct _tDelay
-{
- float gain;
- float* buff;
-
- float lastOut, lastIn;
-
- uint32_t inPoint, outPoint;
-
- uint32_t delay, maxDelay;
-
-} tDelay;
-
-void tDelay_init (tDelay* const, uint32_t delay, uint32_t maxDelay);
-void tDelay_free (tDelay* const);
-
-int tDelay_setDelay (tDelay* const, uint32_t delay);
-uint32_t tDelay_getDelay (tDelay* const);
-void tDelay_tapIn (tDelay* const, float in, uint32_t tapDelay);
-float tDelay_tapOut (tDelay* const, uint32_t tapDelay);
-float tDelay_addTo (tDelay* const, float value, uint32_t tapDelay);
-float tDelay_tick (tDelay* const, float sample);
-float tDelay_getLastOut (tDelay* const);
-float tDelay_getLastIn (tDelay* const);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */
-typedef struct _tDelayL
-{
- float gain;
- float* buff;
-
- float lastOut, lastIn;
-
- uint32_t inPoint, outPoint;
-
- uint32_t maxDelay;
-
- float delay;
-
- float alpha, omAlpha;
-
-} tDelayL;
-
-void tDelayL_init (tDelayL* const, float delay, uint32_t maxDelay);
-void tDelayL_free (tDelayL* const);
-
-int tDelayL_setDelay (tDelayL* const, float delay);
-float tDelayL_getDelay (tDelayL* const);
-void tDelayL_tapIn (tDelayL* const, float in, uint32_t tapDelay);
-float tDelayL_tapOut (tDelayL* const, float tapDelay);
-float tDelayL_addTo (tDelayL* const, float value, uint32_t tapDelay);
-float tDelayL_tick (tDelayL* const, float sample);
-float tDelayL_getLastOut (tDelayL* const);
-float tDelayL_getLastIn (tDelayL* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */
-typedef struct _tDelayA
-{
- float gain;
- float* buff;
-
- float lastOut, lastIn;
-
- uint32_t inPoint, outPoint;
-
- uint32_t maxDelay;
-
- float delay;
-
- float alpha, omAlpha, coeff;
-
- float apInput;
-
-} tDelayA;
-
-void tDelayA_init (tDelayA* const, float delay, uint32_t maxDelay);
-void tDelayA_free (tDelayA* const);
-
-int tDelayA_setDelay (tDelayA* const, float delay);
-float tDelayA_getDelay (tDelayA* const);
-void tDelayA_tapIn (tDelayA* const, float in, uint32_t tapDelay);
-float tDelayA_tapOut (tDelayA* const, uint32_t tapDelay);
-float tDelayA_addTo (tDelayA* const, float value, uint32_t tapDelay);
-float tDelayA_tick (tDelayA* const, float sample);
-float tDelayA_getLastOut (tDelayA* const);
-float tDelayA_getLastIn (tDelayA* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#endif // LEAFDELAY_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-filter.hpp
+++ /dev/null
@@ -1,300 +1,0 @@
-/*
- ==============================================================================
-
- LEAFFilter.h
- Created: 20 Jan 2017 12:01:10pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFFILTER_H_INCLUDED
-#define LEAFFILTER_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-delay.h"
-
-#include "leaf-wavetables.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */
-typedef struct _tAllpass
-{
- float gain;
-
- tDelayL delay;
-
- float lastOut;
-
-} tAllpass;
-
-void tAllpass_init (tAllpass* const, float initDelay, uint32_t maxDelay);
-void tAllpass_free (tAllpass* const);
-
-float tAllpass_tick (tAllpass* const, float input);
-void tAllpass_setGain (tAllpass* const, float gain);
-void tAllpass_setDelay (tAllpass* const f, float delay);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */
-typedef struct _tOnePole
-{
- float gain;
- float a0,a1;
- float b0,b1;
-
- float coef;
-
- float freq;
-
- float lastIn, lastOut;
-
-} tOnePole;
-
-void tOnePole_init (tOnePole* const, float thePole);
-void tOnePole_free (tOnePole* const);
-
-float tOnePole_tick (tOnePole* const, float input);
-void tOnePole_setB0 (tOnePole* const, float b0);
-void tOnePole_setA1 (tOnePole* const, float a1);
-void tOnePole_setPole (tOnePole* const, float thePole);
-void tOnePole_setFreq (tOnePole* const, float freq);
-void tOnePole_setCoefficients(tOnePole* const, float b0, float a1);
-void tOnePole_setGain (tOnePole* const, float gain);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* TwoPole filter, reimplemented from STK (Cook and Scavone). */
-typedef struct _tTwoPole
-{
- float gain;
- float a0, a1, a2;
- float b0;
-
- float radius, frequency;
- oBool normalize;
-
- float lastOut[2];
-
-} tTwoPole;
-
-void tTwoPole_init (tTwoPole* const);
-void tTwoPole_free (tTwoPole* const);
-
-float tTwoPole_tick (tTwoPole* const, float input);
-void tTwoPole_setB0 (tTwoPole* const, float b0);
-void tTwoPole_setA1 (tTwoPole* const, float a1);
-void tTwoPole_setA2 (tTwoPole* const, float a2);
-void tTwoPole_setResonance (tTwoPole* const, float freq, float radius, oBool normalize);
-void tTwoPole_setCoefficients(tTwoPole* const, float b0, float a1, float a2);
-void tTwoPole_setGain (tTwoPole* const, float gain);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* OneZero filter, reimplemented from STK (Cook and Scavone). */
-typedef struct _tOneZero
-{
- float gain;
- float b0,b1;
- float lastIn, lastOut, frequency;
-
-} tOneZero;
-
-void tOneZero_init (tOneZero* const, float theZero);
-void tOneZero_free (tOneZero* const);
-float tOneZero_tick (tOneZero* const, float input);
-void tOneZero_setB0 (tOneZero* const, float b0);
-void tOneZero_setB1 (tOneZero* const, float b1);
-void tOneZero_setZero (tOneZero* const, float theZero);
-void tOneZero_setCoefficients(tOneZero* const, float b0, float b1);
-void tOneZero_setGain (tOneZero* const, float gain);
-float tOneZero_getPhaseDelay(tOneZero *f, float frequency );
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* TwoZero filter, reimplemented from STK (Cook and Scavone). */
-typedef struct _tTwoZero
-{
- float gain;
- float b0, b1, b2;
-
- float frequency, radius;
-
- float lastIn[2];
-
-} tTwoZero;
-
-void tTwoZero_init (tTwoZero* const);
-void tTwoZero_free (tTwoZero* const);
-
-float tTwoZero_tick (tTwoZero* const, float input);
-void tTwoZero_setB0 (tTwoZero* const, float b0);
-void tTwoZero_setB1 (tTwoZero* const, float b1);
-void tTwoZero_setB2 (tTwoZero* const, float b2);
-void tTwoZero_setNotch (tTwoZero* const, float frequency, float radius);
-void tTwoZero_setCoefficients(tTwoZero* const, float b0, float b1, float b2);
-void tTwoZero_setGain (tTwoZero* const, float gain);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* PoleZero filter, reimplemented from STK (Cook and Scavone). */
-typedef struct _tPoleZero
-{
- float gain;
- float a0,a1;
- float b0,b1;
-
- float lastIn, lastOut;
-
-} tPoleZero;
-
-void tPoleZero_init (tPoleZero* const);
-void tPoleZero_free (tPoleZero* const);
-
-float tPoleZero_tick (tPoleZero* const, float input);
-void tPoleZero_setB0 (tPoleZero* const, float b0);
-void tPoleZero_setB1 (tPoleZero* const, float b1);
-void tPoleZero_setA1 (tPoleZero* const, float a1);
-void tPoleZero_setCoefficients (tPoleZero* const, float b0, float b1, float a1);
-void tPoleZero_setAllpass (tPoleZero* const, float coeff);
-void tPoleZero_setBlockZero (tPoleZero* const, float thePole);
-void tPoleZero_setGain (tPoleZero* const, float gain);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* BiQuad filter, reimplemented from STK (Cook and Scavone). */
-typedef struct _tBiQuad
-{
- float gain;
- float a0, a1, a2;
- float b0, b1, b2;
-
- float lastIn[2];
- float lastOut[2];
-
- float frequency, radius;
- oBool normalize;
-} tBiQuad;
-
-void tBiQuad_init (tBiQuad* const);
-void tBiQuad_free (tBiQuad* const);
-
-float tBiQuad_tick (tBiQuad* const, float input);
-void tBiQuad_setB0 (tBiQuad* const, float b0);
-void tBiQuad_setB1 (tBiQuad* const, float b1);
-void tBiQuad_setB2 (tBiQuad* const, float b2);
-void tBiQuad_setA1 (tBiQuad* const, float a1);
-void tBiQuad_setA2 (tBiQuad* const, float a2);
-void tBiQuad_setNotch (tBiQuad* const, float freq, float radius);
-void tBiQuad_setResonance (tBiQuad* const, float freq, float radius, oBool normalize);
-void tBiQuad_setCoefficients(tBiQuad* const, float b0, float b1, float b2, float a1, float a2);
-void tBiQuad_setGain (tBiQuad* const, float gain);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* State Variable Filter, algorithm from Andy Simper. */
-typedef enum SVFType
-{
- SVFTypeHighpass = 0,
- SVFTypeLowpass,
- SVFTypeBandpass,
- SVFTypeNotch,
- SVFTypePeak,
-} SVFType;
-
-typedef struct _tSVF
-{
- SVFType type;
- float cutoff, Q;
- float ic1eq,ic2eq;
- float g,k,a1,a2,a3;
-
-} tSVF;
-
-void tSVF_init (tSVF* const, SVFType type, float freq, float Q);
-void tSVF_free (tSVF* const);
-
-float tSVF_tick (tSVF* const, float v0);
-int tSVF_setFreq (tSVF* const, float freq);
-int tSVF_setQ (tSVF* const, float Q);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Efficient State Variable Filter for 14-bit control input, [0, 4096). */
-typedef struct _tSVFE
-{
- SVFType type;
- float cutoff, Q;
- float ic1eq,ic2eq;
- float g,k,a1,a2,a3;
-
-} tSVFE;
-
-void tSVFE_init (tSVFE* const, SVFType type, uint16_t controlFreq, float Q);
-void tSVFE_free (tSVFE* const);
-
-float tSVFE_tick (tSVFE* const, float v0);
-int tSVFE_setFreq (tSVFE* const, uint16_t controlFreq);
-int tSVFE_setQ (tSVFE* const, float Q);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Simple Highpass filter. */
-typedef struct _tHighpass
-{
- float xs, ys, R;
- float frequency;
-
-} tHighpass;
-
-void tHighpass_init (tHighpass* const, float freq);
-void tHighpass_free (tHighpass* const);
-
-float tHighpass_tick (tHighpass* const, float x);
-void tHighpass_setFreq (tHighpass* const, float freq);
-float tHighpass_getFreq (tHighpass* const);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// Butterworth Filter
-#define NUM_SVF_BW 16
-typedef struct _tButterworth
-{
- float gain;
-
- float N;
-
- tSVF low[NUM_SVF_BW];
- tSVF high[NUM_SVF_BW];
-
- float f1,f2;
-
-} tButterworth;
-
-void tButterworth_init (tButterworth* const, int N, float f1, float f2);
-void tButterworth_free (tButterworth* const);
-
-float tButterworth_tick (tButterworth* const, float input);
-void tButterworth_setF1 (tButterworth* const, float in);
-void tButterworth_setF2 (tButterworth* const, float in);
-void tButterworth_setFreqs (tButterworth* const, float f1, float f2);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#endif // LEAFFILTER_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-formant.hpp
+++ /dev/null
@@ -1,53 +1,0 @@
-/*
- ==============================================================================
-
- leaf-formant.h
- Created: 30 Nov 2018 11:03:37am
- Author: airship
-
- ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#define FORD 7
-#define FORMANT_BUFFER_SIZE 2048
-
-typedef struct _tFormantShifter
-{
- int ford;
- float falph;
- float flamb;
- float fk[FORD];
- float fb[FORD];
- float fc[FORD];
- float frb[FORD];
- float frc[FORD];
- float fsig[FORD];
- float fsmooth[FORD];
- float fhp;
- float flp;
- float flpa;
- float fbuff[FORD][FORMANT_BUFFER_SIZE];
- float ftvec[FORD];
- float fmute;
- float fmutealph;
- unsigned int cbi;
-
-} tFormantShifter;
-
-void tFormantShifter_init (tFormantShifter* const);
-void tFormantShifter_free (tFormantShifter* const);
-
-float tFormantShifter_tick (tFormantShifter* const, float input, float fwarp);
-float tFormantShifter_remove (tFormantShifter* const, float input);
-float tFormantShifter_add (tFormantShifter* const, float input, float fwarp);
-void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
--- a/LEAF/Inc_cpp/leaf-globals.hpp
+++ /dev/null
@@ -1,53 +1,0 @@
-/*
- ==============================================================================
-
- leaf-globals.h
- Created: 23 Jan 2017 10:34:10pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef OPPSGLOBALS_H_INCLUDED
-#define OPPSGLOBALS_H_INCLUDED
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * *
- * If your application requires use of many instances of one component or is facing memory limitations, *
- * use this set of defines to increase or limit the number of instances of each component. The library *
- * will pre-allocate only the number of instances defined here. *
- * *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#include "leaf-mempool.h"
-
-typedef struct _LEAF
-{
- float sampleRate;
- float invSampleRate;
- int blockSize;
-
- float (*random)(void);
-} LEAF;
-
-extern LEAF leaf;
-
-#define SHAPER1_TABLE_SIZE 65536
-extern const float shaper1[SHAPER1_TABLE_SIZE];
-
-#define NUM_VOICES 8
-#define NUM_SHIFTERS 4
-#define MPOLY_NUM_MAX_VOICES 8
-#define NUM_OSC 4
-#define INV_NUM_OSC (1.0f / NUM_OSC)
-#define PS_FRAME_SIZE 1024 // SNAC_FRAME_SIZE in LEAFCore.h should match (or be smaller than?) this
-#define ENV_WINDOW_SIZE 1024
-#define ENV_HOP_SIZE 256
-#define NUM_KNOBS 4
-
-#define DELAY_LENGTH 16000 // The maximum delay length of all Delay/DelayL/DelayA components.
- // Feel free to change to suit memory constraints or desired delay max length / functionality.
-
-#define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size
-
-#endif // OPPSGLOBALS_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-math.hpp
+++ /dev/null
@@ -1,143 +1,0 @@
-/*
- ==============================================================================
-
- LEAFMath.h
- Created: 22 Jan 2017 7:02:56pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFMATH_H_INCLUDED
-#define LEAFMATH_H_INCLUDED
-
-#include "math.h"
-#include "stdint.h"
-#include "stdlib.h"
-
-typedef enum oBool
-{
- OTRUE = 1,
- OFALSE = 0
-}oBool;
-
-#define SQRT8 2.82842712475f
-#define WSCALE 1.30612244898f
-#define PI (3.14159265358979f)
-#define TWO_PI (2 * PI)
-
-#define VSF 1.0e-38f
-
-#define MAX_DELAY 8192
-#define INV_128 0.0078125f
-
-#define INV_20 0.05f
-#define INV_40 0.025f
-#define INV_80 0.0125f
-#define INV_160 0.00625f
-#define INV_320 0.003125f
-#define INV_640 0.0015625f
-#define INV_1280 0.00078125f
-#define INV_2560 0.000390625f
-#define INV_5120 0.0001953125f
-#define INV_10240 0.00009765625f
-#define INV_20480 0.000048828125f
-
-
-#define INV_TWELVE 0.0833333333f
-#define INV_440 0.0022727273f
-
-#define LOG2 0.3010299957f
-#define INV_LOG2 3.321928095f
-
-#define SOS_M 343.0f
-
-#define TWO_TO_7 128.f
-#define INV_TWO_TO_7 0.0078125f
-#define TWO_TO_8 256.f
-#define INV_TWO_TO_8 0.00390625f
-#define TWO_TO_5 32.0f
-#define INV_TWO_TO_5 0.03125f
-#define TWO_TO_12 4096.f
-#define INV_TWO_TO_12 0.00024414062f
-#define TWO_TO_15 32768.f
-#define TWO_TO_16 65536.f
-#define INV_TWO_TO_15 0.00003051757f
-#define INV_TWO_TO_16 0.00001525878f
-#define TWO_TO_16_MINUS_ONE 65535.0f
-#define TWO_TO_23 8388608.0f
-#define INV_TWO_TO_23 0.00000011920929f
-#define TWO_TO_31 2147483648.0f
-#define INV_TWO_TO_31 0.000000000465661f
-
-// Jones shaper
-float LEAF_shaper (float input, float m_drive);
-float LEAF_reedTable (float input, float offset, float slope);
-
-float LEAF_clip (float min, float val, float max);
-float LEAF_softClip (float val, float thresh);
-oBool LEAF_isPrime (uint64_t number );
-
-float LEAF_midiToFrequency (float f);
-float LEAF_frequencyToMidi(float f);
-
-void LEAF_generate_sine (float* buffer, int size);
-void LEAF_generate_sawtooth (float* buffer, float basefreq, int size);
-void LEAF_generate_triangle (float* buffer, float basefreq, int size);
-void LEAF_generate_square (float* buffer, float basefreq, int size);
-
-// dope af
-float LEAF_chebyshevT(float in, int n);
-float LEAF_CompoundChebyshevT(float in, int n, float* amps);
-
-static inline float interpolate3max(float *buf, const int peakindex)
-{
- float a = buf[peakindex-1];
- float b = buf[peakindex];
- float c = buf[peakindex+1];
- float realpeak;
-
- realpeak = b + (float)0.125 * (c - a) * (c - a) / ((float)2. * b - a - c);
-
- return(realpeak);
-}
-
-static inline float interpolate3phase(float *buf, const int peakindex)
-{
- float a = buf[peakindex-1];
- float b = buf[peakindex];
- float c = buf[peakindex+1];
- float fraction;
-
- fraction = ((float)0.5 * (c - a)) / ((float)2. * b - a - c);
-
- return(fraction);
-}
-
-// alternative implementation for abs()
-// REQUIRES: 32 bit integers
-static inline int fastabs_int(int in){
- unsigned int r;
- int const mask = in >> 31;
-
- r = (in ^ mask) - mask;
-
- return (r);
-}
-
-// alternative implementation for abs()
-// REQUIRES: 32 bit floats
-static inline float fastabs(float f)
-{
- union
- {
- float f;
- unsigned int ui;
- }alias;
-
- alias.f = f;
- alias.ui &= 0x7fffffff;
- return alias.f;
-}
-
-#endif // LEAFMATH_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-mempool.hpp
+++ /dev/null
@@ -1,90 +1,0 @@
-/**
- In short, mpool is distributed under so called "BSD license",
-
- Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of the authors nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/* written by C99 style */
-
-#ifndef MPOOL_H
-#define MPOOL_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#define MPOOL_POOL_SIZE 500000
-#define MPOOL_ALIGN_SIZE (8)
-
-//#define size_t unsigned long
-
-/**
- * memory pool structure
- */
-typedef struct mpool_pool_t {
- void *pool; // memory pool field
- struct mpool_pool_t *next; // next memory pool's pointer
- size_t size;
- int used; // used flag
-} mpool_pool_t;
-
-typedef struct mpool_t {
- mpool_pool_t *head; // memory pool's head
- size_t usize; // used pool size of current pool
- size_t msize; // max pool size of current pool
- mpool_pool_t *mpool; // memory pool
- int next;
-} mpool_t;
-
-
-void mpool_create (size_t size, mpool_t* pool);
-
-void *mpool_alloc(size_t size, mpool_t* pool);
-void mpool_free(void* ptr, mpool_t* pool);
-
-size_t mpool_get_size(mpool_t* pool);
-size_t mpool_get_used(mpool_t* pool);
-
-
-void leaf_pool_init(size_t size);
-
-void* leaf_alloc(size_t size);
-void leaf_free(void* ptr);
-
-size_t leaf_pool_get_size(void);
-size_t leaf_pool_get_used(void);
-
-void* leaf_pool_get_pool(void);
-
-
-#endif
-
-
--- a/LEAF/Inc_cpp/leaf-midi.hpp
+++ /dev/null
@@ -1,110 +1,0 @@
-/*
- ==============================================================================
-
- leaf-midi.h
- Created: 30 Nov 2018 11:29:26am
- Author: airship
-
- ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-utilities.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-typedef struct _tMidiNote
-{
- uint8_t pitch;
- uint8_t velocity;
- oBool on;
-} tMidiNote;
-
-typedef struct _tMidiNode tMidiNode;
-
-typedef struct _tMidiNode
-{
- tMidiNode* prev;
- tMidiNode* next;
- tMidiNote midiNote;
-
-} tMidiNode;
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Polyphonic Handler */
-typedef struct _tPoly
-{
- tMidiNode midiNodes[128];
- tMidiNode* onListFirst;
- tMidiNode* offListFirst;
-
-} tPoly;
-
-void tPoly_init(tPoly* const);
-void tPoly_free(tPoly* const);
-
-tMidiNote* tPoly_getMidiNote(tPoly* const, int8_t voiceIndex);
-void tPoly_noteOn(tPoly* poly, int midiNoteNumber, float velocity);
-void tPoly_noteOff(tPoly* poly, int midiNoteNumber);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tMPoly */
-typedef struct _tMPoly
-{
- tStack* stack;
- tStack* orderStack;
-
- tRamp* ramp[MPOLY_NUM_MAX_VOICES];
-
- float rampVals[MPOLY_NUM_MAX_VOICES];
- uint8_t firstReceived[MPOLY_NUM_MAX_VOICES];
- float glideTime;
-
- int numVoices;
-
- int voices[MPOLY_NUM_MAX_VOICES][2];
-
- int notes[128][2];
-
- int CCs[128];
-
- uint8_t CCsRaw[128];
-
- int lastVoiceToChange;
-
- int32_t pitchBend;
- float pitchBendAmount;
-
- int currentNote;
- int currentVoice;
- int currentVelocity;
- int maxLength;
-
-} tMPoly;
-
-/* MPoly*/
-void tMPoly_init(tMPoly* const, int numVoices);
-void tMPoly_free(tMPoly* const);
-
-void tMPoly_tick(tMPoly* const);
-
-//ADDING A NOTE
-int tMPoly_noteOn(tMPoly* const, int note, uint8_t vel);
-int tMPoly_noteOff(tMPoly* const, uint8_t note);
-void tMPoly_orderedAddToStack(tMPoly* const, uint8_t noteVal);
-void tMPoly_pitchBend(tMPoly* const, int pitchBend);
-void tMPoly_setNumVoices(tMPoly* const, uint8_t numVoices);
-void tMPoly_setPitchGlideTime(tMPoly* const, float t);
-int tMPoly_getNumVoices(tMPoly* const);
-float tMPoly_getPitch(tMPoly* const, uint8_t voice);
-int tMPoly_getVelocity(tMPoly* const, uint8_t voice);
-int tMPoly_isOn(tMPoly* const, uint8_t voice);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
--- a/LEAF/Inc_cpp/leaf-oscillator.hpp
+++ /dev/null
@@ -1,174 +1,0 @@
-/*
- ==============================================================================
-
- LEAFOscillator.h
- Created: 20 Jan 2017 12:00:58pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFOSCILLATOR_H_INCLUDED
-#define LEAFOSCILLATOR_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-filter.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tNeuron */
-typedef enum NeuronMode
-{
- NeuronNormal = 0,
- NeuronTanh,
- NeuronAaltoShaper,
- NeuronModeNil
-} NeuronMode;
-
-typedef struct _tNeuron
-{
- tPoleZero f;
-
- NeuronMode mode;
-
- float voltage, current;
- float timeStep;
-
- float alpha[3];
- float beta[3];
- float rate[3];
- float V[3];
- float P[3];
- float gK, gN, gL, C;
-} tNeuron;
-
-void tNeuron_init (tNeuron* const);
-void tNeuron_free (tNeuron* const);
-
-void tNeuron_reset (tNeuron* const);
-float tNeuron_Tick (tNeuron* const);
-void tNeuron_setMode (tNeuron* const, NeuronMode mode);
-void tNeuron_setCurrent (tNeuron* const, float current);
-void tNeuron_setK (tNeuron* const, float K);
-void tNeuron_setL (tNeuron* const, float L);
-void tNeuron_setN (tNeuron* const, float N);
-void tNeuron_setC (tNeuron* const, float C);
-void tNeuron_setV1 (tNeuron* const, float V1);
-void tNeuron_setV2 (tNeuron* const, float V2);
-void tNeuron_setV3 (tNeuron* const, float V3);
-void tNeuron_setTimeStep (tNeuron* const, float timestep);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tPhasor: Aliasing phasor [0.0, 1.0) */
-typedef struct _tPhasor
-{
- float phase;
- float inc,freq;
-
-} tPhasor;
-
-void tPhasor_init (tPhasor* const);
-void tPhasor_free (tPhasor* const);
-
-float tPhasor_tick (tPhasor* const);
-int tPhasor_setFreq (tPhasor* const, float freq);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tCycle: Cycle/Sine waveform. Wavetable synthesis.*/
-typedef struct _tCycle
-{
- // Underlying phasor
- float phase;
- float inc,freq;
-
-} tCycle;
-
-void tCycle_init (tCycle* const);
-void tCycle_free (tCycle* const);
-
-float tCycle_tick (tCycle* const);
-int tCycle_setFreq (tCycle* const, float freq);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */
-typedef struct _tSawtooth
-{
- // Underlying phasor
- float phase;
- float inc,freq;
-
-} tSawtooth;
-
-void tSawtooth_init (tSawtooth* const);
-void tSawtooth_free (tSawtooth* const);
-
-float tSawtooth_tick (tSawtooth* const);
-int tSawtooth_setFreq (tSawtooth* const, float freq);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */
-typedef struct _tTriangle
-{
- // Underlying phasor
- float phase;
- float inc,freq;
-
-} tTriangle;
-
-void tTriangle_init (tTriangle* const);
-void tTriangle_free (tTriangle* const);
-
-float tTriangle_tick (tTriangle* const);
-int tTriangle_setFreq (tTriangle* const, float freq);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */
-typedef struct _tSquare
-{
- // Underlying phasor
- float phase;
- float inc,freq;
-
-} tSquare;
-
-void tSquare_init (tSquare* const);
-void tSquare_free (tSquare* const);
-
-float tSquare_tick (tSquare* const);
-int tSquare_setFreq (tSquare* const, float freq);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tNoise. WhiteNoise, PinkNoise. */
-typedef enum NoiseType
-{
- WhiteNoise=0,
- PinkNoise,
- NoiseTypeNil,
-} NoiseType;
-
-typedef struct _tNoise
-{
- NoiseType type;
- float pinkb0, pinkb1, pinkb2;
- float(*rand)();
-
-} tNoise;
-
-void tNoise_init (tNoise* const, NoiseType type);
-void tNoise_free (tNoise* const);
-
-float tNoise_tick (tNoise* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#endif // LEAFOSCILLATOR_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-pitch.hpp
+++ /dev/null
@@ -1,228 +1,0 @@
-/*
- ==============================================================================
-
- leaf-pitch.h
- Created: 30 Nov 2018 11:03:13am
- Author: airship
-
- ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-filter.h"
-#include "leaf-utilities.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#define DEFPITCHRATIO 2.0f
-#define DEFTIMECONSTANT 100.0f
-#define DEFHOPSIZE 64
-#define DEFWINDOWSIZE 64
-#define FBA 20
-#define HPFREQ 40.0f
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tSOLAD : pitch shifting algorithm that underlies tPitchShifter etc */
-#define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two
-#define LOOPMASK (LOOPSIZE - 1)
-#define PITCHFACTORDEFAULT 1.0f
-#define INITPERIOD 64.0f
-#define MAXPERIOD (float)((LOOPSIZE - w->blocksize) * 0.8f)
-#define MINPERIOD 8.0f
-
-typedef struct _tSOLAD
-{
- uint16_t timeindex; // current reference time, write index
- uint16_t blocksize; // signal input / output block size
- float pitchfactor; // pitch factor between 0.25 and 4
- float readlag; // read pointer's lag behind write pointer
- float period; // period length in input signal
- float jump; // read pointer jump length and direction
- float xfadelength; // crossfade length expressed at input sample rate
- float xfadevalue; // crossfade phase and value
-
- float delaybuf[LOOPSIZE+16];
-
-} tSOLAD;
-
-void tSOLAD_init (tSOLAD* const);
-void tSOLAD_free (tSOLAD* const);
-
-// send one block of input samples, receive one block of output samples
-void tSOLAD_ioSamples (tSOLAD *w, float* in, float* out, int blocksize);
-
-// set periodicity analysis data
-void tSOLAD_setPeriod (tSOLAD *w, float period);
-
-// set pitch factor between 0.25 and 4
-void tSOLAD_setPitchFactor (tSOLAD *w, float pitchfactor);
-
-// force readpointer lag
-void tSOLAD_setReadLag (tSOLAD *w, float readlag);
-
-// reset state variables
-void tSOLAD_resetState (tSOLAD *w);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// tSNAC: period detector
-#define SNAC_FRAME_SIZE 1024 // default analysis framesize // should be the same as (or smaller than?) PS_FRAME_SIZE
-#define DEFOVERLAP 1 // default overlap
-#define DEFBIAS 0.2f // default bias
-#define DEFMINRMS 0.003f // default minimum RMS
-#define SEEK 0.85f // seek-length as ratio of framesize
-
-typedef struct _tSNAC
-{
- float inputbuf[SNAC_FRAME_SIZE];
- float processbuf[SNAC_FRAME_SIZE * 2];
- float spectrumbuf[SNAC_FRAME_SIZE / 2];
- float biasbuf[SNAC_FRAME_SIZE];
-
- uint16_t timeindex;
- uint16_t framesize;
- uint16_t overlap;
- uint16_t periodindex;
-
- float periodlength;
- float fidelity;
- float biasfactor;
- float minrms;
-
-} tSNAC;
-
-void tSNAC_init (tSNAC* const, int overlaparg); // constructor
-void tSNAC_free (tSNAC* const); // destructor
-
-void tSNAC_ioSamples (tSNAC *s, float *in, float *out, int size);
-void tSNAC_setOverlap (tSNAC *s, int lap);
-void tSNAC_setBias (tSNAC *s, float bias);
-void tSNAC_setMinRMS (tSNAC *s, float rms);
-
-/*To get freq, perform SAMPLE_RATE/snac_getperiod() */
-float tSNAC_getPeriod (tSNAC *s);
-float tSNAC_getfidelity (tSNAC *s);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// Pitch shifter
-typedef struct _tPitchShifter
-{
- tEnv env;
- tSNAC snac;
- tSOLAD sola;
- tHighpass hp;
-
- float* inBuffer;
- float* outBuffer;
- int frameSize;
- int bufSize;
- int framesPerBuffer;
- int curBlock;
- int lastBlock;
- int index;
-
- uint16_t hopSize;
- uint16_t windowSize;
- uint8_t fba;
-
- float pitchFactor;
- float timeConstant;
- float radius;
- float max;
- float lastmax;
- float deltamax;
-
-} tPitchShifter;
-
-void tPitchShifter_init (tPitchShifter* const, float* in, float* out, int bufSize, int frameSize);
-void tPitchShifter_free (tPitchShifter* const);
-
-float tPitchShifter_tick (tPitchShifter* const, float sample);
-float tPitchShifterToFreq_tick (tPitchShifter* const, float sample, float freq);
-float tPitchShifterToFunc_tick (tPitchShifter* const, float sample, float (*fun)(float));
-void tPitchShifter_ioSamples_toFreq (tPitchShifter* const, float* in, float* out, int size, float toFreq);
-void tPitchShifter_ioSamples_toPeriod(tPitchShifter* const, float* in, float* out, int size, float toPeriod);
-void tPitchShifter_ioSamples_toFunc (tPitchShifter* const, float* in, float* out, int size, float (*fun)(float));
-void tPitchShifter_setPitchFactor (tPitchShifter* const, float pf);
-void tPitchShifter_setTimeConstant (tPitchShifter* const, float tc);
-void tPitchShifter_setHopSize (tPitchShifter* const, int hs);
-void tPitchShifter_setWindowSize (tPitchShifter* const, int ws);
-float tPitchShifter_getPeriod (tPitchShifter* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// Period detection
-typedef struct _tPeriod
-{
- tEnv env;
- tSNAC snac;
- float* inBuffer;
- float* outBuffer;
- int frameSize;
- int bufSize;
- int framesPerBuffer;
- int curBlock;
- int lastBlock;
- int i;
- int indexstore;
- int iLast;
- int index;
- float period;
-
- uint16_t hopSize;
- uint16_t windowSize;
- uint8_t fba;
-
- float timeConstant;
- float radius;
- float max;
- float lastmax;
- float deltamax;
-
-}tPeriod;
-
-void tPeriod_init (tPeriod* const, float* in, float* out, int bufSize, int frameSize);
-void tPeriod_free (tPeriod* const);
-
-float tPeriod_findPeriod (tPeriod* const, float sample);
-void tPeriod_setHopSize (tPeriod* p, int hs);
-void tPeriod_setWindowSize (tPeriod* p, int ws);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// Pitch shift
-typedef struct _tPitchShift
-{
- tSOLAD sola;
- tHighpass hp;
- tPeriod* p;
-
- float* outBuffer;
- int frameSize;
- int bufSize;
-
- int framesPerBuffer;
- int curBlock;
- int lastBlock;
- int index;
-
- float pitchFactor;
- float timeConstant;
- float radius;
-} tPitchShift;
-
-void tPitchShift_init (tPitchShift* const, tPeriod* const, float* out, int bufSize);
-void tPitchShift_free (tPitchShift* const);
-
-float tPitchShift_shift (tPitchShift* const);
-float tPitchShift_shiftToFunc (tPitchShift* const, float (*fun)(float));
-float tPitchShift_shiftToFreq (tPitchShift* const, float freq);
-void tPitchShift_setPitchFactor (tPitchShift* const, float pf);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
--- a/LEAF/Inc_cpp/leaf-reverb.hpp
+++ /dev/null
@@ -1,139 +1,0 @@
-/*
- ==============================================================================
-
- LEAFReverb.h
- Created: 20 Jan 2017 12:02:04pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFREVERB_H_INCLUDED
-#define LEAFREVERB_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-delay.h"
-#include "leaf-filter.h"
-#include "leaf-oscillator.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */
-typedef struct _tPRCRev
-{
- float mix, t60;
-
- float inv_441;
-
- tDelay* allpassDelays[2];
- tDelay* combDelay;
- float allpassCoeff;
- float combCoeff;
-
- float lastIn, lastOut;
-
-} tPRCRev;
-
-void tPRCRev_init (tPRCRev* const, float t60);
-void tPRCRev_free (tPRCRev* const);
-
-float tPRCRev_tick (tPRCRev* const, float input);
-
-// Set reverb time in seconds.
-void tPRCRev_setT60 (tPRCRev* const, float t60);
-
-// Set mix between dry input and wet output signal.
-void tPRCRev_setMix (tPRCRev* const, float mix);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* NRev: Reverb, reimplemented from STK (Cook and Scavone). */
-typedef struct _tNRev
-{
- float mix, t60;
-
- float inv_sr, inv_441;
-
- tDelay* allpassDelays[8];
- tDelay* combDelays[6];
- float allpassCoeff;
- float combCoeffs[6];
- float lowpassState;
-
- float lastIn, lastOut;
-
-} tNRev;
-
-void tNRev_init (tNRev* const, float t60);
-void tNRev_free (tNRev* const);
-
-float tNRev_tick (tNRev* const, float input);
-
-// Set reverb time in seconds.
-void tNRev_setT60 (tNRev* const, float t60);
-
-// Set mix between dry input and wet output signal.
-void tNRev_setMix (tNRev* const, float mix);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-
-typedef struct _tDattorro
-{
- float predelay;
- float input_filter;
- float feedback_filter;
- float feedback_gain;
- float mix;
-
- float size, t;
-
- float f1_delay_2_last,
- f2_delay_2_last;
-
- float f1_last,
- f2_last;
-
- // INPUT
- tDelayL in_delay;
- tOnePole in_filter;
- tAllpass in_allpass[4];
-
- // FEEDBACK 1
- tAllpass f1_allpass;
- tDelayL f1_delay_1;
- tOnePole f1_filter;
- tDelayL f1_delay_2;
- tDelayL f1_delay_3;
-
- tCycle f1_lfo;
-
- // FEEDBACK 2
- tAllpass f2_allpass;
- tDelayL f2_delay_1;
- tOnePole f2_filter;
- tDelayL f2_delay_2;
- tDelayL f2_delay_3;
-
- tCycle f2_lfo;
-
-} tDattorro;
-
-void tDattorro_init (tDattorro* const);
-void tDattorro_free (tDattorro* const);
-
-float tDattorro_tick (tDattorro* const, float input);
-
-void tDattorro_setMix (tDattorro* const, float mix);
-void tDattorro_setSize (tDattorro* const, float size);
-void tDattorro_setInputDelay (tDattorro* const, float preDelay);
-void tDattorro_setInputFilter (tDattorro* const, float freq);
-void tDattorro_setFeedbackFilter (tDattorro* const, float freq);
-void tDattorro_setFeedbackGain (tDattorro* const, float gain);
-
-
-#endif // LEAFREVERB_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-string.hpp
+++ /dev/null
@@ -1,129 +1,0 @@
-/*
- ==============================================================================
-
- leaf-string.h
- Created: 30 Nov 2018 10:41:55am
- Author: airship
-
- ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-#include "leaf-delay.h"
-#include "leaf-filter.h"
-#include "leaf-oscillator.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Karplus Strong model */
-typedef struct _tPluck
-{
- tDelayA* delayLine; // Allpass or Linear?? big difference...
- tOneZero* loopFilter;
- tOnePole* pickFilter;
- tNoise* noise;
-
- float lastOut;
- float loopGain;
- float lastFreq;
-
- float sr;
-
-} tPluck;
-
-void tPluck_init (tPluck* const, float lowestFrequency); //float delayBuff[DELAY_LENGTH]);
-void tPluck_free (tPluck* const);
-
-float tPluck_tick (tPluck* const);
-
-// Pluck the string.
-void tPluck_pluck (tPluck* const, float amplitude);
-
-// Start a note with the given frequency and amplitude.;
-void tPluck_noteOn (tPluck* const, float frequency, float amplitude );
-
-// Stop a note with the given amplitude (speed of decay).
-void tPluck_noteOff (tPluck* const, float amplitude );
-
-// Set instrument parameters for a particular frequency.
-void tPluck_setFrequency (tPluck* const, float frequency );
-
-// Perform the control change specified by \e number and \e value (0.0 - 128.0).
-void tPluck_controlChange (tPluck* const, int number, float value);
-
-// tPluck Utilities.
-float tPluck_getLastOut (tPluck* const);
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Stif Karplus Strong model */
-typedef struct _tStifKarp
-{
- tDelayA* delayLine;
- tDelayL* combDelay;
- tOneZero* filter;
- tNoise* noise;
- tBiQuad* biquad[4];
-
-
-
- uint32_t length;
- float loopGain;
- float baseLoopGain;
- float lastFrequency;
- float lastLength;
- float stretching;
- float pluckAmplitude;
- float pickupPosition;
-
- float lastOut;
-
-} tStifKarp;
-
-typedef enum SKControlType
-{
- SKPickPosition = 0,
- SKStringDamping,
- SKDetune,
- SKControlTypeNil
-} SKControlType;
-
-void tStifKarp_init (tStifKarp* const, float lowestFrequency); // float delayBuff[2][DELAY_LENGTH]);
-void tStifKarp_free (tStifKarp* const);
-
-float tStifKarp_tick (tStifKarp* const);
-
-// Pluck the string.
-void tStifKarp_pluck (tStifKarp* const, float amplitude);
-
-// Start a note with the given frequency and amplitude.;
-void tStifKarp_noteOn (tStifKarp* const, float frequency, float amplitude );
-
-// Stop a note with the given amplitude (speed of decay).
-void tStifKarp_noteOff (tStifKarp* const, float amplitude );
-
-// Set instrument parameters for a particular frequency.
-void tStifKarp_setFrequency (tStifKarp* const, float frequency );
-
-// Perform the control change specified by \e number and \e value (0.0 - 128.0).
-// Use SKPickPosition, SKStringDamping, or SKDetune for type.
-void tStifKarp_controlChange (tStifKarp* const, SKControlType type, float value);
-
-// Set the stretch "factor" of the string (0.0 - 1.0).
-void tStifKarp_setStretch (tStifKarp* const, float stretch );
-
-// Set the pluck or "excitation" position along the string (0.0 - 1.0).
-void tStifKarp_setPickupPosition (tStifKarp* const, float position );
-
-// Set the base loop gain.
-void tStifKarp_setBaseLoopGain (tStifKarp* const, float aGain );
-
-// tStifKarp utilities.
-float tStifKarp_getLastOut (tStifKarp* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
--- a/LEAF/Inc_cpp/leaf-utilities.hpp
+++ /dev/null
@@ -1,249 +1,0 @@
-/*
- ==============================================================================
-
- LEAFUtilities.h
- Created: 20 Jan 2017 12:02:17pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFUTILITIES_H_INCLUDED
-#define LEAFUTILITIES_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// STACK implementation (fixed size)
-#define STACK_SIZE 128
-typedef struct _tStack
-{
- int data[STACK_SIZE];
- uint16_t pos;
- uint16_t size;
- uint16_t capacity;
- oBool ordered;
-
-} tStack;
-
-void tStack_init (tStack* const);
-void tStack_free (tStack* const);
-
-void tStack_setCapacity (tStack* const, uint16_t cap);
-int tStack_addIfNotAlreadyThere (tStack* const, uint16_t item);
-void tStack_add (tStack* const, uint16_t item);
-int tStack_remove (tStack* const, uint16_t item);
-void tStack_clear (tStack* const);
-int tStack_first (tStack* const);
-int tStack_getSize (tStack* const);
-int tStack_contains (tStack* const, uint16_t item);
-int tStack_next (tStack* const);
-int tStack_get (tStack* const, int which);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Ramp */
-typedef struct _tRamp {
- float inc;
- float inv_sr_ms;
- float minimum_time;
- float curr,dest;
- float time;
- int samples_per_tick;
-
-} tRamp;
-
-void tRamp_init (tRamp* const, float time, int samplesPerTick);
-void tRamp_free (tRamp* const);
-
-float tRamp_tick (tRamp* const);
-float tRamp_sample (tRamp* const);
-int tRamp_setTime (tRamp* const, float time);
-int tRamp_setDest (tRamp* const, float dest);
-int tRamp_setVal (tRamp* const, float val);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Compressor */
-typedef struct _tCompressor
-{
- float tauAttack, tauRelease;
- float T, R, W, M; // Threshold, compression Ratio, decibel Width of knee transition, decibel Make-up gain
-
- float x_G[2], y_G[2], x_T[2], y_T[2];
-
- oBool isActive;
-
-}tCompressor;
-
-void tCompressor_init (tCompressor* const);
-void tCompressor_free (tCompressor* const);
-float tCompressor_tick (tCompressor* const, float input);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Attack-Decay envelope */
-typedef struct _tEnvelope {
-
- const float *exp_buff;
- const float *inc_buff;
- uint32_t buff_size;
-
- float next;
-
- float attackInc, decayInc, rampInc;
-
- oBool inAttack, inDecay, inRamp;
-
- oBool loop;
-
- float gain, rampPeak;
-
- float attackPhase, decayPhase, rampPhase;
-
-} tEnvelope;
-
-void tEnvelope_init (tEnvelope* const, float attack, float decay, oBool loop);
-void tEnvelope_free (tEnvelope* const);
-
-float tEnvelope_tick (tEnvelope* const);
-int tEnvelope_setAttack (tEnvelope* const, float attack);
-int tEnvelope_setDecay (tEnvelope* const, float decay);
-int tEnvelope_loop (tEnvelope* const, oBool loop);
-int tEnvelope_on (tEnvelope* const, float velocity);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* ADSR */
-typedef struct _tADSR
-{
- const float *exp_buff;
- const float *inc_buff;
- uint32_t buff_size;
-
- float next;
-
- float attackInc, decayInc, releaseInc, rampInc;
-
- oBool inAttack, inDecay, inSustain, inRelease, inRamp;
-
- float sustain, gain, rampPeak, releasePeak;
-
- float attackPhase, decayPhase, releasePhase, rampPhase;
-
-} tADSR;
-
-void tADSR_init (tADSR* const, float attack, float decay, float sustain, float release);
-void tADSR_free (tADSR* const);
-
-float tADSR_tick (tADSR* const);
-int tADSR_setAttack (tADSR* const, float attack);
-int tADSR_setDecay (tADSR* const, float decay);
-int tADSR_setSustain(tADSR* const, float sustain);
-int tADSR_setRelease(tADSR* const, float release);
-int tADSR_on (tADSR* const, float velocity);
-int tADSR_off (tADSR* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Envelope Follower */
-typedef struct _tEnvelopeFollower
-{
- float y;
- float a_thresh;
- float d_coeff;
-
-} tEnvelopeFollower;
-
-void tEnvelopeFollower_init (tEnvelopeFollower* const, float attackThreshold, float decayCoeff);
-void tEnvelopeFollower_free (tEnvelopeFollower* const);
-
-float tEnvelopeFollower_tick (tEnvelopeFollower* const, float x);
-int tEnvelopeFollower_decayCoeff (tEnvelopeFollower* const, float decayCoeff);
-int tEnvelopeFollower_attackThresh (tEnvelopeFollower* const, float attackThresh);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tAtkDtk */
-#define DEFBLOCKSIZE 1024
-#define DEFTHRESHOLD 6
-#define DEFATTACK 10
-#define DEFRELEASE 10
-
-typedef struct _tAtkDtk
-{
- float env;
-
- //Attack & Release times in msec
- int atk;
- int rel;
-
- //Attack & Release coefficients based on times
- float atk_coeff;
- float rel_coeff;
-
- int blocksize;
- int samplerate;
-
- //RMS amplitude of previous block - used to decide if attack is present
- float prevAmp;
-
- float threshold;
-} tAtkDtk;
-
-void tAtkDtk_init (tAtkDtk* const, int blocksize);
-void tAtkDtk_init_expanded (tAtkDtk* const, int blocksize, int atk, int rel);
-void tAtkDtk_free (tAtkDtk* const);
-
-// set expected input blocksize
-void tAtkDtk_setBlocksize (tAtkDtk* const, int size);
-
-// change atkDetector sample rate
-void tAtkDtk_setSamplerate (tAtkDtk* const, int inRate);
-
-// set attack time and coeff
-void tAtkDtk_setAtk (tAtkDtk* const, int inAtk);
-
-// set release time and coeff
-void tAtkDtk_setRel (tAtkDtk* const, int inRel);
-
-// set level above which values are identified as attacks
-void tAtkDtk_setThreshold (tAtkDtk* const, float thres);
-
-// find largest transient in input block, return index of attack
-int tAtkDtk_detect (tAtkDtk* const, float *in);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-// ENV~ from PD, modified for LEAF
-#define MAXOVERLAP 32
-#define INITVSTAKEN 64
-
-typedef struct _tEnv
-{
- float buf[ENV_WINDOW_SIZE + INITVSTAKEN];
- uint16_t x_phase; /* number of points since last output */
- uint16_t x_period; /* requested period of output */
- uint16_t x_realperiod; /* period rounded up to vecsize multiple */
- uint16_t x_npoints; /* analysis window size in samples */
- float x_result; /* result to output */
- float x_sumbuf[MAXOVERLAP]; /* summing buffer */
- float x_f;
- uint16_t windowSize, hopSize, blockSize;
- uint16_t x_allocforvs; /* extra buffer for DSP vector size */
-} tEnv;
-
-void tEnv_init (tEnv* const, int windowSize, int hopSize, int blockSize);
-void tEnv_free (tEnv* const);
-float tEnv_tick (tEnv* const);
-void tEnv_processBlock (tEnv* const, float* in);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#endif // LEAFUTILITIES_H_INCLUDED
-
-
--- a/LEAF/Inc_cpp/leaf-vocoder.hpp
+++ /dev/null
@@ -1,80 +1,0 @@
-/*
- ==============================================================================
-
- LEAFInstrument.h
- Created: 20 Jan 2017 12:01:54pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef LEAFINSTRUMENT_H_INCLUDED
-#define LEAFINSTRUMENT_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tTalkbox */
-#define NUM_TALKBOX_PARAM 4
-#define TALKBOX_BUFFER_LENGTH 1024 //1600
-
-typedef struct _tTalkbox
-{
- float param[NUM_TALKBOX_PARAM];
-
- ///global internal variables
- float car0[TALKBOX_BUFFER_LENGTH], car1[TALKBOX_BUFFER_LENGTH];
- float window[TALKBOX_BUFFER_LENGTH];
- float buf0[TALKBOX_BUFFER_LENGTH], buf1[TALKBOX_BUFFER_LENGTH];
-
- float emphasis;
- int32_t K, N, O, pos;
- float wet, dry, FX;
- float d0, d1, d2, d3, d4;
- float u0, u1, u2, u3, u4;
-
-} tTalkbox;
-
-void tTalkbox_init (tTalkbox* const);
-void tTalkbox_free (tTalkbox* const);
-float tTalkbox_tick (tTalkbox* const, float synth, float voice);
-void tTalkbox_update (tTalkbox* const);
-void tTalkbox_suspend (tTalkbox* const);
-void tTalkbox_lpcDurbin (float *r, int p, float *k, float *g);
-void tTalkbox_lpc (float *buf, float *car, int32_t n, int32_t o);
-void tTalkbox_setQuality (tTalkbox* const, float quality);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tVocoder */
-#define NUM_VOCODER_PARAM 8
-#define NBANDS 16
-
-typedef struct _tVocoder
-{
- float param[NUM_VOCODER_PARAM];
-
- float gain; //output level
- float thru, high; //hf thru
- float kout; //downsampled output
- int32_t kval; //downsample counter
- int32_t nbnd; //number of bands
-
- //filter coeffs and buffers - seems it's faster to leave this global than make local copy
- float f[NBANDS][13]; //[0-8][0 1 2 | 0 1 2 3 | 0 1 2 3 | val rate]
-
-} tVocoder;
-
-void tVocoder_init (tVocoder* const);
-void tVocoder_free (tVocoder* const);
-float tVocoder_tick (tVocoder* const, float synth, float voice);
-void tVocoder_update (tVocoder* const);
-void tVocoder_suspend (tVocoder* const);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#endif // LEAFINSTRUMENT_H_INCLUDED
--- a/LEAF/Inc_cpp/leaf-wavefolder.hpp
+++ /dev/null
@@ -1,43 +1,0 @@
-/*
- ==============================================================================
-
- leaf-wavefolder.h
- Created: 30 Nov 2018 11:57:05am
- Author: airship
-
- ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* tLockhartWavefolder */
-#define THRESH 10e-10
-#define ILL_THRESH 10e-10
-#define LOCKHART_RL 7.5e3
-#define LOCKHART_R 15e3
-#define LOCKHART_VT 26e-3
-#define LOCKHART_Is 10e-16
-#define LOCKHART_A 2.0*LOCKHART_RL/LOCKHART_R
-#define LOCKHART_B (LOCKHART_R+2.0*LOCKHART_RL)/(LOCKHART_VT*LOCKHART_R)
-#define LOCKHART_D (LOCKHART_RL*LOCKHART_Is)/LOCKHART_VT
-#define VT_DIV_B LOCKHART_VT/LOCKHART_B
-
-typedef struct _tLockhartWavefolder
-{
- double Ln1;
- double Fn1;
- double xn1;
-
-} tLockhartWavefolder;
-
-void tLockhartWavefolder_init (tLockhartWavefolder* const);
-void tLockhartWavefolder_free (tLockhartWavefolder* const);
-
-float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
--- a/LEAF/Inc_cpp/leaf-wavetables.hpp
+++ /dev/null
@@ -1,74 +1,0 @@
-/*
- ==============================================================================
-
- LEAFWavetables.h
- Created: 4 Dec 2016 9:42:41pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#ifndef WAVETABLES_H_INCLUDED
-#define WAVETABLES_H_INCLUDED
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-
-#define SINE_TABLE_SIZE 2048
-#define SAW_TABLE_SIZE 2048
-#define SQR_TABLE_SIZE 2048
-#define TRI_TABLE_SIZE 2048
-#define EXP_DECAY_TABLE_SIZE 65536
-#define ATTACK_DECAY_INC_TABLE_SIZE 65536
-#define TANH1_TABLE_SIZE 65536
-#define DECAY_COEFF_TABLE_SIZE 4096
-#define MTOF1_TABLE_SIZE 4096
-#define FILTERTAN_TABLE_SIZE 4096
-
-typedef enum TableName
-{
- T20 = 0,
- T40,
- T80,
- T160,
- T320,
- T640,
- T1280,
- T2560,
- T5120,
- T10240,
- T20480,
- TableNameNil
-} TableName;
-
-// mtof lookup table based on input range [0.0,1.0) in 4096 increments - midi frequency values scaled between m25 and m134 (from the Snyderphonics DrumBox code)
-
-extern const float exp_decay[EXP_DECAY_TABLE_SIZE];
-extern const float attack_decay_inc[ATTACK_DECAY_INC_TABLE_SIZE];
-
-extern const float filtertan[FILTERTAN_TABLE_SIZE];
-
-extern const float mtof1[MTOF1_TABLE_SIZE];
-extern const float decayCoeffTable[DECAY_COEFF_TABLE_SIZE];
-
-extern const float tanh1[TANH1_TABLE_SIZE];
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-/* Sine wave table ripped from http://aquaticus.info/pwm-sine-wave. */
-extern const float sinewave[SINE_TABLE_SIZE];
-
-extern const float sawtooth[11][SAW_TABLE_SIZE];
-
-extern const float triangle[11][TRI_TABLE_SIZE];
-
-extern const float squarewave[11][SQR_TABLE_SIZE];
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
-#endif // WAVETABLES_H_INCLUDED
--- a/LEAF/Src/leaf-delay.c
+++ b/LEAF/Src/leaf-delay.c
@@ -63,9 +63,9 @@
int tDelay_setDelay (tDelay* const d, uint32_t delay)
{
- if (delay >= d->maxDelay) d->delay = d->maxDelay;
- else d->delay = delay;
+ d->delay = LEAF_clip(0.0f, delay, d->maxDelay);
+
// read chases write
if ( d->inPoint >= delay ) d->outPoint = d->inPoint - d->delay;
else d->outPoint = d->maxDelay + d->inPoint - d->delay;
@@ -163,29 +163,26 @@
d->buff[d->inPoint] = input * d->gain;
// Increment input pointer modulo length.
- if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0;
+ if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0;
+
+
+ uint32_t idx = (uint32_t) d->outPoint;
+
+ d->lastOut = LEAF_interpolate_hermite (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay],
+ d->buff[idx],
+ d->buff[(idx + 1) % d->maxDelay],
+ d->buff[(idx + 2) % d->maxDelay],
+ d->alpha);
+ // Increment output pointer modulo length
+ if ( (++d->outPoint) >= d->maxDelay ) d->outPoint = 0;
- // First 1/2 of interpolation
- d->lastOut = d->buff[d->outPoint] * d->omAlpha;
-
- // Second 1/2 of interpolation
- if (d->outPoint + 1 < d->maxDelay)
- d->lastOut += d->buff[d->outPoint+1] * d->alpha;
- else
- d->lastOut += d->buff[0] * d->alpha;
-
- // Increment output pointer modulo length.
- if ( ++(d->outPoint) == d->maxDelay ) d->outPoint = 0;
-
return d->lastOut;
}
int tDelayL_setDelay (tDelayL* const d, float delay)
-{
- if (delay < 0.0f) d->delay = 0.0f;
- else if (delay <= d->maxDelay) d->delay = delay;
- else d->delay = d->maxDelay;
+{
+ d->delay = LEAF_clip(0.0f, delay, d->maxDelay);
float outPointer = d->inPoint - d->delay;
@@ -326,10 +323,9 @@
int tDelayA_setDelay (tDelayA* const d, float delay)
{
- if (delay < 0.5f) d->delay = 0.5f;
- else if (delay <= d->maxDelay) d->delay = delay;
- else d->delay = d->maxDelay;
+ d->delay = LEAF_clip(0.5f, delay, d->maxDelay);
+
// outPoint chases inPoint
float outPointer = (float)d->inPoint - d->delay + 1.0f;
@@ -413,5 +409,144 @@
float tDelayA_getGain (tDelayA* const d)
{
return d->gain;
+}
+
+// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TapeDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
+void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay)
+{
+ d->maxDelay = maxDelay;
+
+ d->delay = LEAF_clip(1.f, delay, d->maxDelay);
+
+ d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
+
+ d->gain = 1.0f;
+
+ d->lastIn = 0.0f;
+ d->lastOut = 0.0f;
+
+ d->idx = 0.0f;
+ d->inc = 1.0f;
+ d->inPoint = 0;
+
+ tTapeDelay_setDelay(d, 1.f);
+}
+
+void tTapeDelay_free(tTapeDelay* const d)
+{
+ leaf_free(d->buff);
+ leaf_free(d);
+}
+
+int count = 0;
+
+#define SMOOTH_FACTOR 10.f
+
+float tTapeDelay_tick (tTapeDelay* const d, float input)
+{
+ d->buff[d->inPoint] = input * d->gain;
+
+ // Increment input pointer modulo length.
+ if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0;
+
+ int idx = (int) d->idx;
+ float alpha = d->idx - idx;
+
+ d->lastOut = LEAF_interpolate_hermite (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay],
+ d->buff[idx],
+ d->buff[(idx + 1) % d->maxDelay],
+ d->buff[(idx + 2) % d->maxDelay],
+ alpha);
+
+ float diff = (d->inPoint - d->idx);
+ while (diff < 0.f) diff += d->maxDelay;
+
+ d->inc = 1.0f + (diff - d->delay) / d->delay * SMOOTH_FACTOR;
+
+ d->idx += d->inc;
+
+ if (d->idx >= d->maxDelay) d->idx = 0.f;
+
+ return d->lastOut;
+}
+
+
+void tTapeDelay_setRate(tTapeDelay* const d, float rate)
+{
+ d->inc = rate;
+}
+
+int tTapeDelay_setDelay (tTapeDelay* const d, float delay)
+{
+ d->delay = LEAF_clip(1.f, delay, d->maxDelay);
+
+ return 0;
+}
+
+float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay)
+{
+ float tap = (float) d->inPoint - tapDelay - 1.f;
+
+ // Check for wraparound.
+ while ( tap < 0.f ) tap += (float)d->maxDelay;
+
+ int idx = (int) tap;
+
+ float alpha = tap - idx;
+
+ float samp = LEAF_interpolate_hermite (d->buff[((idx - 1) + d->maxDelay) % d->maxDelay],
+ d->buff[idx],
+ d->buff[(idx + 1) % d->maxDelay],
+ d->buff[(idx + 2) % d->maxDelay],
+ alpha);
+
+ return samp;
+
+}
+
+void tTapeDelay_tapIn (tTapeDelay* const d, float value, uint32_t tapDelay)
+{
+ int32_t tap = d->inPoint - tapDelay - 1;
+
+ // Check for wraparound.
+ while ( tap < 0 ) tap += d->maxDelay;
+
+ d->buff[tap] = value;
+}
+
+float tTapeDelay_addTo (tTapeDelay* const d, float value, uint32_t tapDelay)
+{
+ int32_t tap = d->inPoint - tapDelay - 1;
+
+ // Check for wraparound.
+ while ( tap < 0 ) tap += d->maxDelay;
+
+ return (d->buff[tap] += value);
+}
+
+float tTapeDelay_getDelay (tTapeDelay *d)
+{
+ return d->delay;
+}
+
+float tTapeDelay_getLastOut (tTapeDelay* const d)
+{
+ return d->lastOut;
+}
+
+float tTapeDelay_getLastIn (tTapeDelay* const d)
+{
+ return d->lastIn;
+}
+
+void tTapeDelay_setGain (tTapeDelay* const d, float gain)
+{
+ if (gain < 0.0f) d->gain = 0.0f;
+ else d->gain = gain;
+}
+
+float tTapeDelay_getGain (tTapeDelay* const d)
+{
+ return d->gain;
}
--- a/LEAF/Src/leaf-math.c
+++ b/LEAF/Src/leaf-math.c
@@ -23,7 +23,6 @@
#define EXPONENTIAL_TABLE_SIZE 65536
-
float interpolate3max(float *buf, const int peakindex)
{
float a = buf[peakindex-1];
@@ -72,6 +71,7 @@
alias.f = f;
alias.ui &= 0x7fffffff;
return alias.f;
+
}
// dope af
--- a/LEAF/Src/leaf-reverb.c
+++ b/LEAF/Src/leaf-reverb.c
@@ -262,43 +262,50 @@
float in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f };
float in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f };
+
void tDattorro_init (tDattorro* const r)
{
- tDattorro_setSize(r, 1.0f);
+ r->size_max = 2.0f;
+ r->size = 1.f;
+ r->t = r->size * leaf.sampleRate * 0.001f;
// INPUT
- tDelayL_init(&r->in_delay, 0.f, SAMP(200.f));
+ tTapeDelay_init(&r->in_delay, 0.f, SAMP(200.f));
tOnePole_init(&r->in_filter, 1.f);
for (int i = 0; i < 4; i++)
{
- tAllpass_init(&r->in_allpass[i], in_allpass_delays[i], SAMP(20.f));
+ tAllpass_init(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f)); // * r->size_max
tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
}
// FEEDBACK 1
- tAllpass_init(&r->f1_allpass, SAMP(30.51f), SAMP(100.f));
+ tAllpass_init(&r->f1_allpass, SAMP(30.51f), SAMP(100.f)); // * r->size_max
tAllpass_setGain(&r->f1_allpass, 0.7f);
- tDelayL_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f));
- tDelayL_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f));
- tDelayL_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f));
+ tTapeDelay_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1);
+ tTapeDelay_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1);
+ tTapeDelay_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f) * r->size_max + 1);
tOnePole_init(&r->f1_filter, 1.f);
+ tHighpass_init(&r->f1_hp, 20.f);
+
tCycle_init(&r->f1_lfo);
tCycle_setFreq(&r->f1_lfo, 0.1f);
// FEEDBACK 2
- tAllpass_init(&r->f2_allpass, SAMP(22.58f), SAMP(100.f));
+ tAllpass_init(&r->f2_allpass, SAMP(22.58f), SAMP(100.f)); // * r->size_max
tAllpass_setGain(&r->f2_allpass, 0.7f);
- tDelayL_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.0f));
- tDelayL_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.0f));
- tDelayL_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.0f));
+ tTapeDelay_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1);
+ tTapeDelay_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1);
+ tTapeDelay_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * r->size_max + 1);
tOnePole_init(&r->f2_filter, 1.f);
+ tHighpass_init(&r->f2_hp, 20.f);
+
tCycle_init(&r->f2_lfo);
tCycle_setFreq(&r->f2_lfo, 0.07f);
@@ -313,12 +320,14 @@
tDattorro_setFeedbackFilter(r, 5000.f);
tDattorro_setFeedbackGain(r, 0.4f);
+
+
}
void tDattorro_free (tDattorro* const r)
{
// INPUT
- tDelayL_free(&r->in_delay);
+ tTapeDelay_free(&r->in_delay);
tOnePole_free(&r->in_filter);
for (int i = 0; i < 4; i++)
@@ -329,9 +338,9 @@
// FEEDBACK 1
tAllpass_free(&r->f1_allpass);
- tDelayL_free(&r->f1_delay_1);
- tDelayL_free(&r->f1_delay_2);
- tDelayL_free(&r->f1_delay_3);
+ tTapeDelay_free(&r->f1_delay_1);
+ tTapeDelay_free(&r->f1_delay_2);
+ tTapeDelay_free(&r->f1_delay_3);
tOnePole_free(&r->f1_filter);
@@ -340,9 +349,9 @@
// FEEDBACK 2
tAllpass_free(&r->f2_allpass);
- tDelayL_free(&r->f2_delay_1);
- tDelayL_free(&r->f2_delay_2);
- tDelayL_free(&r->f2_delay_3);
+ tTapeDelay_free(&r->f2_delay_1);
+ tTapeDelay_free(&r->f2_delay_2);
+ tTapeDelay_free(&r->f2_delay_3);
tOnePole_free(&r->f2_filter);
@@ -354,7 +363,7 @@
float tDattorro_tick (tDattorro* const r, float input)
{
// INPUT
- float in_sample = tDelayL_tick(&r->in_delay, input);
+ float in_sample = tTapeDelay_tick(&r->in_delay, input);
in_sample = tOnePole_tick(&r->in_filter, in_sample);
@@ -370,21 +379,23 @@
f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
- f1_sample = tDelayL_tick(&r->f1_delay_1, f1_sample);
+ f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample);
f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
- float f1_delay_2_sample = tDelayL_tick(&r->f1_delay_2, f1_sample * 0.5f);
+ float f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f);
r->f1_delay_2_last = f1_delay_2_sample;
f1_sample = r->f1_delay_2_last + f1_sample;
+ f1_sample = tHighpass_tick(&r->f1_hp, f1_sample);
+
f1_sample *= r->feedback_gain;
- r->f1_last = tDelayL_tick(&r->f1_delay_3, f1_sample);
+ r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample);
// FEEDBACK 2
float f2_sample = in_sample + r->f1_last;
@@ -393,52 +404,54 @@
f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
- f2_sample = tDelayL_tick(&r->f2_delay_1, f2_sample);
+ f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample);
f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
- float f2_delay_2_sample = tDelayL_tick(&r->f2_delay_2, f2_sample * 0.5f);
+ float f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f);
r->f2_delay_2_last = f2_delay_2_sample;
f2_sample = r->f2_delay_2_last + f2_sample;
+ f2_sample = tHighpass_tick(&r->f2_hp, f2_sample);
+
f2_sample *= r->feedback_gain;
- r->f2_last = tDelayL_tick(&r->f2_delay_3, f2_sample);
+ r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample);
// TAP OUT 1
- f1_sample = tDelayL_tapOut(&r->f1_delay_1, SAMP(8.9f)) +
- tDelayL_tapOut(&r->f1_delay_1, SAMP(99.8f));
+ f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) +
+ tTapeDelay_tapOut(&r->f1_delay_1, SAMP(99.8f));
- f1_sample -= tDelayL_tapOut(&r->f1_delay_2, SAMP(64.2f));
+ f1_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(64.2f));
- f1_sample += tDelayL_tapOut(&r->f1_delay_3, SAMP(67.f));
+ f1_sample += tTapeDelay_tapOut(&r->f1_delay_3, SAMP(67.f));
- f1_sample -= tDelayL_tapOut(&r->f2_delay_1, SAMP(66.8f));
+ f1_sample -= tTapeDelay_tapOut(&r->f2_delay_1, SAMP(66.8f));
- f1_sample -= tDelayL_tapOut(&r->f2_delay_2, SAMP(6.3f));
+ f1_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f));
- f1_sample -= tDelayL_tapOut(&r->f2_delay_3, SAMP(35.8f));
+ f1_sample -= tTapeDelay_tapOut(&r->f2_delay_3, SAMP(35.8f));
f1_sample *= 0.14f;
// TAP OUT 2
- f2_sample = tDelayL_tapOut(&r->f2_delay_1, SAMP(11.8f)) +
- tDelayL_tapOut(&r->f2_delay_1, SAMP(121.7f));
+ f2_sample = tTapeDelay_tapOut(&r->f2_delay_1, SAMP(11.8f)) +
+ tTapeDelay_tapOut(&r->f2_delay_1, SAMP(121.7f));
- f2_sample -= tDelayL_tapOut(&r->f2_delay_2, SAMP(6.3f));
+ f2_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f));
- f2_sample += tDelayL_tapOut(&r->f2_delay_3, SAMP(89.7f));
+ f2_sample += tTapeDelay_tapOut(&r->f2_delay_3, SAMP(89.7f));
- f2_sample -= tDelayL_tapOut(&r->f1_delay_1, SAMP(70.8f));
+ f2_sample -= tTapeDelay_tapOut(&r->f1_delay_1, SAMP(70.8f));
- f2_sample -= tDelayL_tapOut(&r->f1_delay_2, SAMP(11.2f));
+ f2_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(11.2f));
- f2_sample -= tDelayL_tapOut(&r->f1_delay_3, SAMP(4.1f));
+ f2_sample -= tTapeDelay_tapOut(&r->f1_delay_3, SAMP(4.1f));
f2_sample *= 0.14f;
@@ -454,8 +467,31 @@
void tDattorro_setSize (tDattorro* const r, float size)
{
- r->size = LEAF_clip(0.001f, size, 100.0f);
+ r->size = LEAF_clip(0.01f, size*r->size_max, r->size_max);
r->t = r->size * leaf.sampleRate * 0.001f;
+
+ /*
+ for (int i = 0; i < 4; i++)
+ {
+ tAllpass_setDelay(&r->in_allpass[i], SAMP(in_allpass_delays[i]));
+ }
+ */
+
+ // FEEDBACK 1
+ //tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f));
+
+ tTapeDelay_setDelay(&r->f1_delay_1, SAMP(141.69f));
+ tTapeDelay_setDelay(&r->f1_delay_2, SAMP(89.24f));
+ tTapeDelay_setDelay(&r->f1_delay_3, SAMP(125.f));
+
+ // maybe change rate of SINE LFO's when size changes?
+
+ // FEEDBACK 2
+ //tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f));
+
+ tTapeDelay_setDelay(&r->f2_delay_1, SAMP(149.62f));
+ tTapeDelay_setDelay(&r->f2_delay_2, SAMP(60.48f));
+ tTapeDelay_setDelay(&r->f2_delay_3, SAMP(106.28f));
}
void tDattorro_setInputDelay (tDattorro* const r, float preDelay)
@@ -462,7 +498,7 @@
{
r->predelay = LEAF_clip(0.0f, preDelay, 200.0f);
- tDelayL_setDelay(&r->in_delay, SAMP(r->predelay));
+ tTapeDelay_setDelay(&r->in_delay, SAMP(r->predelay));
}
void tDattorro_setInputFilter (tDattorro* const r, float freq)
@@ -483,5 +519,4 @@
void tDattorro_setFeedbackGain (tDattorro* const r, float gain)
{
r->feedback_gain = gain;
-}
-
+}
binary files a/LEAF/Src_cpp/.DS_Store /dev/null differ
--- a/LEAF/Src_cpp/leaf-808.cpp
+++ /dev/null
@@ -1,418 +1,0 @@
-/*
- ==============================================================================
-
- leaf_808.cpp
- Created: 30 Nov 2018 10:24:21am
- Author: airship
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-808.h"
-
-#else
-
-#include "../Inc/leaf-808.h"
-
-#endif
-
-#define USE_STICK 0
-void t808Cowbell_on(t808Cowbell* const cowbell, float vel)
-{
-
- tEnvelope_on(&cowbell->envGain, vel);
-
-#if USE_STICK
- tEnvelope_on(&cowbell->envStick,vel);
-#endif
-
-}
-
-float t808Cowbell_tick(t808Cowbell* const cowbell) {
-
- float sample = 0.0f;
-
- // Mix oscillators.
- sample = (cowbell->oscMix * tSquare_tick(&cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(&cowbell->p[1]));
-
- // Filter dive and filter.
- tSVF_setFreq(&cowbell->bandpassOsc, cowbell->filterCutoff + 1000.0f * tEnvelope_tick(&cowbell->envFilter));
- sample = tSVF_tick(&cowbell->bandpassOsc,sample);
-
- sample *= (0.9f * tEnvelope_tick(&cowbell->envGain));
-
-#if USE_STICK
- sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick)));
-#endif
-
- sample = tHighpass_tick(&cowbell->highpass, sample);
-
- return sample;
-}
-
-void t808Cowbell_setDecay(t808Cowbell* const cowbell, float decay)
-{
- tEnvelope_setDecay(&cowbell->envGain,decay);
-}
-
-void t808Cowbell_setHighpassFreq(t808Cowbell *cowbell, float freq)
-{
- tHighpass_setFreq(&cowbell->highpass,freq);
-}
-
-void t808Cowbell_setBandpassFreq(t808Cowbell* const cowbell, float freq)
-{
- cowbell->filterCutoff = freq;
-}
-
-void t808Cowbell_setFreq(t808Cowbell* const cowbell, float freq)
-{
-
- tSquare_setFreq(&cowbell->p[0],freq);
- tSquare_setFreq(&cowbell->p[1],1.48148f*freq);
-}
-
-void t808Cowbell_setOscMix(t808Cowbell* const cowbell, float oscMix)
-{
- cowbell->oscMix = oscMix;
-}
-
-void t808Cowbell_init(t808Cowbell* const cowbell) {
-
- tSquare_init(&cowbell->p[0]);
- tSquare_setFreq(&cowbell->p[0], 540.0f);
-
- tSquare_init(&cowbell->p[1]);
- tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
-
- cowbell->oscMix = 0.5f;
-
- tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f);
-
- tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f);
-
- tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE);
-
- tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE);
-
- tHighpass_init(&cowbell->highpass, 1000.0f);
-
-#if USE_STICK
- tNoise_init(&cowbell->stick, NoiseTypeWhite);
- tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0);
-#endif
-}
-
-void t808Hihat_on(t808Hihat* const hihat, float vel) {
-
- tEnvelope_on(&hihat->envGain, vel);
- tEnvelope_on(&hihat->envStick, vel);
-
-}
-
-void t808Hihat_setOscNoiseMix(t808Hihat* const hihat, float oscNoiseMix) {
-
- hihat->oscNoiseMix = oscNoiseMix;
-
-}
-
-float t808Hihat_tick(t808Hihat* const hihat) {
-
- float sample = 0.0f;
- float gainScale = 0.1666f;
-
-
- float myNoise = tNoise_tick(&hihat->n);
-
- tSquare_setFreq(&hihat->p[0], ((2.0f + hihat->stretch) * hihat->freq));
- tSquare_setFreq(&hihat->p[1], ((3.00f + hihat->stretch) * hihat->freq));
- tSquare_setFreq(&hihat->p[2], ((4.16f + hihat->stretch) * hihat->freq));
- tSquare_setFreq(&hihat->p[3], ((5.43f + hihat->stretch) * hihat->freq));
- tSquare_setFreq(&hihat->p[4], ((6.79f + hihat->stretch) * hihat->freq));
- tSquare_setFreq(&hihat->p[5], ((8.21f + hihat->stretch) * hihat->freq));
-
- for (int i = 0; i < 6; i++)
- {
- sample += tSquare_tick(&hihat->p[i]);
- }
-
- sample *= gainScale;
-
- sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * myNoise);
-
- sample = tSVF_tick(&hihat->bandpassOsc, sample);
-
- float myGain = tEnvelope_tick(&hihat->envGain);
- sample *= (myGain*myGain);//square the output gain envelope
- sample = tHighpass_tick(&hihat->highpass, sample);
- sample += ((0.5f * tEnvelope_tick(&hihat->envStick)) * tSVF_tick(&hihat->bandpassStick, tNoise_tick(&hihat->stick)));
- sample = tanhf(sample * 2.0f);
-
- return sample;
-}
-
-void t808Hihat_setDecay(t808Hihat* const hihat, float decay)
-{
- tEnvelope_setDecay(&hihat->envGain,decay);
- tEnvelope_setDecay(&hihat->noiseFMGain,decay);
-}
-
-void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq)
-{
- tHighpass_setFreq(&hihat->highpass,freq);
-}
-
-void t808Hihat_setStretch(t808Hihat* const hihat, float stretch)
-{
- hihat->stretch = stretch;
-}
-
-void t808Hihat_setFM(t808Hihat* const hihat, float FM_amount)
-{
- hihat->FM_amount = FM_amount;
-}
-
-void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, float freq)
-{
- tSVF_setFreq(&hihat->bandpassOsc,freq);
-}
-
-void t808Hihat_setOscBandpassQ(t808Hihat* const hihat, float Q)
-{
- tSVF_setQ(&hihat->bandpassOsc,Q);
-}
-
-void t808Hihat_setStickBandPassFreq(t808Hihat* const hihat, float freq)
-{
- tSVF_setFreq(&hihat->bandpassStick,freq);
-}
-
-
-void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq)
-{
- hihat->freq = freq;
-}
-
-void t808Hihat_init(t808Hihat* const hihat)
-{
- for (int i = 0; i < 6; i++)
- {
- tSquare_init(&hihat->p[i]);
- }
-
- tNoise_init(&hihat->stick, WhiteNoise);
- tNoise_init(&hihat->n, WhiteNoise);
-
- // need to fix SVF to be generic
- tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0,1.5f);
- tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500,0.5f);
-
- tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
- tEnvelope_init(&hihat->noiseFMGain, 0.0f, 500.0f, OFALSE);
- tEnvelope_init(&hihat->envStick, 0.0f, 4.0f, OFALSE);
-
- tHighpass_init(&hihat->highpass, 7000.0f);
-
- hihat->freq = 40.0f;
- hihat->stretch = 0.0f;
- hihat->FM_amount = 1000.0f;
-
- tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
- tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
- tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
- tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
- tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
- tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
-}
-
-void t808Snare_on(t808Snare* const snare, float vel)
-{
- for (int i = 0; i < 2; i++)
- {
- tEnvelope_on(&snare->toneEnvOsc[i], vel);
- tEnvelope_on(&snare->toneEnvGain[i], vel);
- tEnvelope_on(&snare->toneEnvFilter[i], vel);
- }
-
- tEnvelope_on(&snare->noiseEnvGain, vel);
- tEnvelope_on(&snare->noiseEnvFilter, vel);
-}
-
-void t808Snare_setTone1Freq(t808Snare* const snare, float freq)
-{
- snare->tone1Freq = freq;
- tTriangle_setFreq(&snare->tone[0], freq);
-
-}
-
-void t808Snare_setTone2Freq(t808Snare* const snare, float freq)
-{
- snare->tone2Freq = freq;
- tTriangle_setFreq(&snare->tone[1],freq);
-}
-
-void t808Snare_setTone1Decay(t808Snare* const snare, float decay)
-{
- tEnvelope_setDecay(&snare->toneEnvGain[0],decay);
-}
-
-void t808Snare_setTone2Decay(t808Snare* const snare, float decay)
-{
- tEnvelope_setDecay(&snare->toneEnvGain[1],decay);
-}
-
-void t808Snare_setNoiseDecay(t808Snare* const snare, float decay)
-{
- tEnvelope_setDecay(&snare->noiseEnvGain,decay);
-}
-
-void t808Snare_setToneNoiseMix(t808Snare* const snare, float toneNoiseMix)
-{
- snare->toneNoiseMix = toneNoiseMix;
-}
-
-void t808Snare_setNoiseFilterFreq(t808Snare* const snare, float noiseFilterFreq)
-{
- snare->noiseFilterFreq = noiseFilterFreq;
-}
-
-void t808Snare_setNoiseFilterQ(t808Snare* const snare, float noiseFilterQ)
-{
- tSVF_setQ(&snare->noiseLowpass, noiseFilterQ);
-}
-
-
-static float tone[2];
-
-float t808Snare_tick(t808Snare* const snare)
-{
- for (int i = 0; i < 2; i++)
- {
- tTriangle_setFreq(&snare->tone[i], snare->tone1Freq + (20.0f * tEnvelope_tick(&snare->toneEnvOsc[i])));
- tone[i] = tTriangle_tick(&snare->tone[i]);
-
- tSVF_setFreq(&snare->toneLowpass[i], 2000.0f + (500.0f * tEnvelope_tick(&snare->toneEnvFilter[i])));
- tone[i] = tSVF_tick(&snare->toneLowpass[i], tone[i]) * tEnvelope_tick(&snare->toneEnvGain[i]);
- }
-
- float noise = tNoise_tick(&snare->noiseOsc);
- tSVF_setFreq(&snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tEnvelope_tick(&snare->noiseEnvFilter)));
- noise = tSVF_tick(&snare->noiseLowpass, noise) * tEnvelope_tick(&snare->noiseEnvGain);
-
- float sample = (snare->toneNoiseMix)*(tone[0] * snare->toneGain[0] + tone[1] * snare->toneGain[1]) + (1.0f-snare->toneNoiseMix) * (noise * snare->noiseGain);
- sample = tanhf(sample * 2.0f);
- return sample;
-}
-
-void t808Snare_init(t808Snare* const snare)
-{
- float ratio[2] = {1.0, 1.5};
- for (int i = 0; i < 2; i++)
- {
- tTriangle_init(&snare->tone[i]);
-
- tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f);
- tSVF_init(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f);
- tEnvelope_init(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE);
- tEnvelope_init(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE);
- tEnvelope_init(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE);
-
- snare->toneGain[i] = 0.5f;
- }
-
- snare->tone1Freq = ratio[0] * 100.0f;
- snare->tone2Freq = ratio[1] * 100.0f;
- snare->noiseFilterFreq = 3000.0f;
- tNoise_init(&snare->noiseOsc, WhiteNoise);
- tSVF_init(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f);
- tEnvelope_init(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE);
- tEnvelope_init(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE);
- snare->noiseGain = 1.0f;
-}
-
-void t808Snare_free (t808Snare* const snare)
-{
- for (int i = 0; i < 2; i++)
- {
- tTriangle_free(&snare->tone[i]);
- tSVF_free(&snare->toneLowpass[i]);
- tEnvelope_free(&snare->toneEnvOsc[i]);
- tEnvelope_free(&snare->toneEnvGain[i]);
- tEnvelope_free(&snare->toneEnvFilter[i]);
- }
-
-
- tNoise_free(&snare->noiseOsc);
- tSVF_free(&snare->noiseLowpass);
- tEnvelope_free(&snare->noiseEnvGain);
- tEnvelope_free(&snare->noiseEnvFilter);
-}
-
-
-void t808Kick_init (t808Kick* const kick)
-{
- tCycle_init(&kick->tone);
- kick->toneInitialFreq = 40.0f;
- kick->sighAmountInHz = 7.0f;
- kick->chirpRatioMinusOne = 3.3f;
- tCycle_setFreq(&kick->tone, 50.0f);
- tSVF_init(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f);
- tEnvelope_init(&kick->toneEnvOscChirp, 0.0f, 20.0f, OFALSE);
- tEnvelope_init(&kick->toneEnvOscSigh, 0.0f, 2500.0f, OFALSE);
- tEnvelope_init(&kick->toneEnvGain, 0.0f, 800.0f, OFALSE);
- tNoise_init(&kick->noiseOsc, PinkNoise);
- tEnvelope_init(&kick->noiseEnvGain, 0.0f, 1.0f, OFALSE);
- kick->noiseGain = 0.3f;
-}
-
-
-void t808Kick_free (t808Kick* const kick)
-{
- tCycle_free(&kick->tone);
- tSVF_free(&kick->toneLowpass);
- tEnvelope_free(&kick->toneEnvOscChirp);
- tEnvelope_free(&kick->toneEnvOscSigh);
- tEnvelope_free(&kick->toneEnvGain);
- tNoise_free(&kick->noiseOsc);
- tEnvelope_free(&kick->noiseEnvGain);
-}
-
-float t808Kick_tick (t808Kick* const kick)
-{
- tCycle_setFreq(&kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tEnvelope_tick(&kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tEnvelope_tick(&kick->toneEnvOscSigh)));
- float sample = tCycle_tick(&kick->tone) * tEnvelope_tick(&kick->toneEnvGain);
- sample+= tNoise_tick(&kick->noiseOsc) * tEnvelope_tick(&kick->noiseEnvGain);
- //add distortion here
- sample = tSVF_tick(&kick->toneLowpass, sample);
- return sample;
-}
-
-void t808Kick_on (t808Kick* const kick, float vel)
-{
- tEnvelope_on(&kick->toneEnvOscChirp, vel);
- tEnvelope_on(&kick->toneEnvOscSigh, vel);
- tEnvelope_on(&kick->toneEnvGain, vel);
- tEnvelope_on(&kick->noiseEnvGain, vel);
-
-}
-void t808Kick_setToneFreq (t808Kick* const kick, float freq)
-{
- kick->toneInitialFreq = freq;
-
-}
-
-void t808Kick_setToneDecay (t808Kick* const kick, float decay)
-{
- tEnvelope_setDecay(&kick->toneEnvGain,decay);
- tEnvelope_setDecay(&kick->toneEnvGain,decay * 3.0f);
-}
-void t808Kick_setNoiseDecay (t808Kick* const kick, float decay);
-void t808Kick_setSighAmount (t808Kick* const kick, float sigh);
-void t808Kick_setChirpAmount (t808Kick* const kick, float chirp);
-void t808Kick_setToneNoiseMix (t808Kick* const kick, float toneNoiseMix);
-void t808Kick_setNoiseFilterFreq (t808Kick* const kick, float noiseFilterFreq);
-void t808Kick_setNoiseFilterQ (t808Kick* const kick, float noiseFilterQ);
-
-
--- a/LEAF/Src_cpp/leaf-delay.cpp
+++ /dev/null
@@ -1,417 +1,0 @@
-/*
- ==============================================================================
-
- LEAFDelay.c
- Created: 20 Jan 2017 12:01:24pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-delay.h"
-#include "..\leaf.h"
-
-#else
-
-#include "../Inc/leaf-delay.h"
-#include "../leaf.h"
-
-#endif
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Delay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tDelay_init (tDelay* const d, uint32_t delay, uint32_t maxDelay)
-{
- d->maxDelay = maxDelay;
-
- d->delay = delay;
-
- d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-
- d->inPoint = 0;
- d->outPoint = 0;
-
- d->lastIn = 0.0f;
- d->lastOut = 0.0f;
-
- d->gain = 1.0f;
-
- tDelay_setDelay(d, d->delay);
-}
-
-void tDelay_free(tDelay* const d)
-{
- leaf_free(d->buff);
- leaf_free(d);
-}
-
-float tDelay_tick (tDelay* const d, float input)
-{
- // Input
- d->lastIn = input;
- d->buff[d->inPoint] = input * d->gain;
- if (++(d->inPoint) == d->maxDelay) d->inPoint = 0;
-
- // Output
- d->lastOut = d->buff[d->outPoint];
- if (++(d->outPoint) == d->maxDelay) d->outPoint = 0;
-
- return d->lastOut;
-}
-
-
-int tDelay_setDelay (tDelay* const d, uint32_t delay)
-{
- if (delay >= d->maxDelay) d->delay = d->maxDelay;
- else d->delay = delay;
-
- // read chases write
- if ( d->inPoint >= delay ) d->outPoint = d->inPoint - d->delay;
- else d->outPoint = d->maxDelay + d->inPoint - d->delay;
-
- return 0;
-}
-
-float tDelay_tapOut (tDelay* const d, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- return d->buff[tap];
-
-}
-
-void tDelay_tapIn (tDelay* const d, float value, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- d->buff[tap] = value;
-}
-
-float tDelay_addTo (tDelay* const d, float value, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- return (d->buff[tap] += value);
-}
-
-uint32_t tDelay_getDelay (tDelay* const d)
-{
- return d->delay;
-}
-
-float tDelay_getLastOut (tDelay* const d)
-{
- return d->lastOut;
-}
-
-float tDelay_getLastIn (tDelay* const d)
-{
- return d->lastIn;
-}
-
-void tDelay_setGain (tDelay* const d, float gain)
-{
- if (gain < 0.0f) d->gain = 0.0f;
- else d->gain = gain;
-}
-
-float tDelay_getGain (tDelay* const d)
-{
- return d->gain;
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ DelayL ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tDelayL_init (tDelayL* const d, float delay, uint32_t maxDelay)
-{
- d->maxDelay = maxDelay;
-
- if (delay > maxDelay) d->delay = maxDelay;
- else if (delay < 0.0f) d->delay = 0.0f;
- else d->delay = delay;
-
- d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-
- d->gain = 1.0f;
-
- d->lastIn = 0.0f;
- d->lastOut = 0.0f;
-
- d->inPoint = 0;
- d->outPoint = 0;
-
- tDelayL_setDelay(d, d->delay);
-}
-
-void tDelayL_free(tDelayL* const d)
-{
- leaf_free(d->buff);
- leaf_free(d);
-}
-
-float tDelayL_tick (tDelayL* const d, float input)
-{
- d->buff[d->inPoint] = input * d->gain;
-
- // Increment input pointer modulo length.
- if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0;
-
-
- // First 1/2 of interpolation
- d->lastOut = d->buff[d->outPoint] * d->omAlpha;
-
- // Second 1/2 of interpolation
- if (d->outPoint + 1 < d->maxDelay)
- d->lastOut += d->buff[d->outPoint+1] * d->alpha;
- else
- d->lastOut += d->buff[0] * d->alpha;
-
- // Increment output pointer modulo length.
- if ( ++(d->outPoint) == d->maxDelay ) d->outPoint = 0;
-
- return d->lastOut;
-}
-
-int tDelayL_setDelay (tDelayL* const d, float delay)
-{
- if (delay < 0.0f) d->delay = 0.0f;
- else if (delay <= d->maxDelay) d->delay = delay;
- else d->delay = d->maxDelay;
-
- float outPointer = d->inPoint - d->delay;
-
- while ( outPointer < 0 )
- outPointer += d->maxDelay; // modulo maximum length
-
- d->outPoint = (uint32_t) outPointer; // integer part
-
- d->alpha = outPointer - d->outPoint; // fractional part
- d->omAlpha = 1.0f - d->alpha;
-
- if ( d->outPoint == d->maxDelay ) d->outPoint = 0;
-
- return 0;
-}
-
-float tDelayL_tapOut (tDelayL* const d, float tapDelay)
-{
- float tap = (float) d->inPoint - tapDelay - 1.f;
-
- // Check for wraparound.
- while ( tap < 0.f ) tap += (float)d->maxDelay;
-
- float alpha = tap - (int)tap;
- float omAlpha = 1.f - alpha;
-
- int ptx = (int) tap;
-
- // First 1/2 of interpolation
- float samp = d->buff[ptx] * omAlpha;
-
- // Second 1/2 of interpolation
- if ((ptx + 1) < d->maxDelay)
- samp += d->buff[ptx+1] * d->alpha;
- else
- samp += d->buff[0] * d->alpha;
-
- return samp;
-
-}
-
-void tDelayL_tapIn (tDelayL* const d, float value, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- d->buff[tap] = value;
-}
-
-float tDelayL_addTo (tDelayL* const d, float value, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- return (d->buff[tap] += value);
-}
-
-float tDelayL_getDelay (tDelayL *d)
-{
- return d->delay;
-}
-
-float tDelayL_getLastOut (tDelayL* const d)
-{
- return d->lastOut;
-}
-
-float tDelayL_getLastIn (tDelayL* const d)
-{
- return d->lastIn;
-}
-
-void tDelayL_setGain (tDelayL* const d, float gain)
-{
- if (gain < 0.0f) d->gain = 0.0f;
- else d->gain = gain;
-}
-
-float tDelayL_getGain (tDelayL* const d)
-{
- return d->gain;
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ DelayA ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tDelayA_init (tDelayA* const d, float delay, uint32_t maxDelay)
-{
- d->maxDelay = maxDelay;
-
- if (delay > maxDelay) d->delay = maxDelay;
- else if (delay < 0.0f) d->delay = 0.0f;
- else d->delay = delay;
-
- d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-
- d->gain = 1.0f;
-
- d->lastIn = 0.0f;
- d->lastOut = 0.0f;
-
- d->inPoint = 0;
- d->outPoint = 0;
-
- tDelayA_setDelay(d, d->delay);
-
- d->apInput = 0.0f;
-}
-
-void tDelayA_free(tDelayA* const d)
-{
- leaf_free(d->buff);
- leaf_free(d);
-}
-
-float tDelayA_tick (tDelayA* const d, float input)
-{
- d->buff[d->inPoint] = input * d->gain;
-
- // Increment input pointer modulo length.
- if ( ++(d->inPoint) >= d->maxDelay ) d->inPoint = 0;
-
- // Do allpass interpolation delay.
- float out = d->lastOut * -d->coeff;
- out += d->apInput + ( d->coeff * d->buff[d->outPoint] );
- d->lastOut = out;
-
- // Save allpass input
- d->apInput = d->buff[d->outPoint];
-
- // Increment output pointer modulo length.
- if (++(d->outPoint) >= d->maxDelay ) d->outPoint = 0;
-
- return d->lastOut;
-}
-
-int tDelayA_setDelay (tDelayA* const d, float delay)
-{
- if (delay < 0.5f) d->delay = 0.5f;
- else if (delay <= d->maxDelay) d->delay = delay;
- else d->delay = d->maxDelay;
-
- // outPoint chases inPoint
- float outPointer = (float)d->inPoint - d->delay + 1.0f;
-
- while ( outPointer < 0 ) outPointer += d->maxDelay; // mod max length
-
- d->outPoint = (uint32_t) outPointer; // integer part
-
- if ( d->outPoint >= d->maxDelay ) d->outPoint = 0;
-
- d->alpha = 1.0f + (float)d->outPoint - outPointer; // fractional part
-
- if ( d->alpha < 0.5f )
- {
- // The optimal range for alpha is about 0.5 - 1.5 in order to
- // achieve the flattest phase delay response.
-
- d->outPoint += 1;
-
- if ( d->outPoint >= d->maxDelay ) d->outPoint -= d->maxDelay;
-
- d->alpha += 1.0f;
- }
-
- d->coeff = (1.0f - d->alpha) / (1.0f + d->alpha); // coefficient for allpass
-
- return 0;
-}
-
-float tDelayA_tapOut (tDelayA* const d, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- return d->buff[tap];
-
-}
-
-void tDelayA_tapIn (tDelayA* const d, float value, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- d->buff[tap] = value;
-}
-
-float tDelayA_addTo (tDelayA* const d, float value, uint32_t tapDelay)
-{
- int32_t tap = d->inPoint - tapDelay - 1;
-
- // Check for wraparound.
- while ( tap < 0 ) tap += d->maxDelay;
-
- return (d->buff[tap] += value);
-}
-
-float tDelayA_getDelay (tDelayA* const d)
-{
- return d->delay;
-}
-
-float tDelayA_getLastOut (tDelayA* const d)
-{
- return d->lastOut;
-}
-
-float tDelayA_getLastIn (tDelayA* const d)
-{
- return d->lastIn;
-}
-
-void tDelayA_setGain (tDelayA* const d, float gain)
-{
- if (gain < 0.0f) d->gain = 0.0f;
- else d->gain = gain;
-}
-
-float tDelayA_getGain (tDelayA* const d)
-{
- return d->gain;
-}
-
--- a/LEAF/Src_cpp/leaf-filter.cpp
+++ /dev/null
@@ -1,823 +1,0 @@
-/*
- ==============================================================================
-
- LEAFFilter.c
- Created: 20 Jan 2017 12:01:10pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-filter.h"
-#include "..\Inc\leaf-wavetables.h"
-#include "..\leaf.h"
-
-#else
-
-#include "../Inc/leaf-filter.h"
-#include "../Inc/leaf-wavetables.h"
-#include "../leaf.h"
-
-#endif
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OnePole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tAllpass_init(tAllpass* const f, float initDelay, uint32_t maxDelay)
-{
- f->gain = 0.7f;
-
- f->lastOut = 0.0f;
-
- tDelayL_init(&f->delay, initDelay, maxDelay);
-}
-
-void tAllpass_setDelay(tAllpass* const f, float delay)
-{
- tDelayL_setDelay(&f->delay, delay);
-}
-
-void tAllpass_free(tAllpass* const f)
-{
- leaf_free(&f->delay);
- leaf_free(f);
-}
-
-void tAllpass_setGain(tAllpass* const f, float gain)
-{
- f->gain = gain;
-}
-
-float tAllpass_tick(tAllpass* const f, float input)
-{
- float s1 = (-f->gain) * f->lastOut + input;
-
- float s2 = tDelayL_tick(&f->delay, s1) + (f->gain) * input;
-
- f->lastOut = s2;
-
- return f->lastOut;
-}
-
-void tButterworth_init(tButterworth* const f, int N, float f1, float f2)
-{
- f->f1 = f1;
- f->f2 = f2;
- f->gain = 1.0f;
-
- f->N = N;
-
- if (f->N > NUM_SVF_BW) f->N = NUM_SVF_BW;
-
- for(int i = 0; i < N/2; ++i)
- {
- tSVF_init(&f->low[i], SVFTypeHighpass, f1, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*N)));
- tSVF_init(&f->high[i], SVFTypeLowpass, f2, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*N)));
- }
-}
-
-void tButterworth_free(tButterworth* const f)
-{
- for(int i = 0; i < f->N/2; ++i)
- {
- tSVF_free(&f->low[i]);
- tSVF_free(&f->high[i]);
- }
-
- leaf_free(f);
-}
-
-float tButterworth_tick(tButterworth* const f, float samp)
-{
- for(int i = 0; i < ((f->N)/2); ++i)
- {
- samp = tSVF_tick(&f->low[i],samp);
- samp = tSVF_tick(&f->high[i],samp);
- }
- return samp;
-}
-
-void tButterworth_setF1(tButterworth* const f, float f1)
-{
- f->f1 = f1;
- for(int i = 0; i < ((f->N)/2); ++i) tSVF_setFreq(&f->low[i], f1);
-}
-
-void tButterworth_setF2(tButterworth* const f, float f2)
-{
- f->f2 = f2;
- for(int i = 0; i < ((f->N)/2); ++i) tSVF_setFreq(&f->high[i], f2);
-}
-
-void tButterworth_setFreqs(tButterworth* const f, float f1, float f2)
-{
- f->f1 = f1;
- f->f2 = f2;
- for(int i = 0; i < ((f->N)/2); ++i)
- {
- tSVF_setFreq(&f->low[i], f1);
- tSVF_setFreq(&f->high[i], f2);
- }
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OneZero Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tOneZero_init(tOneZero* const f, float theZero)
-{
- f->gain = 1.0f;
- f->lastIn = 0.0f;
- f->lastOut = 0.0f;
- tOneZero_setZero(f, theZero);
-}
-
-void tOneZero_free(tOneZero* const f)
-{
- leaf_free(f);
-}
-
-float tOneZero_tick(tOneZero* const f, float input)
-{
- float in = input * f->gain;
- float out = f->b1 * f->lastIn + f->b0 * in;
-
- f->lastIn = in;
-
- return out;
-}
-
-void tOneZero_setZero(tOneZero* const f, float theZero)
-{
- if (theZero > 0.0f) f->b0 = 1.0f / (1.0f + theZero);
- else f->b0 = 1.0f / (1.0f - theZero);
-
- f->b1 = -theZero * f->b0;
-
-}
-
-void tOneZero_setB0(tOneZero* const f, float b0)
-{
- f->b0 = b0;
-}
-
-void tOneZero_setB1(tOneZero* const f, float b1)
-{
- f->b1 = b1;
-}
-
-void tOneZero_setCoefficients(tOneZero* const f, float b0, float b1)
-{
- f->b0 = b0;
- f->b1 = b1;
-}
-
-void tOneZero_setGain(tOneZero *f, float gain)
-{
- f->gain = gain;
-}
-
-float tOneZero_getPhaseDelay(tOneZero* const f, float frequency )
-{
- if ( frequency <= 0.0f) frequency = 0.05f;
-
- f->frequency = frequency;
-
- float omegaT = 2 * PI * frequency * leaf.invSampleRate;
- float real = 0.0, imag = 0.0;
-
- real += f->b0;
-
- real += f->b1 * cosf(omegaT);
- imag -= f->b1 * sinf(omegaT);
-
- real *= f->gain;
- imag *= f->gain;
-
- float phase = atan2f( imag, real );
-
- real = 0.0; imag = 0.0;
-
- phase -= atan2f( imag, real );
-
- phase = fmodf( -phase, 2 * PI );
-
- return phase / omegaT;
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TwoZero Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tTwoZero_init(tTwoZero* const f)
-{
- f->gain = 1.0f;
- f->lastIn[0] = 0.0f;
- f->lastIn[1] = 0.0f;
-}
-
-void tTwoZero_free(tTwoZero* const f)
-{
- leaf_free(f);
-}
-
-float tTwoZero_tick(tTwoZero* const f, float input)
-{
- float in = input * f->gain;
- float out = f->b2 * f->lastIn[1] + f->b1 * f->lastIn[0] + f->b0 * in;
-
- f->lastIn[1] = f->lastIn[0];
- f->lastIn[0] = in;
-
- return out;
-}
-
-void tTwoZero_setNotch(tTwoZero* const f, float freq, float radius)
-{
- // Should also deal with frequency being > half sample rate / nyquist. See STK
- if (freq < 0.0f) freq = 0.0f;
- if (radius < 0.0f) radius = 0.0f;
-
- f->frequency = freq;
- f->radius = radius;
-
- f->b2 = radius * radius;
- f->b1 = -2.0f * radius * cosf(TWO_PI * freq * leaf.invSampleRate); // OPTIMIZE with LOOKUP or APPROXIMATION
-
- // Normalize the filter gain. From STK.
- if ( f->b1 > 0.0f ) // Maximum at z = 0.
- f->b0 = 1.0f / ( 1.0f + f->b1 + f->b2 );
- else // Maximum at z = -1.
- f->b0 = 1.0f / ( 1.0f - f->b1 + f->b2 );
- f->b1 *= f->b0;
- f->b2 *= f->b0;
-
-}
-
-void tTwoZero_setB0(tTwoZero* const f, float b0)
-{
- f->b0 = b0;
-}
-
-void tTwoZero_setB1(tTwoZero* const f, float b1)
-{
- f->b1 = b1;
-}
-
-void tTwoZero_setCoefficients(tTwoZero* const f, float b0, float b1, float b2)
-{
- f->b0 = b0;
- f->b1 = b1;
- f->b2 = b2;
-}
-
-void tTwoZero_setGain(tTwoZero* const f, float gain)
-{
- f->gain = gain;
-}
-
-void tTwoZeroSampleRateChanged(tTwoZero* const f)
-{
- tTwoZero_setNotch(f, f->frequency, f->radius);
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OnePole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tOnePole_init(tOnePole* const f, float freq)
-{
- f->gain = 1.0f;
- f->a0 = 1.0;
-
- tOnePole_setFreq(f, freq);
-
- f->lastIn = 0.0f;
- f->lastOut = 0.0f;
-}
-
-void tOnePole_free(tOnePole* const f)
-{
- leaf_free(f);
-}
-
-void tOnePole_setB0(tOnePole* const f, float b0)
-{
- f->b0 = b0;
-}
-
-void tOnePole_setA1(tOnePole* const f, float a1)
-{
- if (a1 >= 1.0f) a1 = 0.999999f;
-
- f->a1 = a1;
-}
-
-void tOnePole_setPole(tOnePole* const f, float thePole)
-{
- if (thePole >= 1.0f) thePole = 0.999999f;
-
- // Normalize coefficients for peak unity gain.
- if (thePole > 0.0f) f->b0 = (1.0f - thePole);
- else f->b0 = (1.0f + thePole);
-
- f->a1 = -thePole;
-}
-
-void tOnePole_setFreq (tOnePole* const f, float freq)
-{
- f->b0 = freq * TWO_PI * leaf.invSampleRate;
-
- f->b0 = LEAF_clip(0.0f, f->b0, 1.0f);
-
- f->a1 = 1.0f - f->b0;
-}
-
-void tOnePole_setCoefficients(tOnePole* const f, float b0, float a1)
-{
- if (a1 >= 1.0f) a1 = 0.999999f;
-
- f->b0 = b0;
- f->a1 = a1;
-}
-
-void tOnePole_setGain(tOnePole* const f, float gain)
-{
- f->gain = gain;
-}
-
-float tOnePole_tick(tOnePole* const f, float input)
-{
- float in = input * f->gain;
- float out = (f->b0 * in) + (f->a1 * f->lastOut);
-
- f->lastIn = in;
- f->lastOut = out;
-
- return out;
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TwoPole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tTwoPole_init(tTwoPole* const f)
-{
- f->gain = 1.0f;
- f->a0 = 1.0;
- f->b0 = 1.0;
-
- f->lastOut[0] = 0.0f;
- f->lastOut[1] = 0.0f;
-}
-
-void tTwoPole_free(tTwoPole* const f)
-{
- leaf_free(f);
-}
-
-float tTwoPole_tick(tTwoPole* const f, float input)
-{
- float in = input * f->gain;
- float out = (f->b0 * in) - (f->a1 * f->lastOut[0]) - (f->a2 * f->lastOut[1]);
-
- f->lastOut[1] = f->lastOut[0];
- f->lastOut[0] = out;
-
- return out;
-}
-
-void tTwoPole_setB0(tTwoPole* const f, float b0)
-{
- f->b0 = b0;
-}
-
-void tTwoPole_setA1(tTwoPole* const f, float a1)
-{
- f->a1 = a1;
-}
-
-void tTwoPole_setA2(tTwoPole* const f, float a2)
-{
- f->a2 = a2;
-}
-
-
-void tTwoPole_setResonance(tTwoPole* const f, float frequency, float radius, oBool normalize)
-{
- if (frequency < 0.0f) frequency = 0.0f; // need to also handle when frequency > nyquist
- if (radius < 0.0f) radius = 0.0f;
- if (radius >= 1.0f) radius = 0.999999f;
-
- f->radius = radius;
- f->frequency = frequency;
- f->normalize = normalize;
-
- f->a2 = radius * radius;
- f->a1 = -2.0f * radius * cos(TWO_PI * frequency * leaf.invSampleRate);
-
- if ( normalize )
- {
- // Normalize the filter gain ... not terribly efficient.
- float real = 1 - radius + (f->a2 - radius) * cos(TWO_PI * 2 * frequency * leaf.invSampleRate);
- float imag = (f->a2 - radius) * sin(TWO_PI * 2 * frequency * leaf.invSampleRate);
- f->b0 = sqrt( pow(real, 2) + pow(imag, 2) );
- }
-}
-
-void tTwoPole_setCoefficients(tTwoPole* const f, float b0, float a1, float a2)
-{
- f->b0 = b0;
- f->a1 = a1;
- f->a2 = a2;
-}
-
-void tTwoPole_setGain(tTwoPole* const f, float gain)
-{
- f->gain = gain;
-}
-
-void tTwoPoleSampleRateChanged (tTwoPole* const f)
-{
- f->a2 = f->radius * f->radius;
- f->a1 = -2.0f * f->radius * cos(TWO_PI * f->frequency * leaf.invSampleRate);
-
- if ( f->normalize )
- {
- // Normalize the filter gain ... not terribly efficient.
- float real = 1 - f->radius + (f->a2 - f->radius) * cos(TWO_PI * 2 * f->frequency * leaf.invSampleRate);
- float imag = (f->a2 - f->radius) * sin(TWO_PI * 2 * f->frequency * leaf.invSampleRate);
- f->b0 = sqrt( pow(real, 2) + pow(imag, 2) );
- }
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ PoleZero Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tPoleZero_init(tPoleZero* const f)
-{
- f->gain = 1.0f;
- f->b0 = 1.0;
- f->a0 = 1.0;
-
- f->lastIn = 0.0f;
- f->lastOut = 0.0f;
-}
-
-void tPoleZero_free(tPoleZero* const f)
-{
- leaf_free(f);
-}
-
-void tPoleZero_setB0(tPoleZero* const pzf, float b0)
-{
- pzf->b0 = b0;
-}
-
-void tPoleZero_setB1(tPoleZero* const pzf, float b1)
-{
- pzf->b1 = b1;
-}
-
-void tPoleZero_setA1(tPoleZero* const pzf, float a1)
-{
- if (a1 >= 1.0f) // a1 should be less than 1.0
- {
- a1 = 0.999999f;
- }
-
- pzf->a1 = a1;
-}
-
-void tPoleZero_setCoefficients(tPoleZero* const pzf, float b0, float b1, float a1)
-{
- if (a1 >= 1.0f) // a1 should be less than 1.0
- {
- a1 = 0.999999f;
- }
-
- pzf->b0 = b0;
- pzf->b1 = b1;
- pzf->a1 = a1;
-}
-
-void tPoleZero_setAllpass(tPoleZero* const pzf, float coeff)
-{
- if (coeff >= 1.0f) // allpass coefficient >= 1.0 makes filter unstable
- {
- coeff = 0.999999f;
- }
-
- pzf->b0 = coeff;
- pzf->b1 = 1.0f;
- pzf->a0 = 1.0f;
- pzf->a1 = coeff;
-}
-
-void tPoleZero_setBlockZero(tPoleZero* const pzf, float thePole)
-{
- if (thePole >= 1.0f) // allpass coefficient >= 1.0 makes filter unstable
- {
- thePole = 0.999999f;
- }
-
- pzf->b0 = 1.0f;
- pzf->b1 = -1.0f;
- pzf->a0 = 1.0f;
- pzf->a1 = -thePole;
-}
-
-void tPoleZero_setGain(tPoleZero* const pzf, float gain)
-{
- pzf->gain = gain;
-}
-
-float tPoleZero_tick(tPoleZero* const pzf, float input)
-{
- float in = input * pzf->gain;
- float out = (pzf->b0 * in) + (pzf->b1 * pzf->lastIn) - (pzf->a1 * pzf->lastOut);
-
- pzf->lastIn = in;
- pzf->lastOut = out;
-
- return out;
-}
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ BiQuad Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tBiQuad_init(tBiQuad* const f)
-{
- f->gain = 1.0f;
-
- f->b0 = 0.0f;
- f->a0 = 0.0f;
-
- f->lastIn[0] = 0.0f;
- f->lastIn[1] = 0.0f;
- f->lastOut[0] = 0.0f;
- f->lastOut[1] = 0.0f;
-}
-
-void tBiQuad_free(tBiQuad* const f)
-{
- leaf_free(f);
-}
-
-float tBiQuad_tick(tBiQuad* const f, float input)
-{
- float in = input * f->gain;
- float out = f->b0 * in + f->b1 * f->lastIn[0] + f->b2 * f->lastIn[1];
- out -= f->a2 * f->lastOut[1] + f->a1 * f->lastOut[0];
-
- f->lastIn[1] = f->lastIn[0];
- f->lastIn[0] = in;
-
- f->lastOut[1] = f->lastOut[0];
- f->lastOut[0] = out;
-
- return out;
-}
-
-void tBiQuad_setResonance(tBiQuad* const f, float freq, float radius, oBool normalize)
-{
- // Should also deal with frequency being > half sample rate / nyquist. See STK
- if (freq < 0.0f) freq = 0.0f;
- if (radius < 0.0f) radius = 0.0f;
- if (radius >= 1.0f) radius = 1.0f;
-
- f->frequency = freq;
- f->radius = radius;
- f->normalize = normalize;
-
- f->a2 = radius * radius;
- f->a1 = -2.0f * radius * cosf(TWO_PI * freq * leaf.invSampleRate);
-
- if (normalize)
- {
- f->b0 = 0.5f - 0.5f * f->a2;
- f->b1 = 0.0f;
- f->b2 = -f->b0;
- }
-}
-
-void tBiQuad_setNotch(tBiQuad* const f, float freq, float radius)
-{
- // Should also deal with frequency being > half sample rate / nyquist. See STK
- if (freq < 0.0f) freq = 0.0f;
- if (radius < 0.0f) radius = 0.0f;
-
- f->b2 = radius * radius;
- f->b1 = -2.0f * radius * cosf(TWO_PI * freq * leaf.invSampleRate); // OPTIMIZE with LOOKUP or APPROXIMATION
-
- // Does not attempt to normalize filter gain.
-}
-
-void tBiQuad_setEqualGainZeros(tBiQuad* const f)
-{
- f->b0 = 1.0f;
- f->b1 = 0.0f;
- f->b2 = -1.0f;
-}
-
-void tBiQuad_setB0(tBiQuad* const f, float b0)
-{
- f->b0 = b0;
-}
-
-void tBiQuad_setB1(tBiQuad* const f, float b1)
-{
- f->b1 = b1;
-}
-
-void tBiQuad_setB2(tBiQuad* const f, float b2)
-{
- f->b2 = b2;
-}
-
-void tBiQuad_setA1(tBiQuad* const f, float a1)
-{
- f->a1 = a1;
-}
-
-void tBiQuad_setA2(tBiQuad* const f, float a2)
-{
- f->a2 = a2;
-}
-
-void tBiQuad_setCoefficients(tBiQuad* const f, float b0, float b1, float b2, float a1, float a2)
-{
- f->b0 = b0;
- f->b1 = b1;
- f->b2 = b2;
- f->a1 = a1;
- f->a2 = a2;
-}
-
-void tBiQuad_setGain(tBiQuad* const f, float gain)
-{
- f->gain = gain;
-}
-
-void tBiQuadSampleRateChanged(tBiQuad* const f)
-{
- f->a2 = f->radius * f->radius;
- f->a1 = -2.0f * f->radius * cosf(TWO_PI * f->frequency * leaf.invSampleRate);
-
- if (f->normalize)
- {
- f->b0 = 0.5f - 0.5f * f->a2;
- f->b1 = 0.0f;
- f->b2 = -f->b0;
- }
-}
-
-/* Highpass */
-void tHighpass_setFreq(tHighpass* const f, float freq)
-{
- f->frequency = freq;
- f->R = (1.0f-((freq * 2.0f * 3.14f) * leaf.invSampleRate));
-
-}
-
-float tHighpass_getFreq(tHighpass* const f)
-{
- return f->frequency;
-}
-
-// From JOS DC Blocker
-float tHighpass_tick(tHighpass* const f, float x)
-{
- f->ys = x - f->xs + f->R * f->ys;
- f->xs = x;
- return f->ys;
-}
-
-void tHighpass_init(tHighpass* const f, float freq)
-{
- f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate));
- f->ys = 0.0f;
- f->xs = 0.0f;
-
- f->frequency = freq;
-}
-
-void tHighpass_free(tHighpass* const f)
-{
- leaf_free(f);
-}
-
-void tHighpassSampleRateChanged(tHighpass* const f)
-{
- f->R = (1.0f-((f->frequency * 2.0f * 3.14f) * leaf.invSampleRate));
-}
-
-float tSVF_tick(tSVF* const svf, float v0)
-{
- float v1,v2,v3;
- v3 = v0 - svf->ic2eq;
- v1 = (svf->a1 * svf->ic1eq) + (svf->a2 * v3);
- v2 = svf->ic2eq + (svf->a2 * svf->ic1eq) + (svf->a3 * v3);
- svf->ic1eq = (2.0f * v1) - svf->ic1eq;
- svf->ic2eq = (2.0f * v2) - svf->ic2eq;
-
- if (svf->type == SVFTypeLowpass) return v2;
- else if (svf->type == SVFTypeBandpass) return v1;
- else if (svf->type == SVFTypeHighpass) return v0 - (svf->k * v1) - v2;
- else if (svf->type == SVFTypeNotch) return v0 - (svf->k * v1);
- else if (svf->type == SVFTypePeak) return v0 - (svf->k * v1) - (2.0f * v2);
- else return 0.0f;
-
-}
-
-// Less efficient, more accurate version of SVF, in which cutoff frequency is taken as floating point Hz value and tanh
-// is calculated when frequency changes.
-void tSVF_init(tSVF* const svf, SVFType type, float freq, float Q)
-{
- svf->type = type;
-
- svf->ic1eq = 0;
- svf->ic2eq = 0;
-
- float a1,a2,a3,g,k;
- g = tanf(PI * freq * leaf.invSampleRate);
- k = 1.0f/Q;
- a1 = 1.0f/(1.0f+g*(g+k));
- a2 = g*a1;
- a3 = g*a2;
-
- svf->g = g;
- svf->k = k;
- svf->a1 = a1;
- svf->a2 = a2;
- svf->a3 = a3;
-}
-
-void tSVF_free(tSVF* const svf)
-{
- leaf_free(svf);
-}
-
-int tSVF_setFreq(tSVF* const svf, float freq)
-{
- svf->g = tanf(PI * freq * leaf.invSampleRate);
- svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
- svf->a2 = svf->g * svf->a1;
- svf->a3 = svf->g * svf->a2;
-
- return 0;
-}
-
-int tSVF_setQ(tSVF* const svf, float Q)
-{
- svf->k = 1.0f/Q;
- svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
- svf->a2 = svf->g * svf->a1;
- svf->a3 = svf->g * svf->a2;
-
- return 0;
-}
-
-// Efficient version of tSVF where frequency is set based on 12-bit integer input for lookup in tanh wavetable.
-void tSVFE_init(tSVFE* const svf, SVFType type, uint16_t input, float Q)
-{
- svf->type = type;
-
- svf->ic1eq = 0;
- svf->ic2eq = 0;
-
- float a1,a2,a3,g,k;
- g = filtertan[input];
- k = 1.0f/Q;
- a1 = 1.0f/(1.0f+g*(g+k));
- a2 = g*a1;
- a3 = g*a2;
-
- svf->g = g;
- svf->k = k;
- svf->a1 = a1;
- svf->a2 = a2;
- svf->a3 = a3;
-}
-
-float tSVFE_tick(tSVFE* const svf, float v0)
-{
- float v1,v2,v3;
- v3 = v0 - svf->ic2eq;
- v1 = (svf->a1 * svf->ic1eq) + (svf->a2 * v3);
- v2 = svf->ic2eq + (svf->a2 * svf->ic1eq) + (svf->a3 * v3);
- svf->ic1eq = (2.0f * v1) - svf->ic1eq;
- svf->ic2eq = (2.0f * v2) - svf->ic2eq;
-
- if (svf->type == SVFTypeLowpass) return v2;
- else if (svf->type == SVFTypeBandpass) return v1;
- else if (svf->type == SVFTypeHighpass) return v0 - (svf->k * v1) - v2;
- else if (svf->type == SVFTypeNotch) return v0 - (svf->k * v1);
- else if (svf->type == SVFTypePeak) return v0 - (svf->k * v1) - (2.0f * v2);
- else return 0.0f;
-
-}
-
-int tSVFE_setFreq(tSVFE* const svf, uint16_t input)
-{
- svf->g = filtertan[input];
- svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
- svf->a2 = svf->g * svf->a1;
- svf->a3 = svf->g * svf->a2;
-
- return 0;
-}
-
-int tSVFE_setQ(tSVFE* const svf, float Q)
-{
- svf->k = 1.0f/Q;
- svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
- svf->a2 = svf->g * svf->a1;
- svf->a3 = svf->g * svf->a2;
-
- return 0;
-}
--- a/LEAF/Src_cpp/leaf-formant.cpp
+++ /dev/null
@@ -1,181 +1,0 @@
-/*
- ==============================================================================
-
- leaf-formant.cpp
- Created: 30 Nov 2018 11:03:30am
- Author: airship
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-formant.h"
-#else
-
-#include "../Inc/leaf-formant.h"
-
-#endif
-
-
-void tFormantShifter_init(tFormantShifter* const fs)
-{
- fs->ford = FORD;
- fs->falph = powf(0.001f, 80.0f / (leaf.sampleRate));
- fs->flamb = -(0.8517f*sqrt(atanf(0.06583f*leaf.sampleRate))-0.1916f);
- fs->fhp = 0.0f;
- fs->flp = 0.0f;
- fs->flpa = powf(0.001f, 10.0f / (leaf.sampleRate));
- fs->fmute = 1.0f;
- fs->fmutealph = powf(0.001f, 1.0f / (leaf.sampleRate));
- fs->cbi = 0;
-}
-
-void tFormantShifter_free(tFormantShifter* const fs)
-{
- leaf_free(fs);
-}
-
-
-float tFormantShifter_tick(tFormantShifter* fs, float in, float fwarp)
-{
- return tFormantShifter_add(fs, tFormantShifter_remove(fs, in), fwarp);
-}
-
-float tFormantShifter_remove(tFormantShifter* fs, float in)
-{
- float fa, fb, fc, foma, falph, ford, flpa, flamb, tf, fk, tf2, f0resp, f1resp, frlamb;
- int outindex = 0;
- int ti4;
- ford = fs->ford;
- falph = fs->falph;
- foma = (1.0f - falph);
- flpa = fs->flpa;
- flamb = fs->flamb;
-
- tf = in;
- ti4 = fs->cbi;
-
- fa = tf - fs->fhp;
- fs->fhp = tf;
- fb = fa;
- for(int i = 0; i < ford; i++)
- {
- fs->fsig[i] = fa*fa*foma + fs->fsig[i]*falph;
- fc = (fb - fs->fc[i])*flamb + fs->fb[i];
- fs->fc[i] = fc;
- fs->fb[i] = fb;
- fk = fa*fc*foma + fs->fk[i]*falph;
- fs->fk[i] = fk;
- tf = fk/(fs->fsig[i] + 0.000001f);
- tf = tf*foma + fs->fsmooth[i]*falph;
- fs->fsmooth[i] = tf;
- fs->fbuff[i][ti4] = tf;
- fb = fc - tf*fa;
- fa = fa - tf*fc;
- }
- fs->cbi++;
- if(fs->cbi >= FORMANT_BUFFER_SIZE)
- {
- fs->cbi = 0;
- }
-
- return fa;
-}
-
-float tFormantShifter_add(tFormantShifter* fs, float in, float fwarp)
-{
- float fa, fb, fc, foma, falph, ford, flpa, flamb, tf, fk, tf2, f0resp, f1resp, frlamb;
- int outindex = 0;
- int ti4;
- ford = fs->ford;
- falph = fs->falph;
- foma = (1.0f - falph);
- flpa = fs->flpa;
- flamb = fs->flamb;
- tf = exp2(fwarp/2.0f) * (1+flamb)/(1-flamb);
- frlamb = (tf-1)/(tf+1);
- ti4 = fs->cbi;
-
- tf2 = in;
- fa = 0;
- fb = fa;
- for (int i=0; i<ford; i++)
- {
- fc = (fb-fs->frc[i])*frlamb + fs->frb[i];
- tf = fs->fbuff[i][ti4];
- fb = fc - tf*fa;
- fs->ftvec[i] = tf*fc;
- fa = fa - fs->ftvec[i];
- }
- tf = -fa;
- for (int i=ford-1; i>=0; i--)
- {
- tf = tf + fs->ftvec[i];
- }
- f0resp = tf;
-
- // second time: compute 1-response
- fa = 1;
- fb = fa;
- for (int i=0; i<ford; i++)
- {
- fc = (fb-fs->frc[i])*frlamb + fs->frb[i];
- tf = fs->fbuff[i][ti4];
- fb = fc - tf*fa;
- fs->ftvec[i] = tf*fc;
- fa = fa - fs->ftvec[i];
- }
- tf = -fa;
- for (int i=ford-1; i>=0; i--)
- {
- tf = tf + fs->ftvec[i];
- }
- f1resp = tf;
-
- // now solve equations for output, based on 0-response and 1-response
- tf = (float)2*tf2;
- tf2 = tf;
- tf = ((float)1 - f1resp + f0resp);
- if (tf!=0)
- {
- tf2 = (tf2 + f0resp) / tf;
- }
- else
- {
- tf2 = 0;
- }
-
- // third time: update delay registers
- fa = tf2;
- fb = fa;
- for (int i=0; i<ford; i++)
- {
- fc = (fb-fs->frc[i])*frlamb + fs->frb[i];
- fs->frc[i] = fc;
- fs->frb[i] = fb;
- tf = fs->fbuff[i][ti4];
- fb = fc - tf*fa;
- fa = fa - tf*fc;
- }
- tf = tf2;
- tf = tf + flpa * fs->flp; // lowpass post-emphasis filter
- fs->flp = tf;
-
- // Bring up the gain slowly when formant correction goes from disabled
- // to enabled, while things stabilize.
- if (fs->fmute>0.5)
- {
- tf = tf*(fs->fmute - 0.5)*2;
- }
- else
- {
- tf = 0;
- }
- tf2 = fs->fmutealph;
- fs->fmute = (1-tf2) + tf2*fs->fmute;
- // now tf is signal output
- // ...and we're done messing with formants
-
- return tf;
-}
--- a/LEAF/Src_cpp/leaf-math.cpp
+++ /dev/null
@@ -1,234 +1,0 @@
-/*
- ==============================================================================
-
- LEAFMath.c
- Created: 22 Jan 2017 7:02:56pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-math.h"
-#include "..\Inc\leaf-wavetables.h"
-
-#else
-
-#include "../Inc/leaf-math.h"
-#include "../Inc/leaf-wavetables.h"
-
-#endif
-
-// The C-embedded Audio Library.
-#define TWO_TO_16 65536.f
-
-#define EXPONENTIAL_TABLE_SIZE 65536
-
-
-
-
-
-// dope af
-float LEAF_chebyshevT(float in, int n){
- if (n == 0) return 1;
- else if (n == 1) return in;
- else return 2.0f * in * LEAF_chebyshevT(in, n-1) - LEAF_chebyshevT(in, n-2);
-}
-
-#if !(_WIN32 || _WIN64)
-float LEAF_CompoundChebyshevT(float in, int n, float* amps){
- float T[n+1];
- T[0] = 1.0f;
- T[1] = in;
- for (int i = 2; i <= n; ++i)
- T[i] = 2*in*T[i-1] - T[i-2];
- float out = 0;
- float amp = 0;
- for (int i = 0; i < n; ++i){
- out += amps[i]*T[i+1];
- amp += amps[i];
- }
- return out / amp ;
-}
-#endif
-
-float LEAF_frequencyToMidi(float f)
-{
- return (69.0f + 12.0f * log2(f * INV_440));
-}
-
-// Erbe shaper
-float LEAF_shaper(float input, float m_drive)
-{
- float fx = input * 2.0f; // prescale
- float w, c, xc, xc2, xc4;
-
- xc = LEAF_clip(-SQRT8, fx, SQRT8);
- xc2 = xc*xc;
- c = 0.5f*fx*(3.0f - (xc2));
- xc4 = xc2 * xc2;
- w = (1.0f - xc2*0.25f + xc4*0.015625f) * WSCALE;
- float shaperOut = w*(c+ 0.05f*xc2)*(m_drive + 0.75f);
- shaperOut *= 0.5f; // post_scale
- return shaperOut;
-}
-
-float LEAF_reedTable(float input, float offset, float slope)
-{
- float output = offset + (slope * input);
- if ( output > 1.0f) output = 1.0f;
- if ( output < -1.0f) output = -1.0f;
- return output;
-}
-
-float LEAF_softClip(float val, float thresh)
-{
- float x;
-
- if(val > thresh)
- {
- x = thresh / val;
- return (1.0f - x) * (1.0f - thresh) + thresh;
- }
- else if(val < -thresh)
- {
- x = -thresh / val;
- return -((1.0f - x) * (1.0f - thresh) + thresh);
- }
- else
- {
- return val;
- }
-}
-
-float LEAF_clip(float min, float val, float max)
- {
-
- if (val < min) {
- return min;
- } else if (val > max) {
- return max;
- } else {
- return val;
- }
-}
-
-oBool LEAF_isPrime(uint64_t number )
-{
- if ( number == 2 ) return OTRUE;
- if ( number & 1 ) {
- for ( int i=3; i<(int)sqrt((double)number)+1; i+=2 )
- if ( (number % i) == 0 ) return OFALSE;
- return OTRUE; // prime
- }
- else return OFALSE; // even
-}
-
-// Adapted from MusicDSP: http://www.musicdsp.org/showone.php?id=238
-float LEAF_tanh(float x)
-{
-
- if( x < -3 )
- return -1;
- else if( x > 3 )
- return 1;
- else
- return x * ( 27 + x * x ) / ( 27 + 9 * x * x );
-}
-
-
-void LEAF_generate_sine(float* buffer, int size)
-{
- float phase;
- for (int i = 0; i < size; i++)
- {
- phase = (float) i / (float) size;
- buffer[i] = sinf(phase * TWO_PI);
- }
-}
-
-void LEAF_generate_sawtooth(float* buffer, float basefreq, int size)
-{
- int harmonic = 1;
- float phase = 0.0f;
- float freq = harmonic * basefreq;
- float amp;
-
- while (freq < (leaf.sampleRate * 0.5))
- {
- amp = 1.0f / harmonic;
- for (int i = 0; i < size; i++)
- {
- phase = (float) i / (float) size;
- buffer[i] += (amp * sinf(harmonic * phase * TWO_PI));
- }
-
- harmonic++;
- freq = harmonic * basefreq;
- }
-}
-
-
-void LEAF_generate_triangle(float* buffer, float basefreq, int size)
-{
- int harmonic = 1;
- float phase = 0.0f;
- float freq = harmonic * basefreq;
- float amp = 1.0f;
-
- int count = 0;
- float mult = 1.0f;
-
- while (freq < (leaf.sampleRate * 0.5))
- {
- amp = 1.0f / (float)(harmonic * harmonic);
-
- if (count % 2) mult = -1.0f;
- else mult = 1.0f;
-
- for (int i = 0; i < size; i++)
- {
- phase = (float) i / (float) size;
- buffer[i] += (mult * amp * sinf(harmonic * phase * TWO_PI));
- }
-
- count++;
- harmonic += 2;
- freq = harmonic * basefreq;
- }
-}
-
-void LEAF_generate_square(float* buffer, float basefreq, int size)
-{
- int harmonic = 1;
- float phase = 0.0f;
- float freq = harmonic * basefreq;
- float amp = 1.0f;
-
- while (freq < (leaf.sampleRate * 0.5))
- {
- amp = 1.0f / (float)(harmonic);
-
- for (int i = 0; i < size; i++)
- {
- phase = (float) i / (float) size;
- buffer[i] += (amp * sinf(harmonic * phase * TWO_PI));
- }
-
- harmonic += 2;
- freq = harmonic * basefreq;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// name: mtof()
-// desc: midi to freq, from PD source
-//-----------------------------------------------------------------------------
-float LEAF_midiToFrequency(float f)
-{
- if( f <= -1500.0f ) return (0);
- else if( f > 1499.0f ) return (LEAF_midiToFrequency(1499.0f));
- else return ( powf(2.0f, (f - 69.0f) / 12.0f) * 440.0f );
-}
--- a/LEAF/Src_cpp/leaf-mempool.cpp
+++ /dev/null
@@ -1,193 +1,0 @@
-
-/** mpool source significantly modified by Mike Mulshine, Jeff Snyder, et al., Princeton University Music Department **/
-
-/**
- In short, mpool is distributed under so called "BSD license",
-
- Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of the authors nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/* written with C99 style */
-
-#include "../Inc/leaf-mempool.h"
-
-
-#define NUM_BLOCKS 50
-
-char memory[MPOOL_POOL_SIZE];
-mpool_pool_t blocks[NUM_BLOCKS]; //
-mpool_t leaf_pool;
-
-/**
- * private function
- */
-static inline size_t mpool_align(size_t size);
-
-
-/**
- * create memory pool
- */
-void mpool_create (size_t size, mpool_t* pool)
-{
- if (size > MPOOL_POOL_SIZE) size = MPOOL_POOL_SIZE;
-
- pool->mpool = &blocks[0];
-
- pool->mpool->pool = (void*)memory;
- pool->mpool->size = size;
- pool->mpool->used = 0;
-
- pool->usize = 0;
- pool->msize = size;
-
- for (int i = 0; i < MPOOL_POOL_SIZE; i++) memory[i]=0;
-}
-
-void leaf_pool_init(size_t size)
-{
- mpool_create(size, &leaf_pool);
-}
-
-/**
- * allocate memory from memory pool
- */
-void* mpool_alloc(size_t size, mpool_t* pool)
-{
- pool->next += 1;
-
- if (pool->next >= NUM_BLOCKS) return NULL;
-
- mpool_pool_t* new_chunk = &blocks[pool->next];
- new_chunk->size = mpool_align(size);
-
- int idx = pool->next - 1;
- for (mpool_pool_t *old_chunk = &blocks[idx]; idx >= 0; old_chunk = &blocks[--idx])
- {
- if (old_chunk->used == 0)
- {
- if (new_chunk->size < old_chunk->size)
- {
- // set memory start pointer of this chunk to that of old chunk, mark new chunk used
- new_chunk->pool = old_chunk->pool;
- new_chunk->used = 1;
-
- // increment memory start pointer of old chunk
- char* ptr = (char*)old_chunk->pool;
- ptr += new_chunk->size;
- old_chunk->pool = (void*)ptr;
-
- // decrement size of old chunk by size of new chunk
- old_chunk->size -= new_chunk->size;
-
- // increment used size of whole mempool by size of new chunk
- pool->usize += new_chunk->size;
-
- // return memory pointer of new chunk
- return new_chunk->pool;
- }
- }
- }
-
- // if not enough space anywhere, return NULL
- return NULL;
-}
-
-void* leaf_alloc(size_t size)
-{
- return mpool_alloc(size, &leaf_pool);
-}
-
-void mpool_free(void* ptr, mpool_t* pool)
-{
- //printf("finding %p\n", ptr);
-
- int idx = 0;
- for (mpool_pool_t *block = &blocks[0]; idx < NUM_BLOCKS; block = &blocks[++idx])
- {
- if (block->pool == ptr)
- {
- // Mark unused
- block->used = 0;
-
-
- // Format to all zeros (kinda arbitrary, but possibly handy / needed)
- char* buff = (char*)block->pool;
- for (int i = 0; i < block->size; i++)
- {
- buff[i] = 0;
- }
-
- // decrement overall pool size
- pool->usize -= block->size;
-
- break;
- }
- }
-}
-
-void leaf_free(void* ptr)
-{
- mpool_free(ptr, &leaf_pool);
-}
-
-size_t mpool_get_size(mpool_t* pool)
-{
- return pool->msize;
-}
-
-size_t leaf_pool_get_size(void)
-{
- return mpool_get_size(&leaf_pool);
-}
-
-size_t mpool_get_used(mpool_t* pool)
-{
- return pool->usize;
-}
-
-size_t leaf_pool_get_used(void)
-{
- return mpool_get_used(&leaf_pool);
-}
-
-void* leaf_pool_get_pool(void)
-{
- float* buff = (float*)memory;
-
- return buff;
-}
-
-/**
- * align byte boundary
- */
-static inline size_t mpool_align(size_t size) {
- return (size + (MPOOL_ALIGN_SIZE - 1)) & ~(MPOOL_ALIGN_SIZE - 1);
-}
-
--- a/LEAF/Src_cpp/leaf-midi.cpp
+++ /dev/null
@@ -1,417 +1,0 @@
-/*
- ==============================================================================
-
- leaf-midi.cpp
- Created: 30 Nov 2018 11:29:16am
- Author: airship
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-midi.h"
-
-#else
-
-#include "../Inc/leaf-midi.h"
-
-#endif
-
-
-/* Poly Handler */
-static void nodeListInit(tPoly* poly)
-{
- for (int16_t i = 0; i < 128; i++)
- {
- poly->midiNodes[i].midiNote.pitch = i;
- poly->midiNodes[i].midiNote.velocity = 0;
- poly->midiNodes[i].midiNote.on = OFALSE;
- }
-}
-
-// Initially everything is off, init as such
-static void offListInit(tPoly* poly)
-{
- tMidiNode* prevNode = NULL;
- tMidiNode* curNode = &poly->midiNodes[0];
- poly->offListFirst = curNode;
-
- for (int16_t i = 1; i < 128; i++)
- {
- curNode->prev = prevNode;
- curNode->next = &poly->midiNodes[i];
-
- prevNode = curNode;
- curNode = &poly->midiNodes[i];
- }
- // Set the final node
- curNode->prev = prevNode;
- curNode->next = NULL;
-}
-
-static void onListInit(tPoly* poly)
-{
- poly->onListFirst = NULL;
-}
-
-void tPoly_init(tPoly* const poly)
-{
- nodeListInit(poly);
- offListInit(poly);
- onListInit(poly);
-}
-
-
-tMidiNote* tPoly_getMidiNote(tPoly* const poly, int8_t voiceIndex)
-{
- tMidiNote* midiNote = NULL;
-
- tMidiNode* currNode = poly->onListFirst;
-
- int8_t i = 0;
- while (i < voiceIndex && currNode != NULL)
- {
- currNode = currNode->next;
- i++;
- }
-
- if (currNode != NULL)
- midiNote = &(currNode->midiNote);
-
- return midiNote;
-}
-
-static void removeNoteFromOffList(tPoly* const poly, int8_t midiNoteNumber)
-{
- // If this has no prev, this is the first node on the OFF list
- if (poly->midiNodes[midiNoteNumber].prev == NULL)
- poly->offListFirst = poly->midiNodes[midiNoteNumber].next;
-
- // Awkward handling to avoid deref null pointers
- if (poly->midiNodes[midiNoteNumber].prev != NULL)
- poly->midiNodes[midiNoteNumber].prev->next = poly->midiNodes[midiNoteNumber].next;
-
- if (poly->midiNodes[midiNoteNumber].next != NULL)
- poly->midiNodes[midiNoteNumber].next->prev = poly->midiNodes[midiNoteNumber].prev;
-
- poly->midiNodes[midiNoteNumber].next = NULL;
- poly->midiNodes[midiNoteNumber].prev = NULL;
-}
-
-static void prependNoteToOnList(tPoly* poly, int midiNoteNumber)
-{
- if (poly->onListFirst != NULL)
- {
- poly->midiNodes[midiNoteNumber].next = poly->onListFirst;
- poly->onListFirst->prev = &poly->midiNodes[midiNoteNumber];
- }
- poly->onListFirst = &poly->midiNodes[midiNoteNumber];
-}
-
-
-// TODO: Fail gracefully on odd MIDI situations
-// For example, getting a note off for an already on note and vice-versa
-void tPoly_noteOn(tPoly* const poly, int midiNoteNumber, float velocity)
-{
- removeNoteFromOffList(poly, midiNoteNumber);
- // Set the MIDI note on accordingly
- poly->midiNodes[midiNoteNumber].midiNote.velocity = velocity;
- poly->midiNodes[midiNoteNumber].midiNote.on = OTRUE;
- prependNoteToOnList(poly, midiNoteNumber);
-}
-
-// Unfortunately similar code to removeNoteFromOffList without any clear way of factoring out to a helper function
-static void removeNoteFromOnList(tPoly* const poly, int8_t midiNoteNumber)
-{
- // If this has no prev, this is the first node on the OFF list
- if (poly->midiNodes[midiNoteNumber].prev == NULL)
- poly->onListFirst = poly->midiNodes[midiNoteNumber].next;
-
- // Awkward handling to avoid deref null pointers
- if (poly->midiNodes[midiNoteNumber].prev != NULL)
- poly->midiNodes[midiNoteNumber].prev->next = poly->midiNodes[midiNoteNumber].next;
-
- if (poly->midiNodes[midiNoteNumber].next != NULL)
- poly->midiNodes[midiNoteNumber].next->prev = poly->midiNodes[midiNoteNumber].prev;
-
- poly->midiNodes[midiNoteNumber].next = NULL;
- poly->midiNodes[midiNoteNumber].prev = NULL;
-}
-
-// Unfortunately similar code to prependNoteToOnList without any clear way of factoring out to a helper function
-static void prependNoteToOffList(tPoly* const poly, int midiNoteNumber)
-{
- if (poly->offListFirst != NULL)
- {
- poly->midiNodes[midiNoteNumber].next = poly->offListFirst;
- poly->offListFirst->prev = &poly->midiNodes[midiNoteNumber];
- }
- poly->offListFirst = &poly->midiNodes[midiNoteNumber];
-}
-
-
-void tPoly_noteOff(tPoly* const poly, int midiNoteNumber)
-{
- removeNoteFromOnList(poly, midiNoteNumber);
- // Set the MIDI note on accordingly
- poly->midiNodes[midiNoteNumber].midiNote.velocity = 0;
- poly->midiNodes[midiNoteNumber].midiNote.on = OFALSE;
- prependNoteToOffList(poly, midiNoteNumber);
-}
-
-
-// MPOLY
-void tMPoly_init(tMPoly* const poly, int numVoices)
-{
- poly->numVoices = numVoices;
- poly->lastVoiceToChange = 0;
-
- // Arp mode stuff
- poly->currentVoice = 0;
- poly->maxLength = 128;
- poly->currentNote = -1;
-
- //default learned CCs and notes are just the CCs 1-128 - notes are skipped
- for (int i = 0; i < 128; i++)
- {
- poly->notes[i][0] = 0;
- poly->notes[i][1] = -1;
- }
-
- for (int i = 0; i < MPOLY_NUM_MAX_VOICES; ++i)
- {
- poly->voices[i][0] = -1;
- poly->firstReceived[i] = 0;
-
- poly->ramp[i] = (tRamp*) leaf_alloc(sizeof(tRamp));
-
- tRamp_init(poly->ramp[i], 5.0f, 1);
- }
-
- poly->glideTime = 5.0f;
-
- poly->pitchBend = 64;
- poly->pitchBendAmount = 2.0f;
-
- poly->stack = (tStack*) leaf_alloc(sizeof(tStack));
- tStack_init(poly->stack);
-
- poly->orderStack = (tStack*) leaf_alloc(sizeof(tStack));
- tStack_init(poly->orderStack);
-}
-
-// Only needs to be used for pitch glide
-void tMPoly_tick(tMPoly* poly)
-{
- for (int i = 0; i < MPOLY_NUM_MAX_VOICES; ++i)
- {
- tRamp_tick(poly->ramp[i]);
- }
-}
-
-//instead of including in dacsend, should have a separate pitch bend ramp, that is added when the ramps are ticked and sent to DAC
-void tMPoly_pitchBend(tMPoly* const poly, int pitchBend)
-{
- poly->pitchBend = pitchBend;
-}
-
-int tMPoly_noteOn(tMPoly* const poly, int note, uint8_t vel)
-{
- // if not in keymap or already on stack, dont do anything. else, add that note.
- if (tStack_contains(poly->stack, note) >= 0) return -1;
- else
- {
- tMPoly_orderedAddToStack(poly, note);
- tStack_add(poly->stack, note);
-
- int alteredVoice = -1;
- oBool found = OFALSE;
- for (int i = 0; i < poly->numVoices; i++)
- {
- if (poly->voices[i][0] < 0) // if inactive voice, give this note to voice
- {
- if (poly->firstReceived[i] == 0)
- {
- tRamp_setVal(poly->ramp[i], note); // can't be 1.0f, causes first note to be off pitch
- poly->firstReceived[i] = 1;
- }
- else
- {
- tRamp_setTime(poly->ramp[i], poly->glideTime);
- }
-
- found = OTRUE;
-
- poly->voices[i][0] = note;
- poly->voices[i][1] = vel;
- poly->lastVoiceToChange = i;
- poly->notes[note][0] = vel;
- poly->notes[note][1] = i;
-
- tRamp_setDest(poly->ramp[i], poly->voices[i][0]);
-
- alteredVoice = i;
- break;
- }
- }
-
- if (!found) //steal
- {
- int whichVoice, whichNote;
- for (int j = tStack_getSize(poly->stack) - 1; j >= 0; j--)
- {
- whichNote = tStack_get(poly->stack, j);
- whichVoice = poly->notes[whichNote][1];
- if (whichVoice >= 0)
- {
- poly->lastVoiceToChange = j;
- int oldNote = poly->voices[whichVoice][0];
- poly->voices[whichVoice][0] = note;
- poly->voices[whichVoice][1] = vel;
- poly->notes[oldNote][1] = -1; //mark the stolen voice as inactive (in the second dimension of the notes array)
- poly->notes[note][0] = vel;
- poly->notes[note][1] = whichVoice;
-
- tRamp_setTime(poly->ramp[whichVoice], poly->glideTime);
- tRamp_setDest(poly->ramp[whichVoice], poly->voices[whichVoice][0]);
-
- alteredVoice = whichVoice;
-
- break;
- }
- }
- }
- return alteredVoice;
- }
-}
-
-
-int16_t noteToTest = -1;
-
-int tMPoly_noteOff(tMPoly* const poly, uint8_t note)
-{
- tStack_remove(poly->stack, note);
- tStack_remove(poly->orderStack, note);
- poly->notes[note][0] = 0;
- poly->notes[note][1] = -1;
-
- int deactivatedVoice = -1;
- for (int i = 0; i < poly->numVoices; i++)
- {
- if (poly->voices[i][0] == note)
- {
- poly->voices[i][0] = -1;
- poly->voices[i][1] = 0;
- poly->lastVoiceToChange = i;
- deactivatedVoice = i;
- break;
- }
- }
- /*
- //monophonic handling
- if ((poly->numVoices == 1) && (tStack_getSize(poly->stack) > 0))
- {
- int oldNote = tStack_first(poly->stack);
- poly->voices[0][0] = oldNote;
- poly->voices[0][1] = poly->notes[oldNote][0];
- poly->lastVoiceToChange = 0;
- }
- */
-
- //grab old notes off the stack if there are notes waiting to replace the free voice
- if (deactivatedVoice >= 0)
- {
- for (int j = 0; j < tStack_getSize(poly->stack); ++j)
- {
- noteToTest = tStack_get(poly->stack, j);
-
- if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack)
- {
- poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note
- tRamp_setDest(poly->ramp[deactivatedVoice], poly->voices[deactivatedVoice][0]);
- poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note
- poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active
- return -1;
- }
- }
- }
- return deactivatedVoice;
-}
-
-void tMPoly_orderedAddToStack(tMPoly* const poly, uint8_t noteVal)
-{
-
- uint8_t j;
- int myPitch, thisPitch, nextPitch;
-
- tStack* ns = poly->orderStack;
-
- int whereToInsert = 0;
-
- for (j = 0; j < ns->size; j++)
- {
- myPitch = noteVal;
- thisPitch = ns->data[j];
- nextPitch = ns->data[j+1];
-
- if (myPitch > thisPitch)
- {
- if ((myPitch < nextPitch) || (nextPitch == -1))
- {
- whereToInsert = j+1;
- break;
- }
- }
- }
-
- //first move notes that are already in the stack one position to the right
- for (j = ns->size; j > whereToInsert; j--)
- {
- ns->data[j] = ns->data[(j - 1)];
- }
-
- //then, insert the new note into the front of the stack
- ns->data[whereToInsert] = noteVal;
-
- ns->size++;
-
-}
-
-void tMPoly_setNumVoices(tMPoly* const poly, uint8_t numVoices)
-{
- poly->numVoices = (numVoices > MPOLY_NUM_MAX_VOICES) ? MPOLY_NUM_MAX_VOICES : numVoices;
-}
-
-void tMPoly_setPitchGlideTime(tMPoly* const poly, float t)
-{
- if (poly->glideTime == t) return;
- poly->glideTime = t;
- for (int i = 0; i < MPOLY_NUM_MAX_VOICES; ++i)
- {
- tRamp_setTime(poly->ramp[i], poly->glideTime);
- }
-}
-
-int tMPoly_getNumVoices(tMPoly* const poly)
-{
- return poly->numVoices;
-}
-
-float tMPoly_getPitch(tMPoly* const poly, uint8_t voice)
-{
- //float pitchBend = ((float)(poly->pitchBend - 8192) / 8192.0f) * poly->pitchBendAmount;
- return tRamp_sample(poly->ramp[voice]);// + pitchBend;
- return poly->voices[voice][0];
-}
-
-int tMPoly_getVelocity(tMPoly* const poly, uint8_t voice)
-{
- return poly->voices[voice][1];
-}
-
-int tMPoly_isOn(tMPoly* const poly, uint8_t voice)
-{
- return (poly->voices[voice][0] > 0) ? 1 : 0;
-}
-
--- a/LEAF/Src_cpp/leaf-oscillator.cpp
+++ /dev/null
@@ -1,639 +1,0 @@
-/*
- ==============================================================================
-
- LEAFOscillator.c
- Created: 20 Jan 2017 12:00:58pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-wavetables.h"
-#include "..\Inc\leaf-oscillator.h"
-#include "..\leaf.h"
-
-#else
-
-#include "../Inc/leaf-wavetables.h"
-#include "../Inc/leaf-oscillator.h"
-#include "../leaf.h"
-
-#endif
-
-void tNeuronSampleRateChanged(tNeuron* n)
-{
-
-}
-
-void tNeuron_init(tNeuron* const n)
-{
- tPoleZero_init(&n->f);
-
- tPoleZero_setBlockZero(&n->f, 0.99f);
-
- n->timeStep = 1.0f / 50.0f;
-
- n->current = 0.0f; // 100.0f for sound
- n->voltage = 0.0f;
-
- n->mode = NeuronNormal;
-
- n->P[0] = 0.0f;
- n->P[1] = 0.0f;
- n->P[2] = 1.0f;
-
- n->V[0] = -12.0f;
- n->V[1] = 115.0f;
- n->V[2] = 10.613f;
-
- n->gK = 36.0f;
- n->gN = 120.0f;
- n->gL = 0.3f;
- n->C = 1.0f;
-
- n->rate[2] = n->gL/n->C;
-}
-
-void tNeuron_free(tNeuron* const n)
-{
- tPoleZero_free(&n->f);
-
- leaf_free(n);
-}
-
-void tNeuron_reset(tNeuron* const n)
-{
-
- tPoleZero_setBlockZero(&n->f, 0.99f);
-
- n->timeStep = 1.0f / 50.0f;
-
- n->current = 0.0f; // 100.0f for sound
- n->voltage = 0.0f;
-
- n->mode = NeuronNormal;
-
- n->P[0] = 0.0f;
- n->P[1] = 0.0f;
- n->P[2] = 1.0f;
-
- n->V[0] = -12.0f;
- n->V[1] = 115.0f;
- n->V[2] = 10.613f;
-
- n->gK = 36.0f;
- n->gN = 120.0f;
- n->gL = 0.3f;
- n->C = 1.0f;
-
- n->rate[2] = n->gL/n->C;
-}
-
-
-void tNeuron_setV1(tNeuron* const n, float V1)
-{
- n->V[0] = V1;
-}
-
-
-void tNeuron_setV2(tNeuron* const n, float V2)
-{
- n->V[1] = V2;
-}
-
-void tNeuron_setV3(tNeuron* const n, float V3)
-{
- n->V[2] = V3;
-}
-
-void tNeuron_setTimeStep(tNeuron* const n, float timeStep)
-{
- n->timeStep = timeStep;
-}
-
-void tNeuron_setK(tNeuron* const n, float K)
-{
- n->gK = K;
-}
-
-void tNeuron_setL(tNeuron* const n, float L)
-{
- n->gL = L;
- n->rate[2] = n->gL/n->C;
-}
-
-void tNeuron_setN(tNeuron* const n, float N)
-{
- n->gN = N;
-}
-
-void tNeuron_setC(tNeuron* const n, float C)
-{
- n->C = C;
- n->rate[2] = n->gL/n->C;
-}
-
-float tNeuron_tick(tNeuron* const n)
-{
- float output = 0.0f;
- float voltage = n->voltage;
-
- n->alpha[0] = (0.01f * (10.0f - voltage)) / (expf((10.0f - voltage)/10.0f) - 1.0f);
- n->alpha[1] = (0.1f * (25.0f-voltage)) / (expf((25.0f-voltage)/10.0f) - 1.0f);
- n->alpha[2] = (0.07f * expf((-1.0f * voltage)/20.0f));
-
- n->beta[0] = (0.125f * expf((-1.0f* voltage)/80.0f));
- n->beta[1] = (4.0f * expf((-1.0f * voltage)/18.0f));
- n->beta[2] = (1.0f / (expf((30.0f-voltage)/10.0f) + 1.0f));
-
- for (int i = 0; i < 3; i++)
- {
- n->P[i] = (n->alpha[i] * n->timeStep) + ((1.0f - ((n->alpha[i] + n->beta[i]) * n->timeStep)) * n->P[i]);
-
- if (n->P[i] > 1.0f) n->P[i] = 0.0f;
- else if (n->P[i] < -1.0f) n->P[i] = 0.0f;
- }
- // rate[0]= k ; rate[1] = Na ; rate[2] = l
- n->rate[0] = ((n->gK * powf(n->P[0], 4.0f)) / n->C);
- n->rate[1] = ((n->gN * powf(n->P[1], 3.0f) * n->P[2]) / n->C);
-
- //calculate the final membrane voltage based on the computed variables
- n->voltage = voltage +
- (n->timeStep * n->current / n->C) -
- (n->timeStep * ( n->rate[0] * (voltage - n->V[0]) + n->rate[1] * (voltage - n->V[1]) + n->rate[2] * (voltage - n->V[2])));
-
- if (n->mode == NeuronTanh)
- {
- n->voltage = 100.0f * tanhf(0.01f * n->voltage);
- }
- else if (n->mode == NeuronAaltoShaper)
- {
- float shapeVoltage = 0.01f * n->voltage;
-
- float w, c, xc, xc2, xc4;
-
- float sqrt8 = 2.82842712475f;
-
- float wscale = 1.30612244898f;
- float m_drive = 1.0f;
-
- xc = LEAF_clip(-sqrt8, shapeVoltage, sqrt8);
-
- xc2 = xc*xc;
-
- c = 0.5f * shapeVoltage * (3.0f - (xc2));
-
- xc4 = xc2 * xc2;
-
- w = (1.0f - xc2 * 0.25f + xc4 * 0.015625f) * wscale;
-
- shapeVoltage = w * (c + 0.05f * xc2) * (m_drive + 0.75f);
-
- n->voltage = 100.0f * shapeVoltage;
- }
-
-
- if (n->voltage > 100.0f) n->voltage = 100.0f;
- else if (n->voltage < -100.) n->voltage = -100.0f;
-
- //(inputCurrent + (voltage - ((voltage * timeStep) / timeConstant)) + P[0] + P[1] + P[2]) => voltage;
- // now we should have a result
- //set the output voltage to the "step" ugen, which controls the DAC.
- output = n->voltage * 0.01f; // volts
-
- output = tPoleZero_tick(&n->f, output);
-
- return output;
-
-}
-
-void tNeuron_setMode (tNeuron* const n, NeuronMode mode)
-{
- n->mode = mode;
-}
-
-void tNeuron_setCurrent (tNeuron* const n, float current)
-{
- n->current = current;
-}
-
-// Cycle
-void tCycle_init(tCycle* const c)
-{
- c->inc = 0.0f;
- c->phase = 0.0f;
-}
-
-void tCycle_free(tCycle* const c)
-{
- leaf_free(c);
-}
-
-int tCycle_setFreq(tCycle* const c, float freq)
-{
- if (freq < 0.0f) freq = 0.0f;
-
- c->freq = freq;
- c->inc = freq * leaf.invSampleRate;
-
- return 0;
-}
-
-float tCycle_tick(tCycle* const c)
-{
- // Phasor increment
- c->phase += c->inc;
- if (c->phase >= 1.0f) c->phase -= 1.0f;
-
- // Wavetable synthesis
- float temp = SINE_TABLE_SIZE * c->phase;
- int intPart = (int)temp;
- float fracPart = temp - (float)intPart;
- float samp0 = sinewave[intPart];
- if (++intPart >= SINE_TABLE_SIZE) intPart = 0;
- float samp1 = sinewave[intPart];
- return (samp0 + (samp1 - samp0) * fracPart);
-}
-
-void tCycleSampleRateChanged (tCycle* const c)
-{
- c->inc = c->freq * leaf.invSampleRate;
-}
-
-/* Phasor */
-void tPhasorSampleRateChanged (tPhasor* const p)
-{
- p->inc = p->freq * leaf.invSampleRate;
-};
-
-int tPhasor_setFreq(tPhasor* const p, float freq)
-{
- if (freq < 0.0f) freq = 0.0f;
-
- p->freq = freq;
- p->inc = freq * leaf.invSampleRate;
-
- return 0;
-}
-
-float tPhasor_tick(tPhasor* const p)
-{
- p->phase += p->inc;
-
- if (p->phase >= 1.0f) p->phase -= 1.0f;
-
- return p->phase;
-}
-
-void tPhasor_init(tPhasor* const p)
-{
- p->phase = 0.0f;
- p->inc = 0.0f;
-}
-
-void tPhasor_free(tPhasor* const p)
-{
- leaf_free(p);
-}
-
-void tSawtooth_init(tSawtooth* const c)
-{
- c->inc = 0.0f;
- c->phase = 0.0f;
-}
-
-void tSawtooth_free(tSawtooth* const c)
-{
- leaf_free(c);
-}
-
-int tSawtooth_setFreq(tSawtooth* const c, float freq)
-{
- if (freq < 0.0f) freq = 0.0f;
-
- c->freq = freq;
- c->inc = freq * leaf.invSampleRate;
-
- return 0;
-}
-
-float tSawtooth_tick(tSawtooth* const c)
-{
- // Phasor increment
- c->phase += c->inc;
- if (c->phase >= 1.0f) c->phase -= 1.0f;
-
- float out = 0.0f;
- float w;
-
- int idx = (int)(c->phase * TRI_TABLE_SIZE);
-
- // Wavetable synthesis
-
- if (c->freq <= 20.0f)
- {
- out = sawtooth[T20][idx];
- }
- else if (c->freq <= 40.0f)
- {
- w = ((40.0f - c->freq) * INV_20);
- out = (sawtooth[T20][idx] * w) + (sawtooth[T40][idx] * (1.0f - w));
- }
- else if (c->freq <= 80.0f)
- {
- w = ((80.0f - c->freq) * INV_40);
- out = (sawtooth[T40][idx] * w) + (sawtooth[T80][idx] * (1.0f - w));
- }
- else if (c->freq <= 160.0f)
- {
- w = ((160.0f - c->freq) * INV_80);
- out = (sawtooth[T80][idx] * w) + (sawtooth[T160][idx] * (1.0f - w));
- }
- else if (c->freq <= 320.0f)
- {
- w = ((320.0f - c->freq) * INV_160);
- out = (sawtooth[T160][idx] * w) + (sawtooth[T320][idx] * (1.0f - w));
- }
- else if (c->freq <= 640.0f)
- {
- w = ((640.0f - c->freq) * INV_320);
- out = (sawtooth[T320][idx] * w) + (sawtooth[T640][idx] * (1.0f - w));
- }
- else if (c->freq <= 1280.0f)
- {
- w = ((1280.0f - c->freq) * INV_640);
- out = (sawtooth[T640][idx] * w) + (sawtooth[T1280][idx] * (1.0f - w));
- }
- else if (c->freq <= 2560.0f)
- {
- w = ((2560.0f - c->freq) * INV_1280);
- out = (sawtooth[T1280][idx] * w) + (sawtooth[T2560][idx] * (1.0f - w));
- }
- else if (c->freq <= 5120.0f)
- {
- w = ((5120.0f - c->freq) * INV_2560);
- out = (sawtooth[T2560][idx] * w) + (sawtooth[T5120][idx] * (1.0f - w));
- }
- else if (c->freq <= 10240.0f)
- {
- w = ((10240.0f - c->freq) * INV_5120);
- out = (sawtooth[T5120][idx] * w) + (sawtooth[T10240][idx] * (1.0f - w));
- }
- else if (c->freq <= 20480.0f)
- {
- w = ((20480.0f - c->freq) * INV_10240);
- out = (sawtooth[T10240][idx] * w) + (sawtooth[T20480][idx] * (1.0f - w));
- }
- else
- {
- out = sawtooth[T20480][idx];
- }
-
- return out;
-}
-
-void tSawtoothSampleRateChanged (tSawtooth* const c)
-{
- c->inc = c->freq * leaf.invSampleRate;
-}
-
-/* Triangle */
-void tTriangle_start(tTriangle* const c)
-{
-
-}
-
-void tTriangle_init(tTriangle* const c)
-{
- c->inc = 0.0f;
- c->phase = 0.0f;
-}
-
-void tTriangle_free(tTriangle* const c)
-{
- leaf_free(c);}
-
-int tTriangle_setFreq(tTriangle* const c, float freq)
-{
- if (freq < 0.0f) freq = 0.0f;
-
- c->freq = freq;
- c->inc = freq * leaf.invSampleRate;
-
- return 0;
-}
-
-
-float tTriangle_tick(tTriangle* const c)
-{
- // Phasor increment
- c->phase += c->inc;
- if (c->phase >= 1.0f) c->phase -= 1.0f;
-
- float out = 0.0f;
- float w;
-
- int idx = (int)(c->phase * TRI_TABLE_SIZE);
-
- // Wavetable synthesis
-
- if (c->freq <= 20.0f)
- {
- out = triangle[T20][idx];
- }
- else if (c->freq <= 40.0f)
- {
- w = ((40.0f - c->freq) * INV_20);
- out = (triangle[T20][idx] * w) + (triangle[T40][idx] * (1.0f - w));
- }
- else if (c->freq <= 80.0f)
- {
- w = ((80.0f - c->freq) * INV_40);
- out = (triangle[T40][idx] * w) + (triangle[T80][idx] * (1.0f - w));
- }
- else if (c->freq <= 160.0f)
- {
- w = ((160.0f - c->freq) * INV_80);
- out = (triangle[T80][idx] * w) + (triangle[T160][idx] * (1.0f - w));
- }
- else if (c->freq <= 320.0f)
- {
- w = ((320.0f - c->freq) * INV_160);
- out = (triangle[T160][idx] * w) + (triangle[T320][idx] * (1.0f - w));
- }
- else if (c->freq <= 640.0f)
- {
- w = ((640.0f - c->freq) * INV_320);
- out = (triangle[T320][idx] * w) + (triangle[T640][idx] * (1.0f - w));
- }
- else if (c->freq <= 1280.0f)
- {
- w = ((1280.0f - c->freq) * INV_640);
- out = (triangle[T640][idx] * w) + (triangle[T1280][idx] * (1.0f - w));
- }
- else if (c->freq <= 2560.0f)
- {
- w = ((2560.0f - c->freq) * INV_1280);
- out = (triangle[T1280][idx] * w) + (triangle[T2560][idx] * (1.0f - w));
- }
- else if (c->freq <= 5120.0f)
- {
- w = ((5120.0f - c->freq) * INV_2560);
- out = (triangle[T2560][idx] * w) + (triangle[T5120][idx] * (1.0f - w));
- }
- else if (c->freq <= 10240.0f)
- {
- w = ((10240.0f - c->freq) * INV_5120);
- out = (triangle[T5120][idx] * w) + (triangle[T10240][idx] * (1.0f - w));
- }
- else if (c->freq <= 20480.0f)
- {
- w = ((20480.0f - c->freq) * INV_10240);
- out = (triangle[T10240][idx] * w) + (triangle[T20480][idx] * (1.0f - w));
- }
- else
- {
- out = triangle[T20480][idx];
- }
-
- return out;
-}
-
-void tTriangleSampleRateChanged (tTriangle* const c)
-{
- c->inc = c->freq * leaf.invSampleRate;
-}
-
-/* Square */
-void tSquare_init(tSquare* const c)
-{
- c->inc = 0.0f;
- c->phase = 0.0f;
-}
-
-void tSquare_free(tSquare* const c)
-{
- leaf_free(c);
-}
-
-int tSquare_setFreq(tSquare* const c, float freq)
-{
- if (freq < 0.0f) freq = 0.0f;
-
- c->freq = freq;
- c->inc = freq * leaf.invSampleRate;
-
- return 0;
-}
-
-float tSquare_tick(tSquare* const c)
-{
- // Phasor increment
- c->phase += c->inc;
- if (c->phase >= 1.0f) c->phase -= 1.0f;
-
- float out = 0.0f;
- float w = 0.0f;
- int idx = (int)(c->phase * TRI_TABLE_SIZE);
-
- // Wavetable synthesis
-
- if (c->freq <= 20.0f)
- {
- out = squarewave[T20][idx];
- }
- else if (c->freq <= 40.0f)
- {
- w = ((40.0f - c->freq) * INV_20);
- out = (squarewave[T20][idx] * w) + (squarewave[T40][idx] * (1.0f - w));
- }
- else if (c->freq <= 80.0f)
- {
- w = ((80.0f - c->freq) * INV_40);
- out = (squarewave[T40][idx] * w) + (squarewave[T80][idx] * (1.0f - w));
- }
- else if (c->freq <= 160.0f)
- {
- w = ((160.0f - c->freq) * INV_80);
- out = (squarewave[T80][idx] * w) + (squarewave[T160][idx] * (1.0f - w));
- }
- else if (c->freq <= 320.0f)
- {
- w = ((320.0f - c->freq) * INV_160);
- out = (squarewave[T160][idx] * w) + (squarewave[T320][idx] * (1.0f - w));
- }
- else if (c->freq <= 640.0f)
- {
- w = ((640.0f - c->freq) * INV_320);
- out = (squarewave[T320][idx] * w) + (squarewave[T640][idx] * (1.0f - w));
- }
- else if (c->freq <= 1280.0f)
- {
- w = ((1280.0f - c->freq) * INV_640);
- out = (squarewave[T640][idx] * w) + (squarewave[T1280][idx] * (1.0f - w));
- }
- else if (c->freq <= 2560.0f)
- {
- w = ((2560.0f - c->freq) * INV_1280);
- out = (squarewave[T1280][idx] * w) + (squarewave[T2560][idx] * (1.0f - w));
- }
- else if (c->freq <= 5120.0f)
- {
- w = ((5120.0f - c->freq) * INV_2560);
- out = (squarewave[T2560][idx] * w) + (squarewave[T5120][idx] * (1.0f - w));
- }
- else if (c->freq <= 10240.0f)
- {
- w = ((10240.0f - c->freq) * INV_5120);
- out = (squarewave[T5120][idx] * w) + (squarewave[T10240][idx] * (1.0f - w));
- }
- else if (c->freq <= 20480.0f)
- {
- w = ((20480.0f - c->freq) * INV_10240);
- out = (squarewave[T10240][idx] * w) + (squarewave[T20480][idx] * (1.0f - w));
- }
- else
- {
- out = squarewave[T20480][idx];
- }
-
- return out;
-}
-
-void tSquareSampleRateChanged (tSquare* const c)
-{
- c->inc = c->freq * leaf.invSampleRate;
-}
-
-/* Noise */
-void tNoise_init(tNoise* const n, NoiseType type)
-{
- n->type = type;
- n->rand = leaf.random;
-}
-
-void tNoise_free(tNoise* const n)
-{
- leaf_free(n);
-}
-
-float tNoise_tick(tNoise* const n)
-{
- float rand = n->rand();
-
- if (n->type == PinkNoise)
- {
- float tmp;
- n->pinkb0 = 0.99765f * n->pinkb0 + rand * 0.0990460f;
- n->pinkb1 = 0.96300f * n->pinkb1 + rand * 0.2965164f;
- n->pinkb2 = 0.57000f * n->pinkb2 + rand * 1.0526913f;
- tmp = n->pinkb0 + n->pinkb1 + n->pinkb2 + rand * 0.1848f;
- return (tmp * 0.05f);
- }
- else // WhiteNoise
- {
- return rand;
- }
-}
--- a/LEAF/Src_cpp/leaf-pitch.cpp
+++ /dev/null
@@ -1,573 +1,0 @@
-/*
- ==============================================================================
-
- leaf-pitch.cpp
- Created: 30 Nov 2018 11:02:59am
- Author: airship
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-pitch.h"
-#else
-
-#include "../Inc/leaf-pitch.h"
-
-#endif
-
-static int pitchshifter_attackdetect(tPitchShifter* ps);
-
-void tPitchShifter_init(tPitchShifter* const ps, float* in, float* out, int bufSize, int frameSize)
-{
- ps->inBuffer = in;
- ps->outBuffer = out;
- ps->bufSize = bufSize;
- ps->frameSize = frameSize;
- ps->framesPerBuffer = ps->bufSize / ps->frameSize;
- ps->curBlock = 1;
- ps->lastBlock = 0;
- ps->index = 0;
-
- ps->hopSize = DEFHOPSIZE;
- ps->windowSize = DEFWINDOWSIZE;
- ps->fba = FBA;
-
- tEnv_init(&ps->env, ps->windowSize, ps->hopSize, ps->frameSize);
-
- tSNAC_init(&ps->snac, DEFOVERLAP);
-
- tSOLAD_init(&ps->sola);
-
- tHighpass_init(&ps->hp, HPFREQ);
-
- tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
-
- tPitchShifter_setTimeConstant(ps, DEFTIMECONSTANT);
-}
-
-void tPitchShifter_free(tPitchShifter* const ps)
-{
- tEnv_free(&ps->env);
- tSNAC_free(&ps->snac);
- tSOLAD_free(&ps->sola);
- tHighpass_free(&ps->hp);
-
- leaf_free(ps);
-}
-
-float tPitchShifter_tick(tPitchShifter* ps, float sample)
-{
- float period, out;
- int i, iLast;
-
- i = (ps->curBlock*ps->frameSize);
- iLast = (ps->lastBlock*ps->frameSize)+ps->index;
-
- out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
- ps->inBuffer[i+ps->index] = sample;
-
- ps->index++;
- if (ps->index >= ps->frameSize)
- {
- ps->index = 0;
-
- tEnv_processBlock(&ps->env, &(ps->inBuffer[i]));
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
- period = tSNAC_getPeriod(&ps->snac);
-
- ps->curBlock++;
- if (ps->curBlock >= ps->framesPerBuffer) ps->curBlock = 0;
- ps->lastBlock++;
- if (ps->lastBlock >= ps->framesPerBuffer) ps->lastBlock = 0;
-
- //separate here
-
- tSOLAD_setPeriod(&ps->sola, period);
-
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
-
-
- }
-
- return out;
-}
-
-float tPitchShifterToFreq_tick(tPitchShifter* ps, float sample, float freq)
-{
- float period, out;
- int i, iLast;
-
- i = (ps->curBlock*ps->frameSize);
- iLast = (ps->lastBlock*ps->frameSize)+ps->index;
-
- out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
- ps->inBuffer[i+ps->index] = sample;
-
- ps->index++;
- if (ps->index >= ps->frameSize)
- {
- ps->index = 0;
-
- tEnv_processBlock(&ps->env, &(ps->inBuffer[i]));
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
- period = tSNAC_getPeriod(&ps->snac);
-
- tSOLAD_setPeriod(&ps->sola, period);
-
- ps->pitchFactor = period*freq*leaf.invSampleRate;
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
-
- ps->curBlock++;
- if (ps->curBlock >= ps->framesPerBuffer) ps->curBlock = 0;
- ps->lastBlock++;
- if (ps->lastBlock >= ps->framesPerBuffer) ps->lastBlock = 0;
- }
-
- return out;
-}
-
-float tPitchShifterToFunc_tick(tPitchShifter* ps, float sample, float (*fun)(float))
-{
- float period, out;
- int i, iLast;
-
- i = (ps->curBlock*ps->frameSize);
- iLast = (ps->lastBlock*ps->frameSize)+ps->index;
-
- out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
- ps->inBuffer[i+ps->index] = sample;
-
- ps->index++;
- if (ps->index >= ps->frameSize)
- {
- ps->index = 0;
-
- tEnv_processBlock(&ps->env, &(ps->inBuffer[i]));
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, (&ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
- period = tSNAC_getPeriod(&ps->snac);
-
- tSOLAD_setPeriod(&ps->sola, period);
-
- ps->pitchFactor = period/fun(period);
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
-
- ps->curBlock++;
- if (ps->curBlock >= ps->framesPerBuffer) ps->curBlock = 0;
- ps->lastBlock++;
- if (ps->lastBlock >= ps->framesPerBuffer) ps->lastBlock = 0;
- }
-
- return out;
-}
-
-void tPitchShifter_ioSamples(tPitchShifter* ps, float* in, float* out, int size)
-{
- float period;
-
- tEnv_processBlock(&ps->env, in);
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, in, out, size);
- period = tSNAC_getPeriod(&ps->snac);
-
- tSOLAD_setPeriod(&ps->sola, period);
-
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, in, out, size);
-
- for (int cc = 0; cc < size; ++cc)
- {
- out[cc] = tHighpass_tick(&ps->hp, out[cc]);
- }
-}
-
-void tPitchShifter_ioSamples_toFreq(tPitchShifter* ps, float* in, float* out, int size, float toFreq)
-{
- float period;
-
- tEnv_processBlock(&ps->env, in);
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, in, out, size);
- period = tSNAC_getPeriod(&ps->snac);
-
- tSOLAD_setPeriod(&ps->sola, period);
- ps->pitchFactor = period*toFreq;
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, in, out, size);
-
- for (int cc = 0; cc < size; ++cc)
- {
- out[cc] = tHighpass_tick(&ps->hp, out[cc]);
- }
-}
-
-void tPitchShifter_ioSamples_toPeriod(tPitchShifter* ps, float* in, float* out, int size, float toPeriod)
-{
- float period;
-
- tEnv_processBlock(&ps->env, in);
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, in, out, size);
- period = tSNAC_getPeriod(&ps->snac);
-
- tSOLAD_setPeriod(&ps->sola, period);
- ps->pitchFactor = period/toPeriod;
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, in, out, size);
-
- for (int cc = 0; cc < size; ++cc)
- {
- out[cc] = tHighpass_tick(&ps->hp, out[cc]);
- }
-}
-
-void tPitchShifter_ioSamples_toFunc(tPitchShifter* ps, float* in, float* out, int size, float (*fun)(float))
-{
- float period;
-
- tEnv_processBlock(&ps->env, in);
-
- if(pitchshifter_attackdetect(ps) == 1)
- {
- ps->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->windowSize);
- }
-
- tSNAC_ioSamples(&ps->snac, in, out, size);
- period = tSNAC_getPeriod(&ps->snac);
-
- tSOLAD_setPeriod(&ps->sola, period);
- ps->pitchFactor = period/fun(period);
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
- tSOLAD_ioSamples(&ps->sola, in, out, size);
-
- for (int cc = 0; cc < size; ++cc)
- {
- out[cc] = tHighpass_tick(&ps->hp, out[cc]);
- }
-}
-
-void tPitchShifter_setPitchFactor(tPitchShifter* ps, float pf)
-{
- ps->pitchFactor = pf;
-}
-
-void tPitchShifter_setTimeConstant(tPitchShifter* ps, float tc)
-{
- ps->timeConstant = tc;
- ps->radius = expf(-1000.0f * ps->hopSize * leaf.invSampleRate / ps->timeConstant);
-}
-
-void tPitchShifter_setHopSize(tPitchShifter* ps, int hs)
-{
- ps->hopSize = hs;
-}
-
-void tPitchShifter_setWindowSize(tPitchShifter* ps, int ws)
-{
- ps->windowSize = ws;
-}
-
-float tPitchShifter_getPeriod(tPitchShifter* ps)
-{
- return tSNAC_getPeriod(&ps->snac);
-}
-
-static int pitchshifter_attackdetect(tPitchShifter* ps)
-{
- float envout;
-
- envout = tEnv_tick(&ps->env);
-
- if (envout >= 1.0f)
- {
- ps->lastmax = ps->max;
- if (envout > ps->max)
- {
- ps->max = envout;
- }
- else
- {
- ps->deltamax = envout - ps->max;
- ps->max = ps->max * ps->radius;
- }
- ps->deltamax = ps->max - ps->lastmax;
- }
-
- ps->fba = ps->fba ? (ps->fba - 1) : 0;
-
- return (ps->fba == 0 && (ps->max > 60 && ps->deltamax > 6)) ? 1 : 0;
-}
-
-
-void tPeriod_init (tPeriod* const p, float* in, float* out, int bufSize, int frameSize)
-{
- p->inBuffer = in;
- p->outBuffer = out;
- p->bufSize = bufSize;
- p->frameSize = frameSize;
- p->framesPerBuffer = p->bufSize / p->frameSize;
- p->curBlock = 1;
- p->lastBlock = 0;
- p->index = 0;
-
- p->hopSize = DEFHOPSIZE;
- p->windowSize = DEFWINDOWSIZE;
- p->fba = FBA;
-
- tEnv_init(&p->env, p->windowSize, p->hopSize, p->frameSize);
-
- tSNAC_init(&p->snac, DEFOVERLAP);
-
- p->timeConstant = DEFTIMECONSTANT;
- p->radius = expf(-1000.0f * p->hopSize * leaf.invSampleRate / p->timeConstant);
-}
-
-void tPeriod_free (tPeriod* const p)
-{
- tEnv_free(&p->env);
- tSNAC_free(&p->snac);
-
- leaf_free(p);
-}
-
-float tPeriod_findPeriod (tPeriod* p, float sample)
-{
- float period;
- int i, iLast;
-
- i = (p->curBlock*p->frameSize);
- iLast = (p->lastBlock*p->frameSize)+p->index;
-
- p->i = i;
- p->iLast = iLast;
-
- p->inBuffer[i+p->index] = sample;
-
- p->index++;
- p->indexstore = p->index;
- if (p->index >= p->frameSize)
- {
- p->index = 0;
-
- tEnv_processBlock(&p->env, &(p->inBuffer[i]));
-
- tSNAC_ioSamples(&p->snac, &(p->inBuffer[i]), &(p->outBuffer[i]), p->frameSize);
- p->period = tSNAC_getPeriod(&p->snac);
-
- p->curBlock++;
- if (p->curBlock >= p->framesPerBuffer) p->curBlock = 0;
- p->lastBlock++;
- if (p->lastBlock >= p->framesPerBuffer) p->lastBlock = 0;
- }
-
- // changed from period to p->period
- return p->period;
-}
-
-void tPeriod_setHopSize(tPeriod* p, int hs)
-{
- p->hopSize = hs;
-}
-
-void tPeriod_setWindowSize(tPeriod* p, int ws)
-{
- p->windowSize = ws;
-}
-
-void tPitchShift_setPitchFactor(tPitchShift* ps, float pf)
-{
- ps->pitchFactor = pf;
-}
-
-static int pitchshift_attackdetect(tPitchShift* ps)
-{
- float envout;
-
- envout = tEnv_tick(&ps->p->env);
-
- if (envout >= 1.0f)
- {
- ps->p->lastmax = ps->p->max;
- if (envout > ps->p->max)
- {
- ps->p->max = envout;
- }
- else
- {
- ps->p->deltamax = envout - ps->p->max;
- ps->p->max = ps->p->max * ps->radius;
- }
- ps->p->deltamax = ps->p->max - ps->p->lastmax;
- }
-
- ps->p->fba = ps->p->fba ? (ps->p->fba - 1) : 0;
-
- return (ps->p->fba == 0 && (ps->p->max > 60 && ps->p->deltamax > 6)) ? 1 : 0;
-}
-
-void tPitchShift_init (tPitchShift* const ps, tPeriod* p, float* out, int bufSize)
-{
- ps->p = p;
-
- ps->outBuffer = out;
- ps->bufSize = bufSize;
- ps->frameSize = p->frameSize;
- ps->framesPerBuffer = ps->bufSize / ps->frameSize;
- ps->curBlock = 1;
- ps->lastBlock = 0;
- ps->index = 0;
- ps->pitchFactor = 1.0f;
-
- tSOLAD_init(&ps->sola);
-
- tHighpass_init(&ps->hp, HPFREQ);
-
- tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
-}
-
-void tPitchShift_free(tPitchShift* const ps)
-{
- tSOLAD_free(&ps->sola);
- tHighpass_free(&ps->hp);
-
- leaf_free(ps);
-}
-
-float tPitchShift_shift (tPitchShift* ps)
-{
- float period, out;
- int i, iLast;
-
- i = ps->p->i;
- iLast = ps->p->iLast;
-
- out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
-
- if (ps->p->indexstore >= ps->frameSize)
- {
- period = ps->p->period;
-
- if(pitchshift_attackdetect(ps) == 1)
- {
- ps->p->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->p->windowSize);
- }
-
- tSOLAD_setPeriod(&ps->sola, period);
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
-
- tSOLAD_ioSamples(&ps->sola, &(ps->p->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
- }
-
- return out;
-}
-
-float tPitchShift_shiftToFreq (tPitchShift* ps, float freq)
-{
- float period, out;
- int i, iLast;
-
- i = ps->p->i;
- iLast = ps->p->iLast;
-
- out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
-
- if (ps->p->indexstore >= ps->frameSize)
- {
- period = ps->p->period;
-
- if(pitchshift_attackdetect(ps) == 1)
- {
- ps->p->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->p->windowSize);
- }
-
- tSOLAD_setPeriod(&ps->sola, period);
-
- ps->pitchFactor = period*freq*leaf.invSampleRate;
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
-
- tSOLAD_ioSamples(&ps->sola, &(ps->p->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
- }
- return out;
-}
-
-float tPitchShift_shiftToFunc (tPitchShift* ps, float (*fun)(float))
-{
- float period, out;
- int i, iLast;
-
- i = ps->p->i;
- iLast = ps->p->iLast;
-
- out = tHighpass_tick(&ps->hp, ps->outBuffer[iLast]);
-
- if (ps->p->indexstore >= ps->frameSize)
- {
- period = ps->p->period;
-
- if(pitchshift_attackdetect(ps) == 1)
- {
- ps->p->fba = 5;
- tSOLAD_setReadLag(&ps->sola, ps->p->windowSize);
- }
-
- tSOLAD_setPeriod(&ps->sola, period);
-
- ps->pitchFactor = period/fun(period);
- tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
-
- tSOLAD_ioSamples(&ps->sola, &(ps->p->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
-
- ps->curBlock++;
- if (ps->curBlock >= ps->p->framesPerBuffer) ps->curBlock = 0;
- ps->lastBlock++;
- if (ps->lastBlock >= ps->framesPerBuffer) ps->lastBlock = 0;
- }
-
- return out;
-}
--- a/LEAF/Src_cpp/leaf-reverb.cpp
+++ /dev/null
@@ -1,487 +1,0 @@
-/*
- ==============================================================================
-
- LEAFReverb.c
- Created: 20 Jan 2017 12:02:04pm
- Author: Michael R Mulshine
-
- ==============================================================================
-*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-reverb.h"
-#include "..\leaf.h"
-
-#else
-
-#include "../Inc/leaf-reverb.h"
-#include "../leaf.h"
-
-#endif
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ PRCRev ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-void tPRCRev_init(tPRCRev* const r, float t60)
-{
- if (t60 <= 0.0f) t60 = 0.001f;
-
- r->inv_441 = 1.0f/44100.0f;
-
- int lengths[4] = { 341, 613, 1557, 2137 }; // Delay lengths for 44100 Hz sample rate.
- double scaler = leaf.sampleRate * r->inv_441;
-
- int delay, i;
- if (scaler != 1.0f)
- {
- for (i=0; i<4; i++)
- {
- delay = (int) scaler * lengths[i];
-
- if ( (delay & 1) == 0) delay++;
-
- while ( !LEAF_isPrime(delay) ) delay += 2;
-
- lengths[i] = delay;
- }
- }
-
- r->allpassDelays[0] = (tDelay*) leaf_alloc(sizeof(tDelay));
- tDelay_init(r->allpassDelays[0], lengths[0], lengths[0] * 2);
-
- r->allpassDelays[1] = (tDelay*) leaf_alloc(sizeof(tDelay));
- tDelay_init(r->allpassDelays[1], lengths[1], lengths[1] * 2);
-
- r->combDelay = (tDelay*) leaf_alloc(sizeof(tDelay));
- tDelay_init(r->combDelay, lengths[2], lengths[2] * 2);
-
- tPRCRev_setT60(r, t60);
-
- r->allpassCoeff = 0.7f;
- r->mix = 0.5f;
-}
-
-void tPRCRev_free(tPRCRev* const r)
-{
- tDelay_free(r->allpassDelays[0]);
- tDelay_free(r->allpassDelays[1]);
- tDelay_free(r->combDelay);
- leaf_free(r);
-}
-
-void tPRCRev_setT60(tPRCRev* const r, float t60)
-{
- if ( t60 <= 0.0f ) t60 = 0.001f;
-
- r->t60 = t60;
-
- r->combCoeff = pow(10.0f, (-3.0f * tDelay_getDelay(r->combDelay) * leaf.invSampleRate / t60 ));
-
-}
-
-void tPRCRev_setMix(tPRCRev* const r, float mix)
-{
- r->mix = mix;
-}
-
-float tPRCRev_tick(tPRCRev* const r, float input)
-{
- float temp, temp0, temp1, temp2;
- float out;
-
- r->lastIn = input;
-
- temp = tDelay_getLastOut(r->allpassDelays[0]);
- temp0 = r->allpassCoeff * temp;
- temp0 += input;
- tDelay_tick(r->allpassDelays[0], temp0);
- temp0 = -( r->allpassCoeff * temp0) + temp;
-
- temp = tDelay_getLastOut(r->allpassDelays[1]);
- temp1 = r->allpassCoeff * temp;
- temp1 += temp0;
- tDelay_tick(r->allpassDelays[1], temp1);
- temp1 = -(r->allpassCoeff * temp1) + temp;
-
- temp2 = temp1 + ( r->combCoeff * tDelay_getLastOut(r->combDelay));
-
- out = r->mix * tDelay_tick(r->combDelay, temp2);
-
- temp = (1.0f - r->mix) * input;
-
- out += temp;
-
- r->lastOut = out;
-
- return out;
-}
-
-void tPRCRevSampleRateChanged (tPRCRev* const r)
-{
- r->combCoeff = pow(10.0f, (-3.0f * tDelay_getDelay(r->combDelay) * leaf.invSampleRate / r->t60 ));
-}
-
-/* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NRev ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
-void tNRev_init(tNRev* const r, float t60)
-{
- if (t60 <= 0.0f) t60 = 0.001f;
-
- r->inv_441 = 1.0f/44100.0f;
-
- int lengths[15] = {1433, 1601, 1867, 2053, 2251, 2399, 347, 113, 37, 59, 53, 43, 37, 29, 19}; // Delay lengths for 44100 Hz sample rate.
- double scaler = leaf.sampleRate / 25641.0f;
-
- int delay, i;
-
- for (i=0; i < 15; i++)
- {
- delay = (int) scaler * lengths[i];
- if ( (delay & 1) == 0)
- delay++;
- while ( !LEAF_isPrime(delay) )
- delay += 2;
- lengths[i] = delay;
- }
-
- for ( i=0; i<6; i++ )
- {
- r->combDelays[i] = (tDelay*) leaf_alloc(sizeof(tDelay));
- tDelay_init(r->combDelays[i], lengths[i], lengths[i] * 2.0f);
- r->combCoeffs[i] = pow(10.0, (-3 * lengths[i] * leaf.invSampleRate / t60));
- }
-
- for ( i=0; i<8; i++ )
- {
- r->allpassDelays[i] = (tDelay*) leaf_alloc(sizeof(tDelay));
- tDelay_init(r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2.0f);
- }
-
- for ( i=0; i<2; i++ )
- {
- tDelay_setDelay(r->allpassDelays[i], lengths[i]);
- tDelay_setDelay(r->combDelays[i], lengths[i+2]);
- }
-
- tNRev_setT60(r, t60);
- r->allpassCoeff = 0.7f;
- r->mix = 0.3f;
-}
-
-void tNRev_free(tNRev* const r)
-{
- for (int i = 0; i < 6; i++)
- {
- tDelay_free(r->combDelays[i]);
- }
-
- for (int i = 0; i < 8; i++)
- {
- tDelay_free(r->allpassDelays[i]);
- }
-
- leaf_free(r);
-}
-
-void tNRev_setT60(tNRev* const r, float t60)
-{
- if (t60 <= 0.0f) t60 = 0.001f;
-
- r->t60 = t60;
-
- for (int i=0; i<6; i++) r->combCoeffs[i] = pow(10.0, (-3.0 * tDelay_getDelay(r->combDelays[i]) * leaf.invSampleRate / t60 ));
-
-}
-
-void tNRev_setMix(tNRev* const r, float mix)
-{
- r->mix = mix;
-}
-
-float tNRev_tick(tNRev* const r, float input)
-{
- r->lastIn = input;
-
- float temp, temp0, temp1, temp2, out;
- int i;
-
- temp0 = 0.0;
- for ( i=0; i<6; i++ )
- {
- temp = input + (r->combCoeffs[i] * tDelay_getLastOut(r->combDelays[i]));
- temp0 += tDelay_tick(r->combDelays[i],temp);
- }
-
- for ( i=0; i<3; i++ )
- {
- temp = tDelay_getLastOut(r->allpassDelays[i]);
- temp1 = r->allpassCoeff * temp;
- temp1 += temp0;
- tDelay_tick(r->allpassDelays[i], temp1);
- temp0 = -(r->allpassCoeff * temp1) + temp;
- }
-
- // One-pole lowpass filter.
- r->lowpassState = 0.7f * r->lowpassState + 0.3f * temp0;
- temp = tDelay_getLastOut(r->allpassDelays[3]);
- temp1 = r->allpassCoeff * temp;
- temp1 += r->lowpassState;
- tDelay_tick(r->allpassDelays[3], temp1 );
- temp1 = -(r->allpassCoeff * temp1) + temp;
-
- temp = tDelay_getLastOut(r->allpassDelays[4]);
- temp2 = r->allpassCoeff * temp;
- temp2 += temp1;
- tDelay_tick(r->allpassDelays[4], temp2 );
- out = r->mix * ( -( r->allpassCoeff * temp2 ) + temp );
-
- /*
- temp = tDelayLGetLastOut(&r->allpassDelays[5]);
- temp3 = r->allpassCoeff * temp;
- temp3 += temp1;
- tDelayLTick(&r->allpassDelays[5], temp3 );
- lastFrame_[1] = effectMix_*( - ( r->allpassCoeff * temp3 ) + temp );
- */
-
- temp = ( 1.0f - r->mix ) * input;
-
- out += temp;
-
- r->lastOut = out;
-
- return out;
-}
-
-void tNRevSampleRateChanged (tNRev* const r)
-{
- for (int i=0; i<6; i++) r->combCoeffs[i] = pow(10.0, (-3.0 * tDelay_getDelay(r->combDelays[i]) * leaf.invSampleRate / r->t60 ));
-}
-
-// ======================================DATTORRO=========================================
-
-#define SAMP(in) (in*r->t)
-
-float in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f };
-float in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f };
-
-void tDattorro_init (tDattorro* const r)
-{
- tDattorro_setSize(r, 1.0f);
-
- // INPUT
- tDelayL_init(&r->in_delay, 0.f, SAMP(200.f));
- tOnePole_init(&r->in_filter, 1.f);
-
- for (int i = 0; i < 4; i++)
- {
- tAllpass_init(&r->in_allpass[i], in_allpass_delays[i], SAMP(20.f));
- tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
- }
-
- // FEEDBACK 1
- tAllpass_init(&r->f1_allpass, SAMP(30.51f), SAMP(100.f));
- tAllpass_setGain(&r->f1_allpass, 0.7f);
-
- tDelayL_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f));
- tDelayL_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f));
- tDelayL_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f));
-
- tOnePole_init(&r->f1_filter, 1.f);
-
- tCycle_init(&r->f1_lfo);
- tCycle_setFreq(&r->f1_lfo, 0.1f);
-
- // FEEDBACK 2
- tAllpass_init(&r->f2_allpass, SAMP(22.58f), SAMP(100.f));
- tAllpass_setGain(&r->f2_allpass, 0.7f);
-
- tDelayL_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.0f));
- tDelayL_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.0f));
- tDelayL_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.0f));
-
- tOnePole_init(&r->f2_filter, 1.f);
-
- tCycle_init(&r->f2_lfo);
- tCycle_setFreq(&r->f2_lfo, 0.07f);
-
-
- // PARAMETERS
- tDattorro_setMix(r, 0.5f);
-
- tDattorro_setInputDelay(r, 0.f);
-
- tDattorro_setInputFilter(r, 10000.f);
-
- tDattorro_setFeedbackFilter(r, 5000.f);
-
- tDattorro_setFeedbackGain(r, 0.4f);
-}
-
-void tDattorro_free (tDattorro* const r)
-{
- // INPUT
- tDelayL_free(&r->in_delay);
- tOnePole_free(&r->in_filter);
-
- for (int i = 0; i < 4; i++)
- {
- tAllpass_free(&r->in_allpass[i]);
- }
-
- // FEEDBACK 1
- tAllpass_free(&r->f1_allpass);
-
- tDelayL_free(&r->f1_delay_1);
- tDelayL_free(&r->f1_delay_2);
- tDelayL_free(&r->f1_delay_3);
-
- tOnePole_free(&r->f1_filter);
-
- tCycle_free(&r->f1_lfo);
-
- // FEEDBACK 2
- tAllpass_free(&r->f2_allpass);
-
- tDelayL_free(&r->f2_delay_1);
- tDelayL_free(&r->f2_delay_2);
- tDelayL_free(&r->f2_delay_3);
-
- tOnePole_free(&r->f2_filter);
-
- tCycle_free(&r->f2_lfo);
-
- leaf_free(r);
-}
-
-float tDattorro_tick (tDattorro* const r, float input)
-{
- // INPUT
- float in_sample = tDelayL_tick(&r->in_delay, input);
-
- in_sample = tOnePole_tick(&r->in_filter, in_sample);
-
- for (int i = 0; i < 4; i++)
- {
- in_sample = tAllpass_tick(&r->in_allpass[i], in_sample);
- }
-
- // FEEDBACK 1
- float f1_sample = in_sample + r->f2_last; // + f2_last_out;
-
- tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f));
-
- f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
-
- f1_sample = tDelayL_tick(&r->f1_delay_1, f1_sample);
-
- f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
-
- f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
-
- float f1_delay_2_sample = tDelayL_tick(&r->f1_delay_2, f1_sample * 0.5f);
-
- r->f1_delay_2_last = f1_delay_2_sample;
-
- f1_sample = r->f1_delay_2_last + f1_sample;
-
- f1_sample *= r->feedback_gain;
-
- r->f1_last = tDelayL_tick(&r->f1_delay_3, f1_sample);
-
- // FEEDBACK 2
- float f2_sample = in_sample + r->f1_last;
-
- tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f));
-
- f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
-
- f2_sample = tDelayL_tick(&r->f2_delay_1, f2_sample);
-
- f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
-
- f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
-
- float f2_delay_2_sample = tDelayL_tick(&r->f2_delay_2, f2_sample * 0.5f);
-
- r->f2_delay_2_last = f2_delay_2_sample;
-
- f2_sample = r->f2_delay_2_last + f2_sample;
-
- f2_sample *= r->feedback_gain;
-
- r->f2_last = tDelayL_tick(&r->f2_delay_3, f2_sample);
-
-
- // TAP OUT 1
- f1_sample = tDelayL_tapOut(&r->f1_delay_1, SAMP(8.9f)) +
- tDelayL_tapOut(&r->f1_delay_1, SAMP(99.8f));
-
- f1_sample -= tDelayL_tapOut(&r->f1_delay_2, SAMP(64.2f));
-
- f1_sample += tDelayL_tapOut(&r->f1_delay_3, SAMP(67.f));
-
- f1_sample -= tDelayL_tapOut(&r->f2_delay_1, SAMP(66.8f));
-
- f1_sample -= tDelayL_tapOut(&r->f2_delay_2, SAMP(6.3f));
-
- f1_sample -= tDelayL_tapOut(&r->f2_delay_3, SAMP(35.8f));
-
- f1_sample *= 0.14f;
-
- // TAP OUT 2
- f2_sample = tDelayL_tapOut(&r->f2_delay_1, SAMP(11.8f)) +
- tDelayL_tapOut(&r->f2_delay_1, SAMP(121.7f));
-
- f2_sample -= tDelayL_tapOut(&r->f2_delay_2, SAMP(6.3f));
-
- f2_sample += tDelayL_tapOut(&r->f2_delay_3, SAMP(89.7f));
-
- f2_sample -= tDelayL_tapOut(&r->f1_delay_1, SAM