Skip to content
Snippets Groups Projects
Commit d286cad4 authored by moon2's avatar moon2 :speech_balloon:
Browse files

Patch: swapped .wav with .mp3 file

The flow3r onboard app store needs to store the entire
app in memory before extracting, the original .wav file
doesn't fit.

This also switches from a bl00mbox sampler to the media
module to reduce loading time.

The version is bumped to 2 to apply these changes.
parent 284b8876
No related branches found
No related tags found
No related merge requests found
......@@ -13,12 +13,9 @@ from st3m.ui.interactions import CapScrollController
from st3m.input import InputController, InputState
from ctx import Context
import bl00mbox
import media
class App(Application):
channel: bl00mbox.Channel = bl00mbox.Channel()
sample: bl00mbox.sampler
def __init__(self, app_ctx: ApplicationContext) -> None:
super().__init__(app_ctx)
self.input = InputController()
......@@ -38,13 +35,17 @@ class App(Application):
self._piece_name = "E"
self._song_length = 0
self._song_max_length = 3000
self._song_path = app_ctx.bundle_path + "/tetrisTheme.mp3"
leds.set_auto_update(1)
#random.shuffle(self._order)
self.sample = self.channel.new(bl00mbox.patches.sampler, "tetrisTheme.wav")
self.sample.signals.output = self.channel.mixer
self.sample.signals.trigger.start()
#self.sampler_preloaded = self.blm.new(bl00mbox.plugins.sampler, "/sd/apps/Tetris/tetrisTheme.wav")
def on_enter(self, vm):
super().on_enter(vm)
media.load(self._song_path)
def on_exit(self):
super().on_exit()
media.stop()
def draw(self, ctx: Context) -> None:
# Paint the background black
......@@ -69,12 +70,8 @@ class App(Application):
def think(self, ins: InputState, delta_ms: int) -> None:
super().think(ins, delta_ms)
if self._song_length >= self._song_max_length:
self.sample.signals.trigger.start()
self._song_length = 0
else:
self._song_length += 1
#print(str(self._song_length))
if media.get_position() == media.get_duration():
media.load(self._song_path)
if self.input.buttons.app.left.pressed and self._current_piece:# and self._thinkcounter == 0: #% self._thinkcooldown / 4 == 0:
self.place_piece(0)
......@@ -91,9 +88,6 @@ class App(Application):
elif self.input.captouch.petals[5].whole.pressed and self._current_piece:
self.place_piece(0)
self.drop_piece()
elif self.input.buttons.os.middle.pressed:
self.sample.signals.trigger.stop()
self._song_length = 0
if 0 <= self._thinkcounter < self._thinkcooldown:
self._thinkcounter = self._thinkcounter + 1
......
......@@ -12,4 +12,4 @@ author = "Lichtgott"
description = "Its Tetris"
license = "LGPL-3.0-only"
url = "https://git.flow3r.garden/Jalimamo/tetrisgame"
version = 1
version = 2
File added
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment