Droplet state checks

This commit is contained in:
Christian Colglazier 2022-02-26 20:07:29 -05:00
parent 774aaa900b
commit 8b989b071b
3 changed files with 44 additions and 10 deletions

View File

@ -17,6 +17,19 @@ DropletState Droplet::GetState() {
return state;
}
bool Droplet::IsLeft() {
return GetState() == DropletState::kLeft;
}
bool Droplet::IsRight() {
return GetState() == DropletState::kRight;
}
bool Droplet::IsFull() {
return GetState() == DropletState::kFull;
}
int Droplet::GetTitleHeight() {
return kTitleHeight;
}

View File

@ -92,6 +92,27 @@ public:
*/
DropletState GetState();
/*
* Returns if the droplet is in the left state.
*
* @ return droplet in left state
*/
bool IsLeft();
/*
* Returns if the droplet is in the right state.
*
* @ return droplet in right state
*/
bool IsRight();
/*
* Returns if the droplet is in the full state.
*
* @ return droplet in full state
*/
bool IsFull();
/*
* Returns the height of the title bar of the droplet.
*

View File

@ -21,13 +21,14 @@ void SequencerDroplet::Control() {
void SequencerDroplet::Process(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size) {
if(GetState() != DropletState::kRight &&
Patch()->gate_input[0].Trig()) {
// Step input for full and left droplets
if(!IsRight() && Patch()->gate_input[0].Trig()) {
Step();
}
if(GetState() != DropletState::kLeft &&
Patch()->gate_input[1].Trig()) {
if (GetState() == DropletState::kFull) {
// Step for right droplet and reset for full
if(!IsLeft() && Patch()->gate_input[1].Trig()) {
if (IsFull()) {
Reset();
} else {
Step();
@ -55,13 +56,13 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in,
}
control_rate_count++;
// VC output of sequencer
for(size_t i = 0; i < size; i++) {
if (GetState() != DropletState::kRight) {
if (!IsRight()) {
Patch()->seed.dac.WriteValue(DacHandle::Channel::ONE,
sequence[step] * 819.2f);
}
if (GetState() != DropletState::kLeft) {
if (!IsRight()) {
Patch()->seed.dac.WriteValue(DacHandle::Channel::TWO,
sequence[step] * 819.2f);
}
@ -72,7 +73,6 @@ void SequencerDroplet::Draw() {
int left_padding = 4+GetScreenMin();
int offset = step / (num_columns*NUM_ROWS);
// Active Input
if (!InMenu()) {
offset = selected / NUM_ROWS;
@ -133,7 +133,7 @@ void SequencerDroplet::Reset() {
}
void SequencerDroplet::SetDimensions() {
if (GetState() != DropletState::kFull) {
if (!IsFull()) {
num_columns = 2;
} else {
num_columns = 4;