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.
55 lines
1.2 KiB
55 lines
1.2 KiB
#include "instr_fm.hh"
|
|
#include "daisysp.h"
|
|
#include "utils.hh"
|
|
|
|
namespace Heck {
|
|
namespace Instrument {
|
|
|
|
FM::FM()
|
|
{
|
|
init();
|
|
}
|
|
|
|
void FM::init()
|
|
{
|
|
osc.Init(samplerate);
|
|
osc.SetFrequency(40);
|
|
osc.SetRatio(0.);
|
|
osc.SetIndex(0.);
|
|
}
|
|
|
|
void FM::trigger()
|
|
{
|
|
osc.Reset();
|
|
}
|
|
|
|
void FM::ctl(unsigned int ctl_nr, float val)
|
|
{
|
|
switch (ctl_nr) {
|
|
case 0:
|
|
osc.SetFrequency(31 + (val * 320.));
|
|
break;
|
|
case 1:
|
|
break;
|
|
case 2: {
|
|
float ratio_val = scalen_min_max(val, 1., 3.);
|
|
osc.SetRatio(ratio_val);
|
|
} break;
|
|
case 3:
|
|
osc.SetIndex(val * 0.1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void FM::switch_mode1(unsigned int pos) {}
|
|
void FM::switch_mode2(unsigned int pos) {}
|
|
|
|
float FM::nextsample()
|
|
{
|
|
float sig{};
|
|
sig = osc.Process();
|
|
return sig;
|
|
}
|
|
|
|
} // namespace Instrument
|
|
} // namespace Heck
|