1
0
mirror of https://github.com/AquaMorph/Droplets.git synced 2025-05-20 17:36:57 +00:00

Basic AD switching

This commit is contained in:
Christian Colglazier 2021-11-08 22:05:42 -05:00
parent c9a10c9b2e
commit 13f7ea65d5
2 changed files with 44 additions and 12 deletions

@ -19,11 +19,15 @@ void AD::Process(DacHandle::Channel chn,
if(patch->gate_input[gate].Trig()) {
env.Trigger();
}
attack = attack_param.Process();
if (curve_menu) {
curve = curve_param.Process();
} else {
attack = attack_param.Process();
}
decay = decay_param.Process();
env.SetTime(ADENV_SEG_ATTACK, attack);
env.SetTime(ADENV_SEG_DECAY, decay);
env.SetCurve(curve);
sig = env.Process();
patch->seed.dac.WriteValue(chn,
@ -46,6 +50,14 @@ float AD::GetCurve() {
return curve;
}
bool AD::GetMenu() {
return curve_menu;
}
void AD::ToggleCurve() {
curve_menu = !curve_menu;
}
ADDroplet::ADDroplet(DaisyPatch* m_patch,
DropletState m_state,
float sample_rate) :
@ -80,7 +92,16 @@ ADDroplet::ADDroplet(DaisyPatch* m_patch,
ADDroplet::~ADDroplet() {}
void ADDroplet::Control() {}
void ADDroplet::Control() {
if (Patch()->encoder.Pressed()) {
if (Patch()->encoder.TimeHeldMs() < 10) {
ad[0].ToggleCurve();
if (GetState() == DropletState::kFull) {
ad[1].ToggleCurve();
}
}
}
}
void ADDroplet::Process(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size) {
Patch()->ProcessAnalogControls();
@ -106,22 +127,22 @@ void ADDroplet::Process(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer o
void ADDroplet::Draw() {
WriteString(Patch(),
GetScreenMin(),
10,
GetScreenMin()+3,
11,
Font_6x8,
"A: " +
FloatToString(ad[0].GetAttack(), 2) +
"s");
WriteString(Patch(),
GetScreenMin(),
20,
GetScreenMin()+3,
21,
Font_6x8,
"D: " +
FloatToString(ad[0].GetDecay(), 2) +
"s");
WriteString(Patch(),
GetScreenMin(),
30,
GetScreenMin()+3,
31,
Font_6x8,
"C: " +
FloatToString(ad[0].GetCurve(), 2));
@ -129,24 +150,32 @@ void ADDroplet::Draw() {
int mid = (GetScreenMax() - GetScreenMin())/2;
WriteString(Patch(),
mid,
10,
11,
Font_6x8,
"A: " +
FloatToString(ad[1].GetAttack(), 2) +
"s");
WriteString(Patch(),
mid,
20,
21,
Font_6x8,
"D: " +
FloatToString(ad[1].GetDecay(), 2) +
"s");
WriteString(Patch(),
mid,
30,
31,
Font_6x8,
"C: " +
FloatToString(ad[1].GetCurve(), 2));
}
if (ad[0].GetMenu()) {
DrawSolidRect(Patch(), GetScreenMin(), 30, GetScreenMin()+1, 39, true);
} else {
DrawSolidRect(Patch(), GetScreenMin(), 10, GetScreenMin()+1, 19, true);
}
DrawSolidRect(Patch(), GetScreenMin(), 20, GetScreenMin()+1, 29, true);
DrawName("AD");
}

@ -21,6 +21,7 @@ private:
Parameter curve_param;
float sig;
DaisyPatch* patch;
bool curve_menu = false;
public:
void Init(DaisyPatch* m_patch,
float sample_rate,
@ -33,6 +34,8 @@ public:
float GetAttack();
float GetDecay();
float GetCurve();
bool GetMenu();
void ToggleCurve();
};
class ADDroplet: public Droplet {