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
58 tSVF bandpassStick;58 tSVF bandpassStick;
59 tEnvelope envGain;59 tEnvelope envGain;
60 tEnvelope envStick;60 tEnvelope envStick;
61 tEnvelope noiseFMGain;
61 tHighpass highpass;62 tHighpass highpass;
62 tNoise stick;63 tNoise stick;
63 64
65 float freq;
66 float stretch;
67 float FM_amount;
64 float oscNoiseMix;68 float oscNoiseMix;
65 69
66} t808Hihat;70} t808Hihat;
@@ -77,7 +81,8 @@ void t808Hihat_setOscBandpassFreq (t808Hihat* const, float freq); · 10 unmodified lines
77void t808Hihat_setOscBandpassQ (t808Hihat* const hihat, float Q);81void t808Hihat_setOscBandpassQ (t808Hihat* const hihat, float Q);
78void t808Hihat_setStickBandPassFreq (t808Hihat* const, float freq);82void t808Hihat_setStickBandPassFreq (t808Hihat* const, float freq);
79void t808Hihat_setOscFreq (t808Hihat* const, float freq);83void t808Hihat_setOscFreq (t808Hihat* const, float freq);
80 84void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);
85void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);
81 86
82// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~87// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
83 88
LEAF/Src/leaf-808.c+37−15
@@ -108,6 +108,7 @@ void t808Cowbell_init(t808Cowbell* const cowbell) { · 107 unmodified lines
108void t808Hihat_on(t808Hihat* const hihat, float vel) {108void t808Hihat_on(t808Hihat* const hihat, float vel) {
109 109
110 tEnvelope_on(&hihat->envGain, vel);110 tEnvelope_on(&hihat->envGain, vel);
111 tEnvelope_on(&hihat->noiseFMGain, vel);
111 tEnvelope_on(&hihat->envStick, vel);112 tEnvelope_on(&hihat->envStick, vel);
112 113
113}114}
@@ -123,6 +124,18 @@ float t808Hihat_tick(t808Hihat* const hihat) { · 9 unmodified lines
123 float sample = 0.0f;124 float sample = 0.0f;
124 float gainScale = 0.3f;125 float gainScale = 0.3f;
125 126
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
126 for (int i = 0; i < 6; i++)139 for (int i = 0; i < 6; i++)
127 {140 {
128 sample += tSquare_tick(&hihat->p[i]);141 sample += tSquare_tick(&hihat->p[i]);
@@ -130,7 +143,7 @@ float t808Hihat_tick(t808Hihat* const hihat) { · 1 unmodified line
130 143
131 sample *= gainScale;144 sample *= gainScale;
132 145
133 sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * (tNoise_tick(&hihat->n)));146 sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * myNoise);
134 147
135 sample = tSVF_tick(&hihat->bandpassOsc, sample);148 sample = tSVF_tick(&hihat->bandpassOsc, sample);
136 149
@@ -138,13 +151,14 @@ float t808Hihat_tick(t808Hihat* const hihat) { · 1 unmodified line
138 sample *= (myGain*myGain);//square the output gain envelope151 sample *= (myGain*myGain);//square the output gain envelope
139 sample = tHighpass_tick(&hihat->highpass, sample);152 sample = tHighpass_tick(&hihat->highpass, sample);
140 sample += ((0.5f * tEnvelope_tick(&hihat->envStick)) * tSVF_tick(&hihat->bandpassStick, tNoise_tick(&hihat->stick)));153 sample += ((0.5f * tEnvelope_tick(&hihat->envStick)) * tSVF_tick(&hihat->bandpassStick, tNoise_tick(&hihat->stick)));
141 154 sample = tanhf(sample * 2.0f);
142 return sample;155 return sample;
143}156}
144 157
145void t808Hihat_setDecay(t808Hihat* const hihat, float decay)158void t808Hihat_setDecay(t808Hihat* const hihat, float decay)
146{159{
147 tEnvelope_setDecay(&hihat->envGain,decay);160 tEnvelope_setDecay(&hihat->envGain,decay);
161 tEnvelope_setDecay(&hihat->noiseFMGain,decay);
148}162}
149 163
150void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq)164void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq)
@@ -152,6 +166,16 @@ void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq) · 1 unmodified line
152 tHighpass_setFreq(&hihat->highpass,freq);166 tHighpass_setFreq(&hihat->highpass,freq);
153}167}
154 168
169void t808Hihat_setStretch(t808Hihat* const hihat, float stretch)
170{
171 hihat->stretch = stretch;
172}
173
174void t808Hihat_setFM(t808Hihat* const hihat, float FM_amount)
175{
176 hihat->FM_amount = FM_amount;
177}
178
155void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, float freq)179void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, float freq)
156{180{
157 tSVF_setFreq(&hihat->bandpassOsc,freq);181 tSVF_setFreq(&hihat->bandpassOsc,freq);
@@ -170,12 +194,7 @@ void t808Hihat_setStickBandPassFreq(t808Hihat* const hihat, float freq) · 12 unmodified lines
170 194
171void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq)195void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq)
172{196{
173 tSquare_setFreq(&hihat->p[0], 2.0f * freq);197 hihat->freq = 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);
179}198}
180 199
181void t808Hihat_init(t808Hihat* const hihat)200void t808Hihat_init(t808Hihat* const hihat)
@@ -193,18 +212,21 @@ void t808Hihat_init(t808Hihat* const hihat) · 11 unmodified lines
193 tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500,0.3f);212 tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500,0.3f);
194 213
195 tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);214 tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
215 tEnvelope_init(&hihat->noiseFMGain, 0.0f, 500.0f, OFALSE);
196 tEnvelope_init(&hihat->envStick, 0.0f, 4.0f, OFALSE);216 tEnvelope_init(&hihat->envStick, 0.0f, 4.0f, OFALSE);
197 217
198 tHighpass_init(&hihat->highpass, 7000.0f);218 tHighpass_init(&hihat->highpass, 7000.0f);
199 219
200 float freq = 40.0f;220 hihat->freq = 40.0f;
221 hihat->stretch = 0.0f;
222 hihat->FM_amount = 1000.0f;
201 223
202 tSquare_setFreq(&hihat->p[0], 2.0f * freq);224 tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
203 tSquare_setFreq(&hihat->p[1], 3.00f * freq);225 tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
204 tSquare_setFreq(&hihat->p[2], 4.16f * freq);226 tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
205 tSquare_setFreq(&hihat->p[3], 5.43f * freq);227 tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
206 tSquare_setFreq(&hihat->p[4], 6.79f * freq);228 tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
207 tSquare_setFreq(&hihat->p[5], 8.21f * freq);229 tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
208}230}
209 231
210void t808Snare_on(t808Snare* const snare, float vel)232void 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