leaf-instruments.h
1 /*==============================================================================
2 
3  leaf-instruments.h
4  Created: 30 Nov 2018 10:24:44am
5  Author: airship
6 
7  ==============================================================================*/
8 
9 #ifndef LEAF_INSTRUMENTS_H_INCLUDED
10 #define LEAF_INSTRUMENTS_H_INCLUDED
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16  //==============================================================================
17 
18 #include "leaf-math.h"
19 #include "leaf-mempool.h"
20 #include "leaf-oscillators.h"
21 #include "leaf-filters.h"
22 #include "leaf-envelopes.h"
23 
32  //==============================================================================
33 
88  typedef struct _t808Cowbell
89  {
90  tMempool mempool;
91  tSquare p[2];
92  tNoise stick;
93  tSVF bandpassOsc;
94  tSVF bandpassStick;
95  tEnvelope envGain;
96  tEnvelope envStick;
97  tEnvelope envFilter;
98  tHighpass highpass;
99  float oscMix;
100  float filterCutoff;
101  uint8_t useStick;
102  } _t808Cowbell;
103 
104  typedef _t808Cowbell* t808Cowbell;
105 
106  void t808Cowbell_init (t808Cowbell* const, int useStick, LEAF* const leaf);
107  void t808Cowbell_initToPool (t808Cowbell* const, int useStick, tMempool* const);
108  void t808Cowbell_free (t808Cowbell* const);
109 
110  float t808Cowbell_tick (t808Cowbell* const);
111  void t808Cowbell_on (t808Cowbell* const, float vel);
112  void t808Cowbell_setDecay (t808Cowbell* const, float decay);
113  void t808Cowbell_setHighpassFreq (t808Cowbell* const, float freq);
114  void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq);
115  void t808Cowbell_setFreq (t808Cowbell* const, float freq);
116  void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix);
117  void t808Cowbell_setStick (t808Cowbell* const, int useStick);
118 
119  //==============================================================================
120 
191  typedef struct _t808Hihat
192  {
193 
194  tMempool mempool;
195  // 6 Square waves
196  tSquare p[6];
197  tNoise n;
198  tSVF bandpassOsc;
199  tSVF bandpassStick;
200  tEnvelope envGain;
201  tEnvelope envStick;
202  tEnvelope noiseFMGain;
203  tHighpass highpass;
204  tNoise stick;
205 
206  float freq;
207  float stretch;
208  float FM_amount;
209  float oscNoiseMix;
210  } _t808Hihat;
211 
212  typedef _t808Hihat* t808Hihat;
213 
214  void t808Hihat_init (t808Hihat* const, LEAF* const leaf);
215  void t808Hihat_initToPool (t808Hihat* const, tMempool* const);
216  void t808Hihat_free (t808Hihat* const);
217 
218  float t808Hihat_tick (t808Hihat* const);
219  void t808Hihat_on (t808Hihat* const, float vel);
220  void t808Hihat_setOscNoiseMix (t808Hihat* const, float oscNoiseMix);
221  void t808Hihat_setDecay (t808Hihat* const, float decay);
222  void t808Hihat_setHighpassFreq (t808Hihat* const, float freq);
223  void t808Hihat_setOscBandpassFreq (t808Hihat* const, float freq);
224  void t808Hihat_setOscBandpassQ (t808Hihat* const hihat, float Q);
225  void t808Hihat_setStickBandPassFreq (t808Hihat* const, float freq);
226  void t808Hihat_setStickBandPassQ (t808Hihat* const hihat, float Q);
227  void t808Hihat_setOscFreq (t808Hihat* const, float freq);
228  void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);
229  void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);
230 
231  //==============================================================================
232 
295  typedef struct _t808Snare
296  {
297 
298  tMempool mempool;
299  // Tone 1, Tone 2, Noise
300  tTriangle tone[2]; // Tri (not yet antialiased or wavetabled)
301  tNoise noiseOsc;
302  tSVF toneLowpass[2];
303  tSVF noiseLowpass; // Lowpass from SVF filter
304  tEnvelope toneEnvOsc[2];
305  tEnvelope toneEnvGain[2];
306  tEnvelope noiseEnvGain;
307  tEnvelope toneEnvFilter[2];
308  tEnvelope noiseEnvFilter;
309 
310  float toneGain[2];
311  float noiseGain;
312 
313  float toneNoiseMix;
314 
315  float tone1Freq, tone2Freq;
316 
317  float noiseFilterFreq;
318  } _t808Snare;
319 
320  typedef _t808Snare* t808Snare;
321 
322  void t808Snare_init (t808Snare* const, LEAF* const leaf);
323  void t808Snare_initToPool (t808Snare* const, tMempool* const);
324  void t808Snare_free (t808Snare* const);
325 
326  float t808Snare_tick (t808Snare* const);
327  void t808Snare_on (t808Snare* const, float vel);
328  void t808Snare_setTone1Freq (t808Snare* const, float freq);
329  void t808Snare_setTone2Freq (t808Snare* const, float freq);
330  void t808Snare_setTone1Decay (t808Snare* const, float decay);
331  void t808Snare_setTone2Decay (t808Snare* const, float decay);
332  void t808Snare_setNoiseDecay (t808Snare* const, float decay);
333  void t808Snare_setToneNoiseMix (t808Snare* const, float toneNoiseMix);
334  void t808Snare_setNoiseFilterFreq (t808Snare* const, float noiseFilterFreq);
335  void t808Snare_setNoiseFilterQ (t808Snare* const, float noiseFilterQ);
336 
337  //==============================================================================
338 
401  typedef struct _t808Kick
402  {
403 
404  tMempool mempool;
405 
406  tCycle tone; // Tri
407  tNoise noiseOsc;
408  tSVF toneLowpass;
409  tEnvelope toneEnvOscChirp;
410  tEnvelope toneEnvOscSigh;
411  tEnvelope toneEnvGain;
412  tEnvelope noiseEnvGain;
413  tEnvelope toneEnvFilter;
414 
415  float toneGain;
416  float noiseGain;
417 
418  float toneInitialFreq;
419  float sighAmountInHz;
420  float chirpRatioMinusOne;
421  float noiseFilterFreq;
422  } _t808Kick;
423 
424  typedef _t808Kick* t808Kick;
425 
426  void t808Kick_init (t808Kick* const, LEAF* const leaf);
427  void t808Kick_initToPool (t808Kick* const, tMempool* const);
428  void t808Kick_free (t808Kick* const);
429 
430  float t808Kick_tick (t808Kick* const);
431  void t808Kick_on (t808Kick* const, float vel);
432  void t808Kick_setToneFreq (t808Kick* const, float freq);
433  void t808Kick_setToneDecay (t808Kick* const, float decay);
434  void t808Kick_setNoiseDecay (t808Kick* const, float decay);
435  void t808Kick_setSighAmount (t808Kick* const, float sigh);
436  void t808Kick_setChirpAmount (t808Kick* const, float chirp);
437  void t808Kick_setToneNoiseMix (t808Kick* const, float toneNoiseMix);
438  void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq);
439  void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);
440 
441  //==============================================================================
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 #endif // LEAF_INSTRUMENTS_H_INCLUDED
448 
449 //==============================================================================
450 
451 
452 
t808Hihat_on
void t808Hihat_on(t808Hihat *const, float vel)
Definition: leaf-instruments.c:209
t808Hihat_initToPool
void t808Hihat_initToPool(t808Hihat *const, tMempool *const)
Initialize a t808Hihat to a specified mempool.
Definition: leaf-instruments.c:151
t808Snare_setTone1Decay
void t808Snare_setTone1Decay(t808Snare *const, float decay)
Definition: leaf-instruments.c:399
t808Hihat_setOscFreq
void t808Hihat_setOscFreq(t808Hihat *const, float freq)
Definition: leaf-instruments.c:306
t808Kick_setNoiseDecay
void t808Kick_setNoiseDecay(t808Kick *const, float decay)
t808Hihat_setStretch
void t808Hihat_setStretch(t808Hihat *const hihat, float stretch)
Definition: leaf-instruments.c:270
t808Cowbell_setOscMix
void t808Cowbell_setOscMix(t808Cowbell *const, float oscMix)
Definition: leaf-instruments.c:132
t808Cowbell_setBandpassFreq
void t808Cowbell_setBandpassFreq(t808Cowbell *const, float freq)
Definition: leaf-instruments.c:119
t808Kick_setNoiseFilterFreq
void t808Kick_setNoiseFilterFreq(t808Kick *const, float noiseFilterFreq)
t808Kick_on
void t808Kick_on(t808Kick *const, float vel)
Definition: leaf-instruments.c:513
t808Kick_free
void t808Kick_free(t808Kick *const)
Free a t808Kick from its mempool.
Definition: leaf-instruments.c:486
t808Kick_initToPool
void t808Kick_initToPool(t808Kick *const, tMempool *const)
Initialize a t808Kick to a specified mempool.
Definition: leaf-instruments.c:466
t808Hihat_setOscNoiseMix
void t808Hihat_setOscNoiseMix(t808Hihat *const, float oscNoiseMix)
Definition: leaf-instruments.c:216
t808Hihat_setStickBandPassQ
void t808Hihat_setStickBandPassQ(t808Hihat *const hihat, float Q)
Definition: leaf-instruments.c:300
t808Kick_setToneNoiseMix
void t808Kick_setToneNoiseMix(t808Kick *const, float toneNoiseMix)
t808Hihat_free
void t808Hihat_free(t808Hihat *const)
Free a t808Hihat from its mempool.
Definition: leaf-instruments.c:186
t808Cowbell_setFreq
void t808Cowbell_setFreq(t808Cowbell *const, float freq)
Definition: leaf-instruments.c:125
t808Snare_setNoiseDecay
void t808Snare_setNoiseDecay(t808Snare *const, float decay)
Definition: leaf-instruments.c:411
t808Snare_setToneNoiseMix
void t808Snare_setToneNoiseMix(t808Snare *const, float toneNoiseMix)
Definition: leaf-instruments.c:417
t808Hihat_tick
float t808Hihat_tick(t808Hihat *const)
Definition: leaf-instruments.c:222
t808Snare_setTone2Decay
void t808Snare_setTone2Decay(t808Snare *const, float decay)
Definition: leaf-instruments.c:405
t808Hihat_setOscBandpassQ
void t808Hihat_setOscBandpassQ(t808Hihat *const hihat, float Q)
Definition: leaf-instruments.c:288
t808Kick_init
void t808Kick_init(t808Kick *const, LEAF *const leaf)
Initialize a t808Kick to the default mempool of a LEAF instance.
Definition: leaf-instruments.c:461
t808Kick_setChirpAmount
void t808Kick_setChirpAmount(t808Kick *const, float chirp)
t808Hihat_setOscBandpassFreq
void t808Hihat_setOscBandpassFreq(t808Hihat *const, float freq)
Definition: leaf-instruments.c:282
t808Cowbell_setStick
void t808Cowbell_setStick(t808Cowbell *const, int useStick)
Definition: leaf-instruments.c:138
t808Snare_setTone1Freq
void t808Snare_setTone1Freq(t808Snare *const, float freq)
Definition: leaf-instruments.c:385
t808Snare_initToPool
void t808Snare_initToPool(t808Snare *const, tMempool *const)
Initialize a t808Snare to a specified mempool.
Definition: leaf-instruments.c:319
t808Hihat_init
void t808Hihat_init(t808Hihat *const, LEAF *const leaf)
Initialize a t808Hihat to the default mempool of a LEAF instance.
Definition: leaf-instruments.c:146
t808Kick_setToneFreq
void t808Kick_setToneFreq(t808Kick *const, float freq)
Definition: leaf-instruments.c:522
t808Cowbell_setHighpassFreq
void t808Cowbell_setHighpassFreq(t808Cowbell *const, float freq)
Definition: leaf-instruments.c:113
t808Hihat_setFM
void t808Hihat_setFM(t808Hihat *const hihat, float FM_amount)
Definition: leaf-instruments.c:276
t808Cowbell_initToPool
void t808Cowbell_initToPool(t808Cowbell *const, int useStick, tMempool *const)
Initialize a t808Cowbell to a specified mempool.
Definition: leaf-instruments.c:26
t808Cowbell_tick
float t808Cowbell_tick(t808Cowbell *const)
Definition: leaf-instruments.c:83
t808Snare_setNoiseFilterFreq
void t808Snare_setNoiseFilterFreq(t808Snare *const, float noiseFilterFreq)
Definition: leaf-instruments.c:423
t808Cowbell_on
void t808Cowbell_on(t808Cowbell *const, float vel)
Definition: leaf-instruments.c:73
t808Cowbell_init
void t808Cowbell_init(t808Cowbell *const, int useStick, LEAF *const leaf)
Initialize a t808Cowbell to the default mempool of a LEAF instance.
Definition: leaf-instruments.c:21
t808Cowbell_free
void t808Cowbell_free(t808Cowbell *const)
Free a t808Cowbell from its mempool.
Definition: leaf-instruments.c:57
t808Snare_free
void t808Snare_free(t808Snare *const)
Free a t808Snare from its mempool.
Definition: leaf-instruments.c:349
t808Kick_setToneDecay
void t808Kick_setToneDecay(t808Kick *const, float decay)
Definition: leaf-instruments.c:529
t808Kick_setSighAmount
void t808Kick_setSighAmount(t808Kick *const, float sigh)
t808Hihat_setStickBandPassFreq
void t808Hihat_setStickBandPassFreq(t808Hihat *const, float freq)
Definition: leaf-instruments.c:294
t808Snare_setNoiseFilterQ
void t808Snare_setNoiseFilterQ(t808Snare *const, float noiseFilterQ)
Definition: leaf-instruments.c:429
t808Snare_init
void t808Snare_init(t808Snare *const, LEAF *const leaf)
Initialize a t808Snare to the default mempool of a LEAF instance.
Definition: leaf-instruments.c:314
t808Kick_tick
float t808Kick_tick(t808Kick *const)
Definition: leaf-instruments.c:501
t808Snare_setTone2Freq
void t808Snare_setTone2Freq(t808Snare *const, float freq)
Definition: leaf-instruments.c:392
t808Snare_on
void t808Snare_on(t808Snare *const, float vel)
Definition: leaf-instruments.c:370
t808Hihat_setDecay
void t808Hihat_setDecay(t808Hihat *const, float decay)
Definition: leaf-instruments.c:258
LEAF
Struct for an instance of LEAF.
Definition: leaf-global.h:31
t808Cowbell_setDecay
void t808Cowbell_setDecay(t808Cowbell *const, float decay)
Definition: leaf-instruments.c:107
t808Kick_setNoiseFilterQ
void t808Kick_setNoiseFilterQ(t808Kick *const, float noiseFilterQ)
t808Snare_tick
float t808Snare_tick(t808Snare *const)
Definition: leaf-instruments.c:437
t808Hihat_setHighpassFreq
void t808Hihat_setHighpassFreq(t808Hihat *const, float freq)
Definition: leaf-instruments.c:264