Changes to triplet characters
This commit is contained in:
@ -124,7 +124,7 @@ def resolve_item(item: Meta, options: dict):
|
|||||||
update_modifications(item, options)
|
update_modifications(item, options)
|
||||||
elif isinstance(item, Measure):
|
elif isinstance(item, Measure):
|
||||||
item.reset_options(options)
|
item.reset_options(options)
|
||||||
elif options["degrees"] is True and isinstance(item, Pitch) and item.pitch_class is 0:
|
elif options["degrees"] is True and isinstance(item, Pitch) and item.pitch_class == 0:
|
||||||
yield Rest(text="r", kwargs=options)
|
yield Rest(text="r", kwargs=options)
|
||||||
elif isinstance(item, Meta): # Filters whitespace
|
elif isinstance(item, Meta): # Filters whitespace
|
||||||
yield update_item(item, options)
|
yield update_item(item, options)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"""Collection of converters"""
|
"""Collection of converters"""
|
||||||
from ziffers import zparse, Ziffers, Pitch, Rest, Chord, accidentals_from_note_name
|
from ziffers import zparse, Ziffers, Pitch, Rest, Chord, accidentals_from_note_name, MODES, MODE_ACCIDENTALS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from music21 import converter, note, stream, meter, chord, environment, tempo, key
|
from music21 import converter, note, stream, meter, chord, environment, tempo, key
|
||||||
@ -102,8 +102,16 @@ if music21_imported:
|
|||||||
|
|
||||||
if "key" in options:
|
if "key" in options:
|
||||||
accidentals = accidentals_from_note_name(options["key"])
|
accidentals = accidentals_from_note_name(options["key"])
|
||||||
if "scale" in options and options["scale"].upper() == "MINOR":
|
else:
|
||||||
accidentals-=3 # If minor, subtract 3 from accidentals
|
accidentals = 0
|
||||||
|
|
||||||
|
if "scale" in options:
|
||||||
|
scale_upper = options["scale"].upper()
|
||||||
|
scale_lower = options["scale"].lower()
|
||||||
|
if scale_upper in MODES:
|
||||||
|
accidentals += MODE_ACCIDENTALS[scale_upper]
|
||||||
|
note_stream.append(key.KeySignature(accidentals,mode=scale_lower))
|
||||||
|
else:
|
||||||
note_stream.append(key.KeySignature(accidentals))
|
note_stream.append(key.KeySignature(accidentals))
|
||||||
|
|
||||||
if "bpm" in options:
|
if "bpm" in options:
|
||||||
|
|||||||
@ -3,41 +3,50 @@ import operator
|
|||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
|
|
||||||
DEFAULT_DURS = MappingProxyType({
|
DEFAULT_DURS = MappingProxyType({
|
||||||
"m": 8.0, # 15360/1920
|
"m..": 14.0, # Double dotted maxima
|
||||||
"k": 10240 / 1920, # ~5.333
|
"m.": 12.0, # Dotted maxima
|
||||||
"l": 4.0, # 7680/1920
|
"m": 8.0, # Maxima
|
||||||
"d.": 3.0, #
|
"l..": 7.0, # Double dotted long
|
||||||
"p": 5120 / 1920, # ~2.666
|
"l.": 6.0, # Dotted long
|
||||||
"d": 2.0, # 3840/1920
|
"l": 4.0, # Long
|
||||||
"w.": 1.5, # 2280/1920
|
"d..": 7/2, # 3.5: Double dotted double whole
|
||||||
"c": 2560 / 1920, # ~1.333
|
"d.": 3.0, # Dotted double whole
|
||||||
"w": 1.0, # 1920/1920
|
"n": 8/3, # 2.666: Triplet long
|
||||||
"h..": 0.875, # 1680/1920
|
"d": 2.0, # Double whole
|
||||||
"h.": 0.75, # 1440/1920
|
"w..": 7/4, # 1.75: Double dotted whole
|
||||||
"y": 1280 / 1920, # ~0.666
|
"w.": 3/2, # 1.5: Double dotted whole
|
||||||
"h": 0.5, # 960/1920 - 1/2
|
"k": 4/3, # 1.333: Triplet double whole
|
||||||
"q..": 840 / 1920, # ~0.4375
|
"w": 1.0, # Whole
|
||||||
"q.": 0.375, # 720/1920
|
"h..": 7/8, # 0.875: Double dotted half
|
||||||
"n": 640 / 1920, # ~0.333
|
"h.": 3/4, # 0.75: Dotted half
|
||||||
"q": 0.25, # 480/1920 - 1/4
|
"c": 2/3, # 0.666: Triplet whole
|
||||||
"e..": 420 / 1920, # = 0.218
|
"h": 1/2, # 0.5: Half
|
||||||
"e.": 0.1875, # 360/1920
|
"p": 1/3, # 0.333: Triplet half
|
||||||
"a": 320 / 1920, # 0.167 - 1/8
|
"q..": 7/16, # 0.4375: Double dotted quarter
|
||||||
"e": 0.125, # 240/1920
|
"q.": 3/8, # 0.375: Dotted quarter
|
||||||
"s..": 210 / 1920, # ~0.10937
|
"q": 0.25, # Quarter
|
||||||
"s.": 180 / 1920, # ~0.0937
|
"e..": 7/32, # 0.2187: Double dotted eighth
|
||||||
"f": 160 / 1920, # ~0.083 - 1/16
|
"e.": 3/16, # 0.1875: Dotted eighth
|
||||||
"s": 0.0625, # 120/1920
|
"g": 1/6, # 0.1666: Triplet quarter
|
||||||
"t..": 105 / 1920, # ~0.0546
|
"e": 1/8, # 0.125: 8th note
|
||||||
"t.": 90 / 1920, # ~0.0468
|
"s..": 7/64, # 0.1093: Double dotted 16th
|
||||||
"x": 80 / 1920, # ~0.042 - 1/32
|
"a": 1/12, # 0.0833: Triplet 8th
|
||||||
"t": 60 / 1920, # ~0.031
|
"s.": 3/32, # 0.0937: Dotted 16th
|
||||||
"u.": 45 / 1920, # ~0.023
|
"s": 1/16, # 0.0625: 16th note
|
||||||
"g": 40 / 1920, # ~0.021 - 1/64
|
"t..": 7/128, # 0.0546: Double dotted 32th
|
||||||
"u": 30 / 1920, # ~0.016
|
"t.": 3/64, # 0.0468: Dotted 32th
|
||||||
"j": 15 / 1920, # ~0.0078 - 1/128
|
"f": 1/24, # 0.0416: Triplet 16th
|
||||||
"o": 8 / 1920, # ~0.00416
|
"t": 1/32, # 0.0312: 32th note
|
||||||
"z": 0.0, # 0
|
"u..": 7/256, # 0.0273: Double dotted 64th
|
||||||
|
"u.": 3/128, # 0.0234: Dotted 64th
|
||||||
|
"x": 1/48, # 0.0208: Triplet 32th
|
||||||
|
"u": 1/64, # 0.0156: 64th note
|
||||||
|
"o..": 7/512, # 0.0136: Double dotted 128th
|
||||||
|
"y": 1/96, # 0.0104: Triplet 64th
|
||||||
|
"o.": 3/256, # 0.0117: Dotted 128th
|
||||||
|
"o": 1/128, # 0.0078: 128th note
|
||||||
|
"j": 1/192, # 0.0052: Triplet 128th
|
||||||
|
"z": 0.0, # 0
|
||||||
})
|
})
|
||||||
|
|
||||||
DEFAULT_OCTAVE = 4
|
DEFAULT_OCTAVE = 4
|
||||||
@ -115,6 +124,30 @@ CIRCLE_OF_FIFTHS = (
|
|||||||
"Fs",
|
"Fs",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MODES = (
|
||||||
|
"MAJOR",
|
||||||
|
"IONIAN",
|
||||||
|
"MINOR",
|
||||||
|
"AEOLIAN",
|
||||||
|
"DORIAN",
|
||||||
|
"PHRYGIAN",
|
||||||
|
"LYDIAN",
|
||||||
|
"MIXOLYDIAN",
|
||||||
|
"LOCRIAN",
|
||||||
|
)
|
||||||
|
|
||||||
|
MODE_ACCIDENTALS = MappingProxyType({
|
||||||
|
"MAJOR": 0,
|
||||||
|
"IONIAN": 0,
|
||||||
|
"MINOR": -3,
|
||||||
|
"AEOLIAN": -3,
|
||||||
|
"DORIAN": -2,
|
||||||
|
"PHRYGIAN": -4,
|
||||||
|
"LYDIAN": 1,
|
||||||
|
"MIXOLYDIAN": -1,
|
||||||
|
"LOCRIAN": -5,
|
||||||
|
})
|
||||||
|
|
||||||
MODIFIERS = MappingProxyType({
|
MODIFIERS = MappingProxyType({
|
||||||
"#": 1,
|
"#": 1,
|
||||||
"b": -1,
|
"b": -1,
|
||||||
|
|||||||
@ -149,6 +149,7 @@ def get_scale_length(scale: str) -> int:
|
|||||||
|
|
||||||
return len(SCALES.get(scale.lower().capitalize(), SCALES["Ionian"]))
|
return len(SCALES.get(scale.lower().capitalize(), SCALES["Ionian"]))
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=locally-disabled, too-many-arguments
|
# pylint: disable=locally-disabled, too-many-arguments
|
||||||
def note_from_pc(
|
def note_from_pc(
|
||||||
root: int | str,
|
root: int | str,
|
||||||
|
|||||||
Reference in New Issue
Block a user