#include "instr_kick.hh" #include "daisysp.h" #include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { Kick::Kick() { init(); } void Kick::init() { osc.Init(Constants::AUDIO_SAMPLERATE); osc.SetWaveform(dsp::Oscillator::WAVE_TRI); osc.SetAmp(1); pitchEnv.Init(Constants::AUDIO_SAMPLERATE); pitchEnv.SetTime(dsp::ADENV_SEG_ATTACK, .001); pitchEnv.SetTime(dsp::ADENV_SEG_DECAY, .01); chorus.Init(Constants::AUDIO_SAMPLERATE); chorus.SetDelay(0.2); chorus.SetFeedback(0.8); chorus.SetLfoDepth(0.2); chorus.SetLfoFreq(7); } void Kick::trigger() { osc.Reset(); // volEnv.Trigger(); pitchEnv.Trigger(); } void Kick::ctl(unsigned int ctl_nr, float val) { switch (ctl_nr) { case 0: { float relpitch = dz::scalen_min_max(val, 40, 400); osc.SetFreq(relpitch); pitchEnv.SetMax(relpitch * 0.03); pitchEnv.SetMin(relpitch); } break; case 1: { // pitchEnv.SetTime(dsp::ADSR_SEG_DECAY, dz::scalen_min_max(val, 0.01, 0.4)); } break; case 2: { osc.SetPw(dz::scalen_min_max(val, 0, 1)); } break; case 3: { chorus.SetDelay(dz::scalen_min_max(val, 0.1, 0.9)); } break; } } void Kick::switch_algo(unsigned int pos) { mode1 = pos; } void Kick::switch_mode(unsigned int pos) { mode2 = pos; } float Kick::nextsample() { // osc.SetFreq(pitchEnv.Process()); float osc_out = osc.Process(); osc_out = chorus.Process(osc_out); return osc_out; } } // namespace Instrument } // namespace Heck