Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
endless-sequencer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rorist
endless-sequencer
Commits
c384b9b7
Commit
c384b9b7
authored
1 year ago
by
rorist
Browse files
Options
Downloads
Patches
Plain Diff
Add time signature to UI
parent
2b3499b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
__init__.py
+18
-7
18 additions, 7 deletions
__init__.py
with
18 additions
and
7 deletions
__init__.py
+
18
−
7
View file @
c384b9b7
...
@@ -38,6 +38,7 @@ class EndlessSequencer(Application):
...
@@ -38,6 +38,7 @@ class EndlessSequencer(Application):
self
.
SILENCE
=
99
self
.
SILENCE
=
99
self
.
bpm
=
120
self
.
bpm
=
120
self
.
time_signature
=
[
0.5
,
1
,
2
]
# 1/16, 1/8, 1/4
self
.
time_signature
=
[
0.5
,
1
,
2
]
# 1/16, 1/8, 1/4
self
.
time_signature_txt
=
[
'
1/16
'
,
'
1/4
'
,
'
1/8
'
]
self
.
current_time_signature
=
2
# 1/8
self
.
current_time_signature
=
2
# 1/8
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
...
@@ -98,23 +99,27 @@ class EndlessSequencer(Application):
...
@@ -98,23 +99,27 @@ class EndlessSequencer(Application):
# CURRENT SAMPLE
# CURRENT SAMPLE
if
self
.
current_sample
!=
None
and
self
.
current_sample
<
len
(
self
.
sample_names
):
if
self
.
current_sample
!=
None
and
self
.
current_sample
<
len
(
self
.
sample_names
):
ctx
.
move_to
(
0
,
1
8
)
ctx
.
move_to
(
0
,
1
0
)
ctx
.
rgb
(
*
colours
.
RED
)
ctx
.
rgb
(
*
colours
.
RED
)
ctx
.
font_size
=
20
ctx
.
font_size
=
20
ctx
.
text
(
self
.
sample_names
[
self
.
current_sample
])
ctx
.
text
(
self
.
sample_names
[
self
.
current_sample
])
# BPM
# BPM
ctx
.
text_align
=
ctx
.
LEFT
ctx
.
text_align
=
ctx
.
LEFT
ctx
.
move_to
(
-
90
,
5
0
)
ctx
.
move_to
(
-
90
,
3
5
)
ctx
.
rgb
(
*
colours
.
WHITE
)
ctx
.
rgb
(
*
colours
.
WHITE
)
ctx
.
font_size
=
18
ctx
.
font_size
=
18
ctx
.
text
(
"
BPM: {}
"
.
format
(
self
.
bpm
))
ctx
.
text
(
"
BPM: {}
"
.
format
(
self
.
bpm
))
ctx
.
move_to
(
-
80
,
70
)
ctx
.
font_size
=
12
# Time signature
ctx
.
text
(
"
left btn
"
)
ctx
.
text_align
=
ctx
.
LEFT
ctx
.
move_to
(
-
90
,
50
)
ctx
.
rgb
(
*
colours
.
WHITE
)
ctx
.
font_size
=
18
ctx
.
text
(
"
TIME: {}
"
.
format
(
self
.
time_signature_txt
[
self
.
current_time_signature
]))
# Length
# Length
ctx
.
move_to
(
30
,
60
)
ctx
.
move_to
(
30
,
45
)
ctx
.
rgb
(
*
colours
.
BLUE
)
ctx
.
rgb
(
*
colours
.
BLUE
)
ctx
.
font_size
=
48
ctx
.
font_size
=
48
if
self
.
current_note
>
0
:
if
self
.
current_note
>
0
:
...
@@ -122,6 +127,12 @@ class EndlessSequencer(Application):
...
@@ -122,6 +127,12 @@ class EndlessSequencer(Application):
else
:
else
:
ctx
.
text
(
"
{}
"
.
format
(
len
(
self
.
notes
)))
ctx
.
text
(
"
{}
"
.
format
(
len
(
self
.
notes
)))
# Hint
ctx
.
move_to
(
-
80
,
70
)
ctx
.
rgb
(
*
colours
.
GREY
)
ctx
.
font_size
=
12
ctx
.
text
(
"
btn to change
\n
bpm and time
"
)
ctx
.
restore
()
ctx
.
restore
()
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
...
@@ -218,7 +229,7 @@ class EndlessSequencer(Application):
...
@@ -218,7 +229,7 @@ class EndlessSequencer(Application):
def
next_bpm
(
self
):
def
next_bpm
(
self
):
# taken from binarybrain code
# taken from binarybrain code
beatTime
=
60.0
*
1000.0
/
self
.
bpm
/
self
.
current_time_signature
beatTime
=
60.0
*
1000.0
/
self
.
bpm
/
self
.
time_signature
[
self
.
current_time_signature
]
curRelTime
=
time
.
ticks_diff
(
time
.
ticks_ms
(),
self
.
startTime
)
curRelTime
=
time
.
ticks_diff
(
time
.
ticks_ms
(),
self
.
startTime
)
return
curRelTime
/
beatTime
>
1
return
curRelTime
/
beatTime
>
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment