aboutsummaryrefslogtreecommitdiffstats
path: root/web-project/src/solo_tool_web.py
blob: f854e1a9191880ae88e24cb14b5ac203368590e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from nicegui import ui

from solo_tool import SoloTool

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 

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()

if __name__ in {'__main__', '__mp_main__'}:
    main()