Skip to content
Snippets Groups Projects
Commit 23f45596 authored by q3k's avatar q3k
Browse files

py/melodic: fix sustain

No idea when this broke, but we weren't actually ever stopping the
synth on petal release.
parent 9055f322
Branches
Tags v1.0.0+rc2
No related merge requests found
...@@ -2,11 +2,10 @@ import bl00mbox ...@@ -2,11 +2,10 @@ import bl00mbox
blm = bl00mbox.Channel("Melodic Demo") blm = bl00mbox.Channel("Melodic Demo")
import captouch
import leds import leds
from st3m.goose import List, Optional from st3m.goose import List, Optional
from st3m.input import InputState from st3m.input import InputState, InputController
from st3m.ui.view import ViewManager from st3m.ui.view import ViewManager
from ctx import Context from ctx import Context
...@@ -44,13 +43,17 @@ def adjust_playing_field_to_octave() -> None: ...@@ -44,13 +43,17 @@ def adjust_playing_field_to_octave() -> None:
change_playing_field_color(0, 55, 0) change_playing_field_color(0, 55, 0)
def run(ins: InputState) -> None: def run(input: InputController) -> None:
global scale global scale
global octave global octave
global synths global synths
any_down = False
for i in range(10): for i in range(10):
petal = ins.captouch.petals[i] petal = input.captouch.petals[i].whole
if petal.down:
any_down = True
if petal.pressed: if petal.pressed:
any_down = True
if i == 6: if i == 6:
octave = -1 octave = -1
adjust_playing_field_to_octave() adjust_playing_field_to_octave()
...@@ -69,6 +72,9 @@ def run(ins: InputState) -> None: ...@@ -69,6 +72,9 @@ def run(ins: InputState) -> None:
synths[0].signals.pitch.tone = note synths[0].signals.pitch.tone = note
synths[0].signals.trigger.start() synths[0].signals.trigger.start()
if not any_down:
synths[0].signals.trigger.stop()
def init() -> None: def init() -> None:
global synths global synths
...@@ -105,4 +111,4 @@ class MelodicApp(Application): ...@@ -105,4 +111,4 @@ class MelodicApp(Application):
def think(self, ins: InputState, delta_ms: int) -> None: def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms) super().think(ins, delta_ms)
run(ins) run(self.input)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment