#include "instr_bd2.hh" #include "daisysp.h" #include "utils.hh" namespace Heck { namespace Instrument { BD2::BD2() { init(); } void BD2::init() { bd2.Init(Constants::AUDIO_SAMPLERATE); bd2.SetDecay(1.); bd2.SetTone(0.4); bd2.SetAccent(1.); bd2.SetSustain(true); bd2.SetDirtiness(1.); } void BD2::trigger() { bd2.Trig(); } void BD2::ctl(unsigned int ctl_nr, float val) { switch (ctl_nr) { case 0: { bd2.SetFreq(scalen_min_max(val, 40, 180)); } break; case 1: { bd2.SetDecay(scalen_min_max(val,0,1)); } break; case 2: { bd2.SetFmEnvelopeAmount(scalen_min_max(val,0,1)); } break; case 3: { bd2.SetFmEnvelopeDecay(scalen_min_max(val,0,1)); } break; } } void BD2::switch_algo(unsigned int pos) { mode1 = pos; } void BD2::switch_mode(unsigned int pos) { mode2 = pos; } float BD2::nextsample() { float out{}; out = bd2.Process(); return out; } } // namespace Instrument } // namespace Heck