
3 changed files with 100 additions and 3 deletions
@ -0,0 +1,64 @@ |
|||||
|
#include "instr_zosc.hh" |
||||
|
#include "daisysp.h" |
||||
|
#include "utils.hh" |
||||
|
|
||||
|
namespace Heck { |
||||
|
namespace Instrument { |
||||
|
|
||||
|
ZOsc::ZOsc() |
||||
|
{ |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
void ZOsc::init() |
||||
|
{ |
||||
|
zosc.Init(samplerate); |
||||
|
zosc.SetFreq(80.f); |
||||
|
zosc.SetShape(1.f); |
||||
|
} |
||||
|
|
||||
|
void ZOsc::trigger() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void ZOsc::ctl(unsigned int ctl_nr, float val) |
||||
|
{ |
||||
|
switch (ctl_nr) { |
||||
|
case 0: { |
||||
|
zosc.SetFreq(scalen_min_max(val, 40, 180)); |
||||
|
} break; |
||||
|
case 1: { |
||||
|
// zosc.SetDecay(scalen_min_max(val,0,1));
|
||||
|
} break; |
||||
|
case 2: { |
||||
|
zosc.SetFormantFreq(scalen_min_max(val,200,800)); |
||||
|
} break; |
||||
|
case 3: { |
||||
|
zosc.SetShape(scalen_min_max(val,0,1)); |
||||
|
} break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void ZOsc::switch_mode1(unsigned int pos) |
||||
|
{ |
||||
|
mode1 = pos; |
||||
|
zosc.SetMode(((float)pos)/3.); |
||||
|
hw.PrintLine(""); |
||||
|
} |
||||
|
|
||||
|
void ZOsc::switch_mode2(unsigned int pos) |
||||
|
{ |
||||
|
mode2 = pos; |
||||
|
hw.PrintLine("ZOSC MODE2: %i", mode2); |
||||
|
} |
||||
|
|
||||
|
float ZOsc::nextsample() |
||||
|
{ |
||||
|
float out{}; |
||||
|
out = zosc.Process(); |
||||
|
return out; |
||||
|
} |
||||
|
|
||||
|
} // namespace Instrument
|
||||
|
} // namespace Heck
|
@ -0,0 +1,32 @@ |
|||||
|
#ifndef HECK_DAISY_INSTR_ZOSC_HH |
||||
|
#define HECK_DAISY_INSTR_ZOSC_HH |
||||
|
|
||||
|
#include "instr_abstract.hh" |
||||
|
#include "daisy_seed.h" |
||||
|
#include "daisysp.h" |
||||
|
|
||||
|
namespace ld = daisy; |
||||
|
namespace dsp = daisysp; |
||||
|
|
||||
|
namespace Heck { |
||||
|
namespace Instrument { |
||||
|
|
||||
|
class ZOsc : public AbstractInstrument { |
||||
|
public: |
||||
|
ZOsc(); |
||||
|
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::ZOscillator zosc{}; |
||||
|
float mode1{}; |
||||
|
float mode2{}; |
||||
|
}; |
||||
|
|
||||
|
} // namespace Instrument
|
||||
|
} // namespace Heck
|
||||
|
#endif |
Loading…
Reference in new issue