History

new hihat features, FM, harmonic stretch, if FM gets removed then pitch calculation wouldnt need to be happening inside tick, so if we get rid of it later we should move pitch calculation back into the set freq routine

Jeff Snyder committed 7 years ago

Commit ba8d0691 parent d958b112 files · +44 −17Browse files

Unified · Split

2 files
  1. LEAF/Inc/leaf-808.h +7 −2
  2. LEAF/Src/leaf-808.c +37 −15
LEAF/Inc/leaf-808.h+7−2
@@ -58,9 +58,13 @@ typedef struct _t808Hihat { · 57 unmodified lines
5858 tSVF bandpassStick;
5959 tEnvelope envGain;
6060 tEnvelope envStick;
61+ tEnvelope noiseFMGain;
6162 tHighpass highpass;
6263 tNoise stick;
63−
64+
65+ float freq;
66+ float stretch;
67+ float FM_amount;
6468 float oscNoiseMix;
6569
6670 } t808Hihat;
@@ -77,7 +81,8 @@ void t808Hihat_setOscBandpassFreq (t808Hihat* const, float freq); · 10 unmodified lines
7781 void t808Hihat_setOscBandpassQ (t808Hihat* const hihat, float Q);
7882 void t808Hihat_setStickBandPassFreq (t808Hihat* const, float freq);
7983 void t808Hihat_setOscFreq (t808Hihat* const, float freq);
80−
84+void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);
85+void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);
8186
8287 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
8388
LEAF/Src/leaf-808.c+37−15
@@ -108,6 +108,7 @@ void t808Cowbell_init(t808Cowbell* const cowbell) { · 107 unmodified lines
108108 void t808Hihat_on(t808Hihat* const hihat, float vel) {
109109
110110 tEnvelope_on(&hihat->envGain, vel);
111+ tEnvelope_on(&hihat->noiseFMGain, vel);
111112 tEnvelope_on(&hihat->envStick, vel);
112113
113114 }
@@ -123,6 +124,18 @@ float t808Hihat_tick(t808Hihat* const hihat) { · 9 unmodified lines
123124 float sample = 0.0f;
124125 float gainScale = 0.3f;
125126
127+
128+ float myNoise = tNoise_tick(&hihat->n);
129+ //float FM_Noise = myNoise * tEnvelope_tick(&hihat->noiseFMGain);
130+ float FM_Noise = myNoise;
131+ //FM the hat with the noise
132+ tSquare_setFreq(&hihat->p[0], (2.0f * hihat->freq + hihat->stretch) + (FM_Noise * hihat->FM_amount));
133+ tSquare_setFreq(&hihat->p[1], (3.00f * hihat->freq + hihat->stretch) + (FM_Noise * hihat->FM_amount));
134+ tSquare_setFreq(&hihat->p[2], (4.16f * hihat->freq + hihat->stretch) + (FM_Noise * hihat->FM_amount));
135+ tSquare_setFreq(&hihat->p[3], (5.43f * hihat->freq + hihat->stretch) + (FM_Noise * hihat->FM_amount));
136+ tSquare_setFreq(&hihat->p[4], (6.79f * hihat->freq + hihat->stretch) + (FM_Noise * hihat->FM_amount));
137+ tSquare_setFreq(&hihat->p[5], (8.21f * hihat->freq + hihat->stretch) + (FM_Noise * hihat->FM_amount));
138+
126139 for (int i = 0; i < 6; i++)
127140 {
128141 sample += tSquare_tick(&hihat->p[i]);
@@ -130,7 +143,7 @@ float t808Hihat_tick(t808Hihat* const hihat) { · 1 unmodified line
130143
131144 sample *= gainScale;
132145
133− sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * (tNoise_tick(&hihat->n)));
146+ sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * myNoise);
134147
135148 sample = tSVF_tick(&hihat->bandpassOsc, sample);
136149
@@ -138,13 +151,14 @@ float t808Hihat_tick(t808Hihat* const hihat) { · 1 unmodified line
138151 sample *= (myGain*myGain);//square the output gain envelope
139152 sample = tHighpass_tick(&hihat->highpass, sample);
140153 sample += ((0.5f * tEnvelope_tick(&hihat->envStick)) * tSVF_tick(&hihat->bandpassStick, tNoise_tick(&hihat->stick)));
141−
154+ sample = tanhf(sample * 2.0f);
142155 return sample;
143156 }
144157
145158 void t808Hihat_setDecay(t808Hihat* const hihat, float decay)
146159 {
147160 tEnvelope_setDecay(&hihat->envGain,decay);
161+ tEnvelope_setDecay(&hihat->noiseFMGain,decay);
148162 }
149163
150164 void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq)
@@ -152,6 +166,16 @@ void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq) · 1 unmodified line
152166 tHighpass_setFreq(&hihat->highpass,freq);
153167 }
154168
169+void t808Hihat_setStretch(t808Hihat* const hihat, float stretch)
170+{
171+ hihat->stretch = stretch;
172+}
173+
174+void t808Hihat_setFM(t808Hihat* const hihat, float FM_amount)
175+{
176+ hihat->FM_amount = FM_amount;
177+}
178+
155179 void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, float freq)
156180 {
157181 tSVF_setFreq(&hihat->bandpassOsc,freq);
@@ -170,12 +194,7 @@ void t808Hihat_setStickBandPassFreq(t808Hihat* const hihat, float freq) · 12 unmodified lines
170194
171195 void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq)
172196 {
173− tSquare_setFreq(&hihat->p[0], 2.0f * freq);
174− tSquare_setFreq(&hihat->p[1], 3.00f * freq);
175− tSquare_setFreq(&hihat->p[2], 4.16f * freq);
176− tSquare_setFreq(&hihat->p[3], 5.43f * freq);
177− tSquare_setFreq(&hihat->p[4], 6.79f * freq);
178− tSquare_setFreq(&hihat->p[5], 8.21f * freq);
197+ hihat->freq = freq;
179198 }
180199
181200 void t808Hihat_init(t808Hihat* const hihat)
@@ -193,18 +212,21 @@ void t808Hihat_init(t808Hihat* const hihat) · 11 unmodified lines
193212 tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500,0.3f);
194213
195214 tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
215+ tEnvelope_init(&hihat->noiseFMGain, 0.0f, 500.0f, OFALSE);
196216 tEnvelope_init(&hihat->envStick, 0.0f, 4.0f, OFALSE);
197217
198218 tHighpass_init(&hihat->highpass, 7000.0f);
199219
200− float freq = 40.0f;
220+ hihat->freq = 40.0f;
221+ hihat->stretch = 0.0f;
222+ hihat->FM_amount = 1000.0f;
201223
202− tSquare_setFreq(&hihat->p[0], 2.0f * freq);
203− tSquare_setFreq(&hihat->p[1], 3.00f * freq);
204− tSquare_setFreq(&hihat->p[2], 4.16f * freq);
205− tSquare_setFreq(&hihat->p[3], 5.43f * freq);
206− tSquare_setFreq(&hihat->p[4], 6.79f * freq);
207− tSquare_setFreq(&hihat->p[5], 8.21f * freq);
224+ tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
225+ tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
226+ tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
227+ tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
228+ tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
229+ tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
208230 }
209231
210232 void t808Snare_on(t808Snare* const snare, float vel)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t