Skip to content

Commit

Permalink
define sound once in handleButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Mar 18, 2021
1 parent af2bc99 commit 55a2b1b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bleepbloopmachine/src/main.cc
Expand Up @@ -446,6 +446,7 @@ class BleepBloopMachine {
bool b_mode = !ab_mode && held & PAD_B;
bool start_mode = !ab_mode && !a_mode && !b_mode && held & PAD_START;
bool none_mode = !ab_mode && !a_mode && !b_mode && !start_mode;
auto sound = &selectedWave()->sounds[selectedBlockIndex];

if (b_mode && released) {
ignoreRelease |= PAD_B;
Expand Down Expand Up @@ -499,7 +500,6 @@ class BleepBloopMachine {
}
}
if (selectedMenu1Control == Menu1Selection::env) {
auto sound = &selectedWave()->sounds[selectedBlockIndex];
if (b_mode) {
if (released & PAD_LEFT) {
sound->attackDown();
Expand Down Expand Up @@ -579,7 +579,7 @@ class BleepBloopMachine {
break;
case MenuMode::live:
if (b_mode) {
auto sound = &selectedWave()->sounds[selectedBlockIndex];

if (released & PAD_UP) {
sound->noteUp();
}
Expand Down Expand Up @@ -609,10 +609,8 @@ class BleepBloopMachine {
}

if (released == PAD_B) {
selectedWave()->sounds[selectedBlockIndex].activate(lastNote,
lastOctave);
sound->activate(lastNote, lastOctave);
} else if (released == PAD_A) {
auto sound = &selectedWave()->sounds[selectedBlockIndex];
if (sound->active) {
// TODO this can be done by assigning it to a variable w/o using &
clipboard = sound->cut();
Expand Down

0 comments on commit 55a2b1b

Please sign in to comment.