Skip to content

Commit

Permalink
swap the representations for sus and amp
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Mar 18, 2021
1 parent b25add6 commit af2bc99
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions bleepbloopmachine/src/main.cc
Expand Up @@ -142,7 +142,7 @@ class SoundBlock {
float delay = 0.0;
float pan = 0.0;
float amp = 1.0;
float sustain = 0.9;
float sustain = 0.4;
Waveform waveform;
float frequency() { return freq[note][octave]; }
void activate(int n, int o) {
Expand Down Expand Up @@ -291,24 +291,28 @@ class Wave {
display->fillRect(point.x + panX, point.y + BLOCK_SIZE - 2, 2, 2,
ST7735_CYAN);

// draw attack/decay/sustain
// draw attack/decay/amp
/// perhaps unexpected is that amplitude is represented by the height
/// of the envelope, sustain being the bar on the right

auto envColor = ST7735_GREEN;
float attackX = ((float)BLOCK_SIZE / 2 / MAX_ATTACK) * sound->attack;
float decayW = ((float)BLOCK_SIZE / 2 / MAX_DECAY) * sound->decay;
/// attack/sus
display->drawLine(
point.x, point.y + BLOCK_SIZE, point.x + attackX,
(point.y + BLOCK_SIZE) - BLOCK_SIZE * sound->sustain, envColor);
/// decay/sus
display->drawLine(
point.x + attackX,
(point.y + BLOCK_SIZE) - BLOCK_SIZE * sound->sustain,
point.x + attackX + decayW, (point.y + BLOCK_SIZE), envColor);

// draw amp
auto ampY = BLOCK_SIZE * sound->amp;

/// attack/amp
display->drawLine(point.x, point.y + BLOCK_SIZE, point.x + attackX,
(point.y + BLOCK_SIZE) - BLOCK_SIZE * sound->amp,
envColor);
/// decay/amp
display->drawLine(point.x + attackX,
(point.y + BLOCK_SIZE) - BLOCK_SIZE * sound->amp,
point.x + attackX + decayW, (point.y + BLOCK_SIZE),
envColor);

// draw sustain
auto susY = BLOCK_SIZE * sound->sustain;
display->fillRect(point.x + BLOCK_SIZE - 4,
point.y + (BLOCK_SIZE - ampY), 4, ampY,
point.y + (BLOCK_SIZE - susY), 4, susY,
ST7735_CYAN);
}
} else if (mode == MenuMode::menu2) {
Expand Down

0 comments on commit af2bc99

Please sign in to comment.