Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Petal Hero
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
Petal Hero
Commits
7d14cb74
Verified
Commit
7d14cb74
authored
1 year ago
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
Cache tempo marks
parent
bedeb5e4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
loading.py
+7
-2
7 additions, 2 deletions
loading.py
midireader.py
+16
-12
16 additions, 12 deletions
midireader.py
with
23 additions
and
14 deletions
loading.py
+
7
−
2
View file @
7d14cb74
from
st3m.ui.view
import
BaseView
,
ViewTransitionBlend
from
st3m.ui.view
import
BaseView
,
ViewTransitionBlend
import
gc
import
gc
import
sys_display
import
time
import
song
import
song
import
utils
import
utils
...
@@ -43,5 +43,10 @@ class LoadingView(BaseView):
...
@@ -43,5 +43,10 @@ class LoadingView(BaseView):
utils
.
blm_timeout
(
self
,
delta_ms
)
utils
.
blm_timeout
(
self
,
delta_ms
)
if
self
.
vm
.
transitioning
or
not
self
.
is_active
():
return
if
self
.
vm
.
transitioning
or
not
self
.
is_active
():
return
#gc.collect()
#gc.collect()
self
.
vm
.
replace
(
song
.
SongView
(
self
.
app
,
self
.
song
,
self
.
difficulty
),
ViewTransitionBlend
())
t
=
time
.
ticks_ms
()
view
=
song
.
SongView
(
self
.
app
,
self
.
song
,
self
.
difficulty
)
t
=
time
.
ticks_ms
()
-
t
if
t
<
2000
:
time
.
sleep_ms
(
2000
-
t
)
self
.
vm
.
replace
(
view
,
ViewTransitionBlend
())
gc
.
collect
()
gc
.
collect
()
This diff is collapsed.
Click to expand it.
midireader.py
+
16
−
12
View file @
7d14cb74
...
@@ -125,6 +125,9 @@ class MidiReader(midi.MidiOutStream):
...
@@ -125,6 +125,9 @@ class MidiReader(midi.MidiOutStream):
self
.
nTracks
=
-
1
self
.
nTracks
=
-
1
self
.
ignored
=
False
self
.
ignored
=
False
self
.
current_tempo_marker
=
0
self
.
scaledTime
=
0
def
addEvent
(
self
,
track
,
event
):
def
addEvent
(
self
,
track
,
event
):
time
=
event
.
time
time
=
event
.
time
if
time
is
None
:
if
time
is
None
:
...
@@ -139,26 +142,27 @@ class MidiReader(midi.MidiOutStream):
...
@@ -139,26 +142,27 @@ class MidiReader(midi.MidiOutStream):
#elif track < len(self.tracks):
#elif track < len(self.tracks):
# self.tracks[track].addEvent(time, event)
# self.tracks[track].addEvent(time, event)
def
abs_time
(
self
):
def
ticksToBeats
(
self
,
ticks
,
bpm
):
def
ticksToBeats
(
ticks
,
bpm
):
return
(
60000.0
*
ticks
)
/
(
bpm
*
self
.
ticksPerBeat
)
return
(
60000.0
*
ticks
)
/
(
bpm
*
self
.
ticksPerBeat
)
def
abs_time
(
self
):
if
self
.
bpm
:
if
self
.
bpm
:
currentTime
=
midi
.
MidiOutStream
.
abs_time
(
self
)
currentTime
=
midi
.
MidiOutStream
.
abs_time
(
self
)
# Find out the current scaled time.
if
self
.
current_tempo_marker
==
0
:
# Yeah, this is reeally slow, but fast enough :)
tempoMarkerTime
,
currentBpm
=
0.0
,
self
.
bpm
scaledTime
=
0.0
else
:
tempoMarkerTime
=
0.0
# Find out the current scaled time.
tempoMarkerTime
,
currentBpm
=
self
.
tempoMarkers
[
self
.
current_tempo_marker
-
1
]
currentBpm
=
self
.
bpm
while
len
(
self
.
tempoMarkers
)
>
self
.
current_tempo_marker
:
for
i
in
range
(
len
(
self
.
tempoMarkers
)):
time
,
bpm
=
self
.
tempoMarkers
[
self
.
current_tempo_marker
]
time
,
bpm
=
self
.
tempoMarkers
[
i
]
if
time
>
currentTime
:
if
time
>
currentTime
:
break
break
scaledTime
+=
ticksToBeats
(
time
-
tempoMarkerTime
,
currentBpm
)
self
.
scaledTime
+=
self
.
ticksToBeats
(
time
-
tempoMarkerTime
,
currentBpm
)
self
.
current_tempo_marker
+=
1
tempoMarkerTime
,
currentBpm
=
time
,
bpm
tempoMarkerTime
,
currentBpm
=
time
,
bpm
return
scaledTime
+
ticksToBeats
(
currentTime
-
tempoMarkerTime
,
currentBpm
)
return
self
.
scaledTime
+
self
.
ticksToBeats
(
currentTime
-
tempoMarkerTime
,
currentBpm
)
return
0.0
return
0.0
def
header
(
self
,
format
,
nTracks
,
division
):
def
header
(
self
,
format
,
nTracks
,
division
):
...
...
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