diff options
Diffstat (limited to 'web-project/src')
-rw-r--r-- | web-project/src/solo_tool_web.py | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/web-project/src/solo_tool_web.py b/web-project/src/solo_tool_web.py index f854e1a..edca008 100644 --- a/web-project/src/solo_tool_web.py +++ b/web-project/src/solo_tool_web.py @@ -1,56 +1,61 @@ from nicegui import ui from solo_tool import SoloTool +from solo_tool.session_manager import loadSession +from solo_tool import handlers +from solo_tool.midi_controller_launchpad_mini import MidiController -st = SoloTool() -st.loadSession("/home/eddy/music/solos/practice.json") - -def _createSeekHandler(delta): - def f(): - newPosition = st.getPlaybackPosition() + delta - newPosition = min(1.0, max(0.0, newPosition)) - st.setPlaybackPosition(newPosition) - return f +st = loadSession("/home/eddy/music/funk-band/practice.json") +midiController = MidiController(st) +midiController.connect() def main(): - with ui.splitter(value=30) as splitter: - splitter.style('width: 100%; height: 100%;') - with splitter.before: - with ui.list().props('dense separator'): - for song in st.getSongs(): - ui.item(song) - with splitter.after: - ui.slider(min=0, max=1.2, value=1.0, step=0.01, on_change=lambda e: st.setPlaybackVolume(e.value)) - - with ui.row().classes("w-full justify-between no-wrap"): - ui.button('-5%', on_click=lambda: st.setPlaybackRate(max(0.5, st.getPlaybackRate() - 0.05))) - ui.slider(min=0.5, max=1.2, step=0.05, value=st.getPlaybackRate(), on_change=lambda e: st.setPlaybackRate(e.value)) - ui.button('+5%', on_click=lambda: st.setPlaybackRate(min(1.2, st.getPlaybackRate() + 0.05))) - - ui.slider(min=0, max=100, value=0) - - with ui.row().classes("w-full justify-between no-wrap"): - ui.button('Prev', on_click=st.previousSong) - ui.button('-25%', on_click=_createSeekHandler(-0.25)) - ui.button('-5%', on_click=_createSeekHandler(-0.05)) - ui.button('-1%', on_click=_createSeekHandler(-0.01)) - ui.button('+1%', on_click=_createSeekHandler(0.01)) - ui.button('+5%', on_click=_createSeekHandler(0.05)) - ui.button('+25%', on_click=_createSeekHandler(0.25)) - ui.button('Next', on_click=st.nextSong) - - with ui.row().classes("w-full justify-between no-wrap"): - ui.button('Set A') - ui.button('Set B') - ui.button('Previous AB') - ui.button('Next AB') - - with ui.row().classes("w-full justify-between no-wrap"): - ui.button('Toggle AB', on_click=lambda: st.setAbLimitEnable(not st.isAbLimitEnabled())) - ui.button('Stop', on_click=st.stop) - ui.button('Play', on_click=st.play) - ui.button('Jump to A', on_click=st.jumpToA) - ui.run() + fullscreen = ui.fullscreen() + ui.dark_mode().enable() + ui.colors(secondary='#ffc107') + + with ui.row() as mainContainer: + mainContainer.style('width: 100%; height: 100%;') + + with ui.column() as keyPointColumn: + keyPointColumn.style('width: 12%; height: 100%;') + + ui.label('Key Points') + + with ui.scroll_area(): + for i, song in enumerate(st.songs): + with ui.list().props('dense separator').bind_visibility_from(st, 'song', value=i) as keyPointList: + for kp in st._keyPoints[i]: + ui.item(f"{kp}", on_click=handlers.setKeyPoint(st, kp)).props('clickable') + + with ui.column() as controlColumn: + controlColumn.style('width: 84%; height: 100%;') + + ui.label("Song name").bind_text_from(st, 'song', lambda index: st.songs[index] if index is not None else "") + + # Playback position + ui.slider(min=0, max=1.0, step=0.01).bind_value(st, 'position').props('thumb-size=0px track-size=16px') + + # Key point position + ui.slider(min=0, max=1.0, step=0.01).bind_value(st, 'keyPoint').props('color=secondary') + + # Play control + with ui.button_group().classes('w-full').style('height: 90px'): + ui.button(icon='skip_previous', on_click=handlers.changeSong(st, -1)).style('flex: 1') + ui.button(icon='stop', on_click=st.stop, color='negative').style('flex: 1') + ui.button(color='positive', on_click=handlers.playPause(st)).bind_icon_from(st, "playing", lambda playing: "pause" if playing else "play_arrow").style('flex: 2') + ui.button(icon='undo', on_click=st.jump, color='secondary').style('flex: 2') + ui.button(icon='skip_next', on_click=handlers.changeSong(st, 1)).style('flex: 1') + + # Volume and rate + with ui.row().classes('w-full justify-between no-wrap'): + ui.button(icon='fast_rewind', on_click=handlers.rateRelative(st, -0.05)) + ui.label().bind_text_from(st, 'rate', lambda rate: f'{rate:0.3}').on('click', handlers.rateAbsolute(st, 1.0)) + ui.button(icon='fast_forward', on_click=handlers.rateRelative(st, 0.05)) + ui.slider(min=0, max=1.2, step=0.01).bind_value(st, 'volume') + ui.button(icon='fullscreen', on_click=fullscreen.toggle).props('outline') + + ui.run() if __name__ in {'__main__', '__mp_main__'}: main() |