-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
119 lines (100 loc) · 3.72 KB
/
app.py
File metadata and controls
119 lines (100 loc) · 3.72 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import os
import dash
from dash import dcc, html
import dash_bootstrap_components as dbc
from assets.layout import Layout
import callbacks
bpm = callbacks.loop_machine.bpm
tempo = callbacks.loop_machine.beats_per_loop
latency = callbacks.loop_machine.latency_compensation_samples
rate = callbacks.loop_machine.rate
layout = Layout()
# Initialize Dash app
# Note: external stylesheet is for modal/file popup styling
app = dash.Dash(__name__,
external_stylesheets=[dbc.themes.BOOTSTRAP])
# Contains the UI layout
app_layout = html.Div(
className="app-container",
children=[
# Data store and poll interval, used to trigger UI update
# programmatically
# data = is_dirty, i.e. 'True' indicates refresh is needed
dcc.Store(id='track_buffer_modified', data=False),
dcc.Interval(id='track_buffer_poll', interval=100, n_intervals=0),
# Links css style file
html.Link(rel="stylesheet", href=os.path.join(
"assets", "main_style.css")),
html.Link(rel="stylesheet", href=os.path.join(
"assets", "top_style.css")),
html.Link(rel="stylesheet", href=os.path.join(
"assets", "bottom_right_style.css")),
html.Link(rel="stylesheet", href=os.path.join(
"assets", "bottom_left_style.css")),
# Link font awesome file to use icons
html.Link(
rel="stylesheet",
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css",
),
# Top section
html.Div(
className="top-container",
children=layout.get_top_layout()
),
# Bottom section
html.Div(
className="bottom-container",
children=[
# Left section
html.Div(
className="left-container",
children=[
# Loop period
# Contains loop text, pitch button
html.Div(
className="loop-container",
children=layout.get_loop_layout()
),
# Get track layout
html.Div(
className="track-container",
children=[
html.Div(
id="track_section",
),
html.Div(
className="playhead",
id='playhead',
),
dcc.Interval(
id='playhead-interval',
interval=(6000 / bpm),
n_intervals=0
)
]
)
]
),
# Bottom right section
html.Div(
className="right-container",
children=layout.get_right_tab_layout(bpm=bpm,
beats_per_loop=tempo,
latency_compensation_samples=latency,
rate=rate)
),
]
)
]
)
# Add layout to app
app.layout = app_layout
# Get all callbacks
callbacks.button_callbacks(app)
callbacks.offset_callbacks(app)
callbacks.load_save(app)
callbacks.playhead_callback(app)
def run_program():
app.run('127.0.0.1', port=8050)
if __name__ == "__main__":
app.run(debug=False)