shithub: leaf

Download patch

ref: c27e1979bdab14b50ad69a799bbe5028fb3557c3
parent: c019bb2937d6be9c014dc8738281a65d22be2f79
author: mulshine <mulshine@princeton.edu>
date: Mon Jan 7 06:41:22 EST 2019

Fixed conflict with merge.

binary files a/.DS_Store b/.DS_Store differ
--- a/LEAF/Inc_cpp/leaf-808.hpp
+++ b/LEAF/Inc_cpp/leaf-808.hpp
@@ -58,9 +58,13 @@
     tSVF bandpassStick;
     tEnvelope envGain;
     tEnvelope envStick;
+    tEnvelope noiseFMGain;
     tHighpass highpass;
     tNoise stick;
-    
+
+    float freq;
+    float stretch;
+    float FM_amount;
     float oscNoiseMix;
     
 } t808Hihat;
@@ -73,10 +77,13 @@
 void        t808Hihat_setOscNoiseMix     (t808Hihat* const, float oscNoiseMix);
 void        t808Hihat_setDecay           (t808Hihat* const, float decay);
 void        t808Hihat_setHighpassFreq    (t808Hihat* const, float freq);
-void        t808Hihat_etOscBandpassFreq  (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
@@ -118,6 +125,46 @@
 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-math.hpp
+++ b/LEAF/Inc_cpp/leaf-math.hpp
@@ -77,12 +77,7 @@
 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);
-
-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);
+float       LEAF_midiToFrequency    (float f);
 
 // dope af
 float LEAF_chebyshevT(float in, int n);
--- a/LEAF/Inc_cpp/leaf-oscillator.hpp
+++ b/LEAF/Inc_cpp/leaf-oscillator.hpp
@@ -17,16 +17,6 @@
 #include "leaf-math.h"
 
 #include "leaf-filter.h"
-
-/*
-extern const float* sinewave;
-
-extern const float* sawtooth[11];
-
-extern const float* triangle[11];
-
-extern const float* squarewave[11];
- */
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
@@ -96,9 +86,7 @@
     // Underlying phasor
     float phase;
     float inc,freq;
-    
-    int tsize;
-    float* table;
+    
 } tCycle;
 
 void        tCycle_init         (tCycle*  const);
@@ -105,8 +93,7 @@
 void        tCycle_free         (tCycle*  const);
 
 float       tCycle_tick         (tCycle*  const);
-int         tCycle_setFreq      (tCycle*  const, float freq);
-void        tCycle_setTableSize (tCycle*  const c, int size);
+int         tCycle_setFreq      (tCycle*  const, float freq);
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
@@ -115,20 +102,15 @@
 {
     // Underlying phasor
     float phase;
-    float inc,freq;
-    
-    int tsize;
-    
-    float* table[NUM_TABLES];
+    float inc,freq;
     
 } tSawtooth;
 
-void        tSawtooth_init          (tSawtooth*  const);
-void        tSawtooth_free          (tSawtooth*  const);
+void        tSawtooth_init      (tSawtooth*  const);
+void        tSawtooth_free      (tSawtooth*  const);
 
-float       tSawtooth_tick          (tSawtooth*  const);
-int         tSawtooth_setFreq       (tSawtooth*  const, float freq);
-void        tSawtooth_setTableSize  (tSawtooth*  const c, int size);
+float       tSawtooth_tick      (tSawtooth*  const);
+int         tSawtooth_setFreq   (tSawtooth*  const, float freq);
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
@@ -137,20 +119,15 @@
 {
     // Underlying phasor
     float phase;
-    float inc,freq;
-    
-    int tsize;
-    
-    float* table[NUM_TABLES];
+    float inc,freq;
     
 } tTriangle;
 
-void        tTriangle_init          (tTriangle*  const);
-void        tTriangle_free          (tTriangle*  const);
+void        tTriangle_init      (tTriangle*  const);
+void        tTriangle_free      (tTriangle*  const);
 
-float       tTriangle_tick          (tTriangle*  const);
-int         tTriangle_setFreq       (tTriangle*  const, float freq);
-void        tTriangle_setTableSize  (tTriangle*  const c, int size);
+float       tTriangle_tick      (tTriangle*  const);
+int         tTriangle_setFreq   (tTriangle*  const, float freq);
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
@@ -159,20 +136,15 @@
 {
     // Underlying phasor
     float phase;
-    float inc,freq;
-    
-    int tsize;
-    
-    float* table[NUM_TABLES];
+    float inc,freq;
     
 } tSquare;
 
-void        tSquare_init            (tSquare*  const);
-void        tSquare_free            (tSquare*  const);
+void        tSquare_init        (tSquare*  const);
+void        tSquare_free        (tSquare*  const);
 
-float       tSquare_tick            (tSquare*  const);
-int         tSquare_setFreq         (tSquare*  const, float freq);
-void        tSquare_setTableSize    (tSquare*  const c, int size);
+float       tSquare_tick        (tSquare*  const);
+int         tSquare_setFreq     (tSquare*  const, float freq);
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
--- a/LEAF/Inc_cpp/leaf-wavetables.hpp
+++ b/LEAF/Inc_cpp/leaf-wavetables.hpp
@@ -43,7 +43,7 @@
     T5120,
     T10240,
     T20480,
-    NUM_TABLES
+    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)
@@ -57,6 +57,17 @@
 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];
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
--- a/LEAF/Src/leaf-808.c
+++ b/LEAF/Src/leaf-808.c
@@ -193,7 +193,6 @@
 void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq)
 {
 		hihat->freq = freq;
-
 }
 
 void t808Hihat_init(t808Hihat* const hihat)
--- a/LEAF/Src/leaf-oscillator.c
+++ b/LEAF/Src/leaf-oscillator.c
@@ -328,7 +328,7 @@
     float out = 0.0f;
     float w;
     
-    int idx = (int)(c->phase * SAW_TABLE_SIZE);
+    int idx = (int)(c->phase * TRI_TABLE_SIZE);
     
     // Wavetable synthesis
     
@@ -386,7 +386,7 @@
         w = ((20480.0f - c->freq) * INV_10240);
         out = (sawtooth[T10240][idx] * w) + (sawtooth[T20480][idx] * (1.0f - w));
     }
-    else if (c->freq <= 24000.0f)
+    else
     {
         out = sawtooth[T20480][idx];
     }
@@ -493,7 +493,7 @@
         w = ((20480.0f - c->freq) * INV_10240);
         out = (triangle[T10240][idx] * w) + (triangle[T20480][idx] * (1.0f - w));
     }
-    else if (c->freq <= 24000.0f)
+    else
     {
         out = triangle[T20480][idx];
     }
@@ -536,7 +536,7 @@
     
     float out = 0.0f;
     float w = 0.0f;
-    int idx = (int)(c->phase * SQR_TABLE_SIZE);
+    int idx = (int)(c->phase * TRI_TABLE_SIZE);
     
     // Wavetable synthesis
     
@@ -594,7 +594,7 @@
         w = ((20480.0f - c->freq) * INV_10240);
         out = (squarewave[T10240][idx] * w) + (squarewave[T20480][idx] * (1.0f - w));
     }
-    else if (c->freq <= 24000.0f)
+    else
     {
         out = squarewave[T20480][idx];
     }
--- a/LEAF/Src/leaf-reverb.c
+++ b/LEAF/Src/leaf-reverb.c
@@ -264,16 +264,6 @@
 
 void    tDattorro_init              (tDattorro* const r)
 {
-    tDattorro_setMix(r, 0.5f);
-    
-    tDattorro_setInputDelay(r,  5.f);
-    
-    tDattorro_setInputFilter(r, 1000.f);
-    
-    tDattorro_setFeedbackFilter(r, 1000.f);
-    
-    tDattorro_setFeedbackGain(r, 0.25f);
-    
     tDattorro_setSize(r, 1.0f);
     
     // INPUT
@@ -311,6 +301,18 @@
     
     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)
--- a/LEAF/Src_cpp/leaf-reverb.cpp
+++ b/LEAF/Src_cpp/leaf-reverb.cpp
@@ -264,16 +264,6 @@
 
 void    tDattorro_init              (tDattorro* const r)
 {
-    tDattorro_setMix(r, 0.5f);
-    
-    tDattorro_setInputDelay(r,  5.f);
-    
-    tDattorro_setInputFilter(r, 1000.f);
-    
-    tDattorro_setFeedbackFilter(r, 1000.f);
-    
-    tDattorro_setFeedbackGain(r, 0.25f);
-    
     tDattorro_setSize(r, 1.0f);
     
     // INPUT
@@ -311,6 +301,18 @@
     
     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)