diff --git a/docs/badge/usage.rst b/docs/badge/usage.rst index 90a0d84cc71c2df74f49349830594c501631c552..7eb4192ade5bff550fd58d296341d59546e1b6e9 100644 --- a/docs/badge/usage.rst +++ b/docs/badge/usage.rst @@ -88,12 +88,12 @@ We ship some noise-making apps by default: shoegaze ^^^^^^^^ -Electric guitar simulator with fuzz and reverb. Tilt for wiggle stick. App button middle switches between render modes: Lo Fi has lower framerate, default has slower input response time. App button left turns delay on and off. +Electric guitar simulator with fuzz and reverb. Tilt for wiggle stick. App button middle switches between render modes: Lo Fi has lower framerate, default has slower input response time. App button left turns delay on and off. Top petals play notes in chord, bottom petals change chord. Otamatone ^^^^^^^^^ -The highlighted blue petal makes noise. +The highlighted blue petal makes noise. The highlighted green petal modulates the a resonant lowpass filter. gay drums ^^^^^^^^^^ diff --git a/python_payload/apps/otamatone/__init__.py b/python_payload/apps/otamatone/__init__.py index ee988ea8737ab651eb3c011a2562eea12eeac285..7948ab1f01f7fbd5f7caac109c8f244324f8f2f4 100644 --- a/python_payload/apps/otamatone/__init__.py +++ b/python_payload/apps/otamatone/__init__.py @@ -76,6 +76,7 @@ class Otamatone(Application): """ PETAL_NO = 7 + WAH_PETAL_NO = 3 def __init__(self, app_ctx: ApplicationContext) -> None: super().__init__(app_ctx) @@ -96,11 +97,19 @@ class Otamatone(Application): self._dist = self._blm.new(bl00mbox.plugins._distortion) # Lowpass. self._lp = self._blm.new(bl00mbox.plugins.lowpass) + self._lp2 = self._blm.new(bl00mbox.plugins.lowpass) + # Mixer. + self._mixer = self._blm.new(bl00mbox.plugins.mixer, 2) - # Wire sawtooth -> distortion -> lowpass - self._osc.signals.output = self._dist.signals.input - self._dist.signals.output = self._lp.signals.input - self._lp.signals.output = self._blm.mixer + # Wire sawtooth -> distortion -> env -> lowpass + self._osc.plugins.osc.signals.output = self._dist.signals.input + self._osc.plugins.amp.signals.input = self._dist.signals.output + self._lp.signals.input = self._osc.signals.output + self._lp2.signals.input = self._osc.signals.output + + self._lp.signals.output = self._mixer.signals.input0 + self._lp2.signals.output = self._mixer.signals.input1 + self._mixer.signals.output = self._blm.mixer # Closest thing to a waveform number for 'saw'. self._osc.signals.waveform = 20000 @@ -110,21 +119,34 @@ class Otamatone(Application): # Built custom square wave (low duty cycle) table_len = 129 self._dist.table = [ - 32767 if i > (0.1 * table_len) else -32767 for i in range(table_len) + 500 if i > (0.1 * table_len) else -5000 for i in range(table_len) ] - self._lp.signals.freq = 4000 + self._set_wah(0.8) + + def _set_wah(self, wah_ctrl): + self._lp.signals.reso = 1000 + 2500 * (1 - wah_ctrl) + self._lp.signals.freq = 1500 * (2 ** (2.5 * wah_ctrl)) + self._lp.signals.gain.dB = 6 + 3 * (1 - wah_ctrl) + self._lp2.signals.reso = 1000 + 1000 * (1 - wah_ctrl) + self._lp2.signals.freq = 2800 * (2 ** (2 * wah_ctrl)) + self._lp2.signals.gain.dB = 6 + 3 * (1 - wah_ctrl) def on_exit(self): super().on_exit() if self._blm is not None: + self._blm.clear() self._blm.free = True self._blm = None def on_enter(self, vm: Optional[ViewManager]) -> None: super().on_enter(vm) + for i in range(40): + leds.set_rgb(i, 0, 0, 0) for i in range(26, 30 + 1): leds.set_rgb(i, 62, 159, 229) + for i in range(10, 14 + 1): + leds.set_rgb(i, 62, 229, 159) leds.update() if self._blm is None: self._build_synth() @@ -157,6 +179,15 @@ class Otamatone(Application): ctrl = 1 ctrl *= -1 + wah_petal = self.input.captouch.petals[self.WAH_PETAL_NO] + wah_pos = ins.captouch.petals[self.WAH_PETAL_NO].position + wah_ctrl = wah_pos[0] / 40000 + if wah_ctrl < -1: + wah_ctrl = -1 + if wah_ctrl > 1: + wah_ctrl = 1 + wah_ctrl *= -1 + if petal.whole.down: if self._intensity < 1.0: self._intensity += 0.1 * (delta_ms / 20) @@ -167,6 +198,9 @@ class Otamatone(Application): self._intensity = 0 self._osc.signals.trigger.stop() + if wah_petal.whole.down: + self._set_wah(wah_ctrl) + self._blob._yell = self._intensity * 0.8 + (ctrl + 1) * 0.1