shithub: leaf

ref: f0a1204dfb90feef80d99c1fbb0458d3748ef9ec
dir: /LEAF/Inc_cpp/leaf-808.hpp/

View raw version
/*
  ==============================================================================

    leaf_808.h
    Created: 30 Nov 2018 10:24:44am
    Author:  airship

  ==============================================================================
*/

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

#include "leaf-globals.h"
#include "leaf-math.h"

#include "leaf-oscillator.h"
#include "leaf-utilities.h"
#include "leaf-filter.h"

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

// 808 Cowbell
typedef struct _t808Cowbell {
    
    tSquare p[2];
    tNoise stick;
    tSVF bandpassOsc;
    tSVF bandpassStick;
    tEnvelope envGain;
    tEnvelope envStick;
    tEnvelope envFilter;
    tHighpass highpass;
    float oscMix;
    float filterCutoff;
    
} t808Cowbell;

void    t808Cowbell_init             (t808Cowbell* const);
void    t808Cowbell_free             (t808Cowbell* const);
float   t808Cowbell_tick             (t808Cowbell* const);
void    t808Cowbell_on               (t808Cowbell* const, float vel);
void    t808Cowbell_setDecay         (t808Cowbell* const, float decay);
void    t808Cowbell_setHighpassFreq  (t808Cowbell* const, float freq);
void    t808Cowbell_setBandpassFreq  (t808Cowbell* const, float freq);
void    t808Cowbell_setFreq          (t808Cowbell* const, float freq);
void    t808Cowbell_setOscMix        (t808Cowbell* const, float oscMix);


// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

// 808 Hihat
typedef struct _t808Hihat {
    
    // 6 Square waves
    tSquare p[6];
    tNoise n;
    tSVF bandpassOsc;
    tSVF bandpassStick;
    tEnvelope envGain;
    tEnvelope envStick;
    tHighpass highpass;
    tNoise stick;
    
    float oscNoiseMix;
    
} t808Hihat;

void        t808Hihat_init               (t808Hihat* const);
void        t808Hihat_free               (t808Hihat* const);

float       t808Hihat_tick               (t808Hihat* const);
void        t808Hihat_on                 (t808Hihat* const, float vel);
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_setOscFreq         (t808Hihat* const, float freq);


// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

// 808 Snare
typedef struct _t808Snare {
    
    // Tone 1, Tone 2, Noise
    tTriangle tone[2]; // Tri (not yet antialiased or wavetabled)
    tNoise noiseOsc;
    tSVF toneLowpass[2];
    tSVF noiseLowpass; // Lowpass from SVF filter
    tEnvelope toneEnvOsc[2];
    tEnvelope toneEnvGain[2];
    tEnvelope noiseEnvGain;
    tEnvelope toneEnvFilter[2];
    tEnvelope noiseEnvFilter;
    
    float toneGain[2];
    float noiseGain;
    
    float toneNoiseMix;
    
    float tone1Freq, tone2Freq;
    
    float noiseFilterFreq;
    
    
} t808Snare;

void        t808Snare_init                  (t808Snare* const);
void        t808Snare_free                  (t808Snare* const);

float       t808Snare_tick                  (t808Snare* const);
void        t808Snare_on                    (t808Snare* const, float vel);
void        t808Snare_setTone1Freq          (t808Snare* const, float freq);
void        t808Snare_setTone2Freq          (t808Snare* const, float freq);
void        t808Snare_setTone1Decay         (t808Snare* const, float decay);
void        t808Snare_setTone2Decay         (t808Snare* const, float decay);
void        t808Snare_setNoiseDecay         (t808Snare* const, float decay);
void        t808Snare_setToneNoiseMix       (t808Snare* const, float toneNoiseMix);
void        t808Snare_setNoiseFilterFreq    (t808Snare* const, float noiseFilterFreq);
void        t808Snare_setNoiseFilterQ       (t808Snare* const, float noiseFilterQ);

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~