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
d3b98b20
Verified
Commit
d3b98b20
authored
8 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add support for octave tracking like in Mir(?)BSD, closes
#4
.
parent
9cde6b6a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Add support for octave tracking like in Mir(?)BSD, closes #4.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MMLFILE.rst
+5
-1
5 additions, 1 deletion
MMLFILE.rst
mmllib/mml.py
+18
-1
18 additions, 1 deletion
mmllib/mml.py
with
23 additions
and
2 deletions
MMLFILE.rst
+
5
−
1
View file @
d3b98b20
...
...
@@ -35,7 +35,11 @@ Symbols of MML
:O(n):
Octave 0 sets the current octave. There are 7 octaves (0 through 6).
Default is 4. Middle C is at the beginning of octave 2.
Default is 4. Middle C is at the beginning of octave 2. The special
values L and N control octave tracking. L enables octave tracking, N
disables it; with octave tracking enabled, jumps between notes are
limited to 6 half-tones, otherwise, the octave is incremented or
decremented accordingly. Octave tracking is disabled by default.
:P(n):
Pause. n may range from 1-64; the current L value is used if omitted.
...
...
This diff is collapsed.
Click to expand it.
mmllib/mml.py
+
18
−
1
View file @
d3b98b20
...
...
@@ -200,6 +200,8 @@ def mml(macro, _nplay=None, _barline=None):
art
=
'
N
'
bpm
=
120
octave
=
4
octave_tracking
=
False
octave_tracking_last_note
=
None
timevalue
=
4
# normalise macro string, create input list
...
...
@@ -222,6 +224,12 @@ def mml(macro, _nplay=None, _barline=None):
if
char
in
_MML_NAME2STEP
.
keys
():
# base note
note
=
12
*
octave
+
_MML_NAME2STEP
[
char
]
if
octave_tracking
and
octave_tracking_last_note
:
if
note
-
octave_tracking_last_note
>
6
:
octave
-=
1
elif
note
-
octave_tracking_last_note
<
-
6
:
octave
+=
1
note
=
12
*
octave
+
_MML_NAME2STEP
[
char
]
extra
=
(
octave
,
char
,
u
'
♮
'
)
# accidental sign
...
...
@@ -242,6 +250,8 @@ def mml(macro, _nplay=None, _barline=None):
# sustain dots, and play the note
_play
(
macro
,
res
,
bpm
,
art
,
note
,
_length
,
extra
)
# remember last note for octave tracking
octave_tracking_last_note
=
note
elif
char
==
"
L
"
:
timevalue
=
_getint
(
macro
,
1
,
64
,
4
)
...
...
@@ -257,7 +267,14 @@ def mml(macro, _nplay=None, _barline=None):
_play
(
macro
,
res
,
bpm
,
art
,
note
,
timevalue
,
note
)
elif
char
==
"
O
"
:
octave
=
_getint
(
macro
,
0
,
6
,
4
)
if
macro
[
0
].
isdigit
():
octave
=
_getint
(
macro
,
0
,
6
,
4
)
else
:
char
=
macro
.
pop
(
0
)
if
char
==
"
L
"
:
octave_tracking
=
True
elif
char
==
"
N
"
:
octave_tracking
=
False
elif
char
==
"
P
"
:
_length
=
_getint
(
macro
,
1
,
64
,
timevalue
)
...
...
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