Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mmllib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Teckids
Projekt Hack-n-Fun
Libs
mmllib
Commits
5730793c
Unverified
Commit
5730793c
authored
3 years ago
by
mirabilos
Committed by
mirabilos
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
make octave tracking implementation match spkr(4) better
parent
52b14693
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmllib/mml.py
+22
-11
22 additions, 11 deletions
mmllib/mml.py
with
22 additions
and
11 deletions
mmllib/mml.py
+
22
−
11
View file @
5730793c
...
@@ -206,7 +206,8 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
...
@@ -206,7 +206,8 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
bpm
=
120
bpm
=
120
octave
=
4
octave
=
4
octave_tracking
=
False
octave_tracking
=
False
octave_tracking_last_note
=
None
octave_tracking_onhold
=
True
octave_tracking_last_note
=
12
*
octave
timevalue
=
4
timevalue
=
4
# result normalised MML
# result normalised MML
normml
=
[
"
O4L4T120MN
"
]
normml
=
[
"
O4L4T120MN
"
]
...
@@ -231,14 +232,22 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
...
@@ -231,14 +232,22 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
if
char
in
_MML_NAME2STEP
.
keys
():
if
char
in
_MML_NAME2STEP
.
keys
():
# base note
# base note
if
octave_tracking
and
octave_tracking_last_note
:
if
note
-
octave_tracking_last_note
>
6
:
octave
-=
1
normml
[
0
]
+=
"
<
"
elif
note
-
octave_tracking_last_note
<
-
6
:
octave
+=
1
normml
[
0
]
+=
"
>
"
note
=
12
*
octave
+
_MML_NAME2STEP
[
char
]
note
=
12
*
octave
+
_MML_NAME2STEP
[
char
]
# octave tracking implementation
if
octave_tracking
and
not
octave_tracking_onhold
:
if
abs
(
note
-
octave_tracking_last_note
)
>
\
abs
(
note
+
12
-
octave_tracking_last_note
):
normml
[
0
]
+=
"
>
"
octave
+=
1
note
+=
12
if
abs
(
note
-
octave_tracking_last_note
)
>
\
abs
(
note
-
12
-
octave_tracking_last_note
):
normml
[
0
]
+=
"
<
"
octave
-=
1
note
-=
12
octave_tracking_onhold
=
False
octave_tracking_last_note
=
note
# base note information
extra
=
(
octave
,
char
,
u
'
♮
'
)
extra
=
(
octave
,
char
,
u
'
♮
'
)
bnote
=
char
bnote
=
char
...
@@ -256,6 +265,7 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
...
@@ -256,6 +265,7 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
bnote
=
_MML_STEP2NAME_ES
[
note
%
12
]
bnote
=
_MML_STEP2NAME_ES
[
note
%
12
]
macro
.
pop
(
0
)
macro
.
pop
(
0
)
# base note and accidental
normml
[
0
]
+=
bnote
normml
[
0
]
+=
bnote
# length
# length
...
@@ -267,9 +277,6 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
...
@@ -267,9 +277,6 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
# sustain dots, and play the note
# sustain dots, and play the note
_play
(
macro
,
normml
,
res
,
bpm
,
art
,
note
,
_length
,
extra
)
_play
(
macro
,
normml
,
res
,
bpm
,
art
,
note
,
_length
,
extra
)
# remember last note for octave tracking
octave_tracking_last_note
=
note
elif
char
==
"
L
"
:
elif
char
==
"
L
"
:
timevalue
=
_getint
(
macro
,
1
,
64
,
4
)
timevalue
=
_getint
(
macro
,
1
,
64
,
4
)
normml
[
0
]
+=
"
L
"
+
str
(
timevalue
)
normml
[
0
]
+=
"
L
"
+
str
(
timevalue
)
...
@@ -290,12 +297,14 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
...
@@ -290,12 +297,14 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
if
macro
[
0
].
isdigit
():
if
macro
[
0
].
isdigit
():
octave
=
_getint
(
macro
,
0
,
6
,
4
)
octave
=
_getint
(
macro
,
0
,
6
,
4
)
normml
[
0
]
+=
"
O
"
+
str
(
octave
)
normml
[
0
]
+=
"
O
"
+
str
(
octave
)
octave_tracking_onhold
=
True
else
:
else
:
char
=
macro
.
pop
(
0
)
char
=
macro
.
pop
(
0
)
if
char
==
"
L
"
:
if
char
==
"
L
"
:
octave_tracking
=
True
octave_tracking
=
True
elif
char
==
"
N
"
:
elif
char
==
"
N
"
:
octave_tracking
=
False
octave_tracking
=
False
octave_tracking_onhold
=
False
elif
char
==
"
P
"
:
elif
char
==
"
P
"
:
_length
=
_getint
(
macro
,
1
,
64
,
timevalue
)
_length
=
_getint
(
macro
,
1
,
64
,
timevalue
)
...
@@ -310,11 +319,13 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
...
@@ -310,11 +319,13 @@ def mml(macro, _nplay=None, _barline=None, _mmltrk=None):
if
octave
>
0
:
if
octave
>
0
:
octave
-=
1
octave
-=
1
normml
[
0
]
+=
char
normml
[
0
]
+=
char
octave_tracking_onhold
=
True
elif
char
==
"
>
"
:
elif
char
==
"
>
"
:
if
octave
<
6
:
if
octave
<
6
:
octave
+=
1
octave
+=
1
normml
[
0
]
+=
char
normml
[
0
]
+=
char
octave_tracking_onhold
=
True
elif
char
==
"
|
"
:
elif
char
==
"
|
"
:
normml
[
0
]
+=
"
"
normml
[
0
]
+=
"
"
...
...
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