
2 changed files with 97 additions and 0 deletions
@ -0,0 +1,65 @@ |
|||
#include "instr_bd2.hh" |
|||
#include "daisysp.h" |
|||
#include "utils.hh" |
|||
|
|||
namespace Heck { |
|||
namespace Instrument { |
|||
|
|||
BD2::BD2() |
|||
{ |
|||
init(); |
|||
} |
|||
|
|||
void BD2::init() |
|||
{ |
|||
bd2.Init(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_mode1(unsigned int pos) |
|||
{ |
|||
mode1 = pos; |
|||
} |
|||
|
|||
void BD2::switch_mode2(unsigned int pos) |
|||
{ |
|||
mode2 = pos; |
|||
} |
|||
|
|||
float BD2::nextsample() |
|||
{ |
|||
float out{}; |
|||
out = bd2.Process(); |
|||
return out; |
|||
} |
|||
|
|||
} // namespace Instrument
|
|||
} // namespace Heck
|
@ -0,0 +1,32 @@ |
|||
#ifndef HECK_DAISY_INSTR_BD2_HH |
|||
#define HECK_DAISY_INSTR_BD2_HH |
|||
|
|||
#include "instr_abstract.hh" |
|||
#include "daisy_seed.h" |
|||
#include "daisysp.h" |
|||
|
|||
namespace ld = daisy; |
|||
namespace dsp = daisysp; |
|||
|
|||
namespace Heck { |
|||
namespace Instrument { |
|||
|
|||
class BD2 : public AbstractInstrument { |
|||
public: |
|||
BD2(); |
|||
void init(); |
|||
void trigger() override; |
|||
void ctl(unsigned int ctl_nr, float val) override; |
|||
void switch_mode1(unsigned int pos) override; |
|||
void switch_mode2(unsigned int pos) override; |
|||
float nextsample() override; |
|||
|
|||
private: |
|||
dsp::SyntheticBassDrum bd2{}; |
|||
float mode1{}; |
|||
float mode2{}; |
|||
}; |
|||
|
|||
} // namespace Instrument
|
|||
} // namespace Heck
|
|||
#endif |
Loading…
Reference in new issue