
3 changed files with 94 additions and 1 deletions
@ -0,0 +1,60 @@ |
|||||
|
#include "instr_hihat.hh" |
||||
|
#include "daisysp.h" |
||||
|
#include "utils.hh" |
||||
|
|
||||
|
namespace Heck { |
||||
|
namespace Instrument { |
||||
|
|
||||
|
HiHat::HiHat() |
||||
|
{ |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
void HiHat::init() |
||||
|
{ |
||||
|
hihat.Init(samplerate); |
||||
|
hihat.SetDecay(1.); |
||||
|
} |
||||
|
|
||||
|
void HiHat::trigger() |
||||
|
{ |
||||
|
hihat.Trig(); |
||||
|
} |
||||
|
|
||||
|
void HiHat::ctl(unsigned int ctl_nr, float val) |
||||
|
{ |
||||
|
switch (ctl_nr) { |
||||
|
case 0: { |
||||
|
hihat.SetFreq(scalen_min_max(val, 800, 2000)); |
||||
|
} break; |
||||
|
case 1: { |
||||
|
|
||||
|
} break; |
||||
|
case 2: { |
||||
|
hihat.SetTone(scalen_min_max(val, 0, 1)); |
||||
|
} break; |
||||
|
case 3: { |
||||
|
hihat.SetNoisiness(scalen_min_max(val, 0, 1)); |
||||
|
} break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void HiHat::switch_mode1(unsigned int pos) |
||||
|
{ |
||||
|
mode1 = pos; |
||||
|
} |
||||
|
|
||||
|
void HiHat::switch_mode2(unsigned int pos) |
||||
|
{ |
||||
|
mode2 = pos; |
||||
|
} |
||||
|
|
||||
|
float HiHat::nextsample() |
||||
|
{ |
||||
|
float out{}; |
||||
|
out = hihat.Process(); |
||||
|
return out; |
||||
|
} |
||||
|
|
||||
|
} // namespace Instrument
|
||||
|
} // namespace Heck
|
@ -0,0 +1,32 @@ |
|||||
|
#ifndef HECK_DAISY_INSTR_HIHAT_HH |
||||
|
#define HECK_DAISY_INSTR_HIHAT_HH |
||||
|
|
||||
|
#include "instr_abstract.hh" |
||||
|
#include "daisy_seed.h" |
||||
|
#include "daisysp.h" |
||||
|
|
||||
|
namespace ld = daisy; |
||||
|
namespace dsp = daisysp; |
||||
|
|
||||
|
namespace Heck { |
||||
|
namespace Instrument { |
||||
|
|
||||
|
class HiHat : public AbstractInstrument { |
||||
|
public: |
||||
|
HiHat(); |
||||
|
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::HiHat<> hihat{}; |
||||
|
float mode1{}; |
||||
|
float mode2{}; |
||||
|
}; |
||||
|
|
||||
|
} // namespace Instrument
|
||||
|
} // namespace Heck
|
||||
|
#endif |
Loading…
Reference in new issue