diff --git a/pizzactrl/hal_serial.py b/pizzactrl/hal_serial.py index b347e0f..6c405c0 100644 --- a/pizzactrl/hal_serial.py +++ b/pizzactrl/hal_serial.py @@ -35,6 +35,7 @@ class SerialCommands(Enum): BACKLIGHT = 'B' FRONTLIGHT = 'F' USER_INTERACTION = 'U' + RECORD = 'C' REWIND = 'R' @@ -135,7 +136,7 @@ def wait_for_input(hal: PizzaHAL, go_callback: Any, :param to_callback: called on timeout :param timeout: inactivity timeout in seconds (default 120) """ - resp = hal.send_cmd(SerialCommands.USER_INTERACTION, timeout) + resp = hal.send_cmd(SerialCommands.USER_INTERACTION, timeout).strip() if resp == 'B': go_callback(**kwargs) elif resp == 'R': @@ -208,8 +209,11 @@ def record_sound(hal: PizzaHAL, filename: Any, duration: int, myrecording = sd.rec(int(duration * AUDIO_REC_SR), samplerate=AUDIO_REC_SR, channels=2) - # TODO user interaction instead - sd.wait() # Wait until recording is finished + resp = hal.send_cmd(SerialCommands.RECORD, duration).strip() + if resp == 'I': + sd.stop() + else: + sd.wait() # Wait until recording is finished # TODO test myrecording = np.int16(myrecording) song = pydub.AudioSegment(myrecording.tobytes(), frame_rate=AUDIO_REC_SR, sample_width=2, channels=2) diff --git a/pizzactrl/sb_en.py b/pizzactrl/sb_en.py index f758c46..6b0e59b 100644 --- a/pizzactrl/sb_en.py +++ b/pizzactrl/sb_en.py @@ -2,43 +2,42 @@ from pizzactrl import storyboard, fs_names STORYBOARD = [ storyboard.Chapter( - # storyboard.Do(storyboard.Activity.ADVANCE_UP), - storyboard.Do(storyboard.Activity.LIGHT_BACK, # Bild 1 + storyboard.Do(storyboard.Activity.LIGHT_LAYER, # VERT01 intensity=1.0, fade=1.0) ), storyboard.Chapter( storyboard.Do(storyboard.Activity.PLAY_SOUND, - sound=fs_names.StoryFile('03en')), + sound=fs_names.StoryFile('01en')), + storyboard.Do(storyboard.Activity.PLAY_SOUND, + sound=fs_names.StoryFile('02en')), storyboard.Do(storyboard.Activity.WAIT_FOR_INPUT), - storyboard.Do(storyboard.Activity.ADVANCE_UP) # Bild 2 + storyboard.Do(storyboard.Activity.ADVANCE_UP) # VERT02up ), storyboard.Chapter( - storyboard.Do(storyboard.Activity.LIGHT_BACK, # Bild 1 - intensity=1.0, fade=1.0), storyboard.Do(storyboard.Activity.PLAY_SOUND, - sound=fs_names.StoryFile('04en')), - storyboard.Do(storyboard.Activity.ADVANCE_UP), # Bild 3 + sound=fs_names.StoryFile('03en')), + storyboard.Do(storyboard.Activity.ADVANCE_UP), # VERT02down + storyboard.Do(storyboard.Activity.LIGHT_BACK, + intensity=1.0, fade=0.5), + storyboard.Do(storyboard.Activity.LIGHT_LAYER, + intensity=0.0, fade=0.5), storyboard.Do(storyboard.Activity.PLAY_SOUND, sound=fs_names.StoryFile('05en')), + storyboard.Do(storyboard.Activity.ADVANCE_UP), # VERT03 storyboard.Do(storyboard.Activity.PLAY_SOUND, sound=fs_names.StoryFile('06en')), + storyboard.Do(storyboard.Activity.LIGHT_BACK, + intensity=0.0, fade=1.0), storyboard.Do(storyboard.Activity.PLAY_SOUND, sound=fs_names.StoryFile('07en')), - storyboard.Do(storyboard.Activity.ADVANCE_UP), # Bild 4 - storyboard.Do(storyboard.Activity.PLAY_SOUND, - sound=fs_names.StoryFile('08en')), - storyboard.Do(storyboard.Activity.PLAY_SOUND, - sound=fs_names.StoryFile('09en')), - storyboard.Do(storyboard.Activity.LIGHT_BACK, - intensity=0.0), storyboard.Do(storyboard.Activity.WAIT_FOR_INPUT), - storyboard.Do(storyboard.Activity.ADVANCE_UP), # Bild 5 + storyboard.Do(storyboard.Activity.ADVANCE_UP), # VERT04 + storyboard.Do(storyboard.Activity.LIGHT_LAYER, + intensity=1.0, fade=1.0), ), storyboard.Chapter( - storyboard.Do(storyboard.Activity.LIGHT_BACK, - intensity=1.0), storyboard.Do(storyboard.Activity.PLAY_SOUND, - sound=fs_names.StoryFile('10en')), + sound=fs_names.StoryFile('08en')), storyboard.Do(storyboard.Activity.PLAY_SOUND, sound=fs_names.StoryFile('11en')), storyboard.Do(storyboard.Activity.PLAY_SOUND,