You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
67 lines
1.6 KiB
#include "instr_fm.hh"
|
|
#include "daisysp.h"
|
|
|
|
using namespace daisysp;
|
|
|
|
|
|
namespace Heck {
|
|
namespace Instrument {
|
|
|
|
void FM::init(float samplerate)
|
|
{
|
|
osc.Init(samplerate);
|
|
osc.SetFrequency(100);
|
|
osc.SetRatio(0.);
|
|
osc.SetIndex(0.);
|
|
|
|
volEnv.Init(samplerate);
|
|
volEnv.SetTime(ADENV_SEG_ATTACK, .0001);
|
|
volEnv.SetTime(ADENV_SEG_DECAY, 1.);
|
|
volEnv.SetMax(1);
|
|
volEnv.SetMin(0);
|
|
|
|
}
|
|
|
|
void FM::trigger()
|
|
{
|
|
volEnv.Trigger();
|
|
return;
|
|
}
|
|
|
|
void FM::ctl(unsigned int ctl_nr, float val)
|
|
{
|
|
switch (ctl_nr) {
|
|
case 0:
|
|
osc.SetFrequency(val * 200.);
|
|
break;
|
|
case 1:
|
|
volEnv.SetTime(ADENV_SEG_DECAY, val * 2.);
|
|
break;
|
|
case 2:
|
|
osc.SetRatio(val * 1.);
|
|
break;
|
|
case 3:
|
|
osc.SetIndex(val * 1.);
|
|
break;
|
|
case 4:
|
|
break;
|
|
case 5:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void FM::switch_mode(unsigned int pos) {}
|
|
void FM::switch_variation(unsigned int pos) {}
|
|
void FM::switch_filter(unsigned int pos) {}
|
|
|
|
float FM::nextsample()
|
|
{
|
|
float sig{};
|
|
sig = osc.Process();
|
|
float volEnv_sig = volEnv.Process();
|
|
sig *= volEnv_sig;
|
|
return sig;
|
|
}
|
|
|
|
} // namespace Instrument
|
|
} // namespace Heck
|