| @@ -108,6 +108,7 @@ void t808Cowbell_init(t808Cowbell* const cowbell) { · 107 unmodified lines |
| 108 | void t808Hihat_on(t808Hihat* const hihat, float vel) { | 108 | void 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 envelope | 151 | 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 | |
| 145 | void t808Hihat_setDecay(t808Hihat* const hihat, float decay) | 158 | void 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 | |
| 150 | void t808Hihat_setHighpassFreq(t808Hihat* const hihat, float freq) | 164 | void 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 | |
| | 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 | |
| 155 | void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, float freq) | 179 | void 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 | |
| 171 | void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq) | 195 | void 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 | |
| 181 | void t808Hihat_init(t808Hihat* const hihat) | 200 | void 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 | |
| 210 | void t808Snare_on(t808Snare* const snare, float vel) | 232 | void t808Snare_on(t808Snare* const snare, float vel) |