Skip to content

Commit 466bcc8

Browse files
committed
Added Marcato
1 parent d723a2d commit 466bcc8

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

CHANGES

+4
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,7 @@ different panes. Tie/untie option added for notes. Broken rhythm
588588
- Find in files: selecting tune focused wrong tune sometimes
589589
- ABC settings: Added 'Separate defaults per voice' checkbox to Voices tab
590590
- ABC assist supports %%barnumbers (better to use %%measurenb instead)
591+
- ABC assist supports %%percmap (similar to %%MIDI drummap)
592+
- General MIDI 2 percussion instruments added to %%MIDI drummap
593+
- ABC assist supports !marcato! and !editoral!
594+

easy_abc.py

+4
Original file line numberDiff line numberDiff line change
@@ -5283,6 +5283,10 @@ def export_interactive_html(self, tune, filepath):
52835283
f.write(file_header)
52845284
f.write('\n')
52855285
abc = tune.abc
5286+
if '%%MIDI drummap' in abc:
5287+
abc = re.sub(r'%%MIDI drummap\s+(?P<note>[_\^][A-Ga-g])\s+(?P<midinote>\d+)', r'%%percmap \g<note> \g<midinote> x', abc)
5288+
abc = abc.replace('%%MIDI drummap ', '%%percmap ')
5289+
52865290
if self.settings.get('play_chords') or '%%MIDI gchord' in abc:
52875291
# prepend gchordon to each tune body
52885292
abclines = text_to_lines(abc)

img/marcato.png

513 Bytes
Loading

tune_actions.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,9 @@ def __init__(self):
11211121

11221122
class BaseDecorationChangeAction(ValueChangeAction):
11231123
def __init__(self, name, decoration_values, display_name=None):
1124-
values = []
1125-
for mark in decoration_values:
1126-
value = ValueImageDescription(mark, self.get_image_name(mark), decoration_to_description[mark])
1127-
values.append(value)
1124+
values = [ValueImageDescription(mark, self.get_image_name(mark), decoration_to_description[mark]) for mark in decoration_values]
11281125
super(BaseDecorationChangeAction, self).__init__(name, values, 'decoration', display_name=display_name)
11291126

1130-
11311127
def is_current_value(self, context, value):
11321128
match = self.get_match(context)
11331129
current_value = match.group(self.matchgroup)
@@ -1142,6 +1138,7 @@ def get_values(self, context):
11421138
def get_image_name(mark):
11431139
name_lookup = {
11441140
'.': 'staccato',
1141+
'!^!': 'marcato',
11451142
'!upbow!': 'u',
11461143
'!downbow!': 'v',
11471144
'!lowermordent!': 'mordent',
@@ -1322,6 +1319,14 @@ def get_channel_values():
13221319

13231320
class MidiDrumInstrumentChangeAction(ValueChangeAction):
13241321
values = [
1322+
ValueDescription('27', _('High Q'), common=False),
1323+
ValueDescription('28', _('Slap'), common=False),
1324+
ValueDescription('29', _('Scratch Push'), common=False),
1325+
ValueDescription('30', _('Scratch Pull'), common=False),
1326+
ValueDescription('31', _('Sticks'), common=False),
1327+
ValueDescription('32', _('Square Click'), common=False),
1328+
ValueDescription('33', _('Metronome Click'), common=False),
1329+
ValueDescription('34', _('Metronome Bell'), common=False),
13251330
ValueDescription('35', _('Acoustic Bass Drum')),
13261331
ValueDescription('36', _('Bass Drum 1')),
13271332
ValueDescription('37', _('Side Stick')),
@@ -1369,6 +1374,12 @@ class MidiDrumInstrumentChangeAction(ValueChangeAction):
13691374
ValueDescription('79', _('Open Cuica')),
13701375
ValueDescription('80', _('Mute Triangle')),
13711376
ValueDescription('81', _('Open Triangle')),
1377+
ValueDescription('82', _('Shaker'), common=False),
1378+
ValueDescription('83', _('Jingle Bell'), common=False),
1379+
ValueDescription('84', _('Belltree'), common=False),
1380+
ValueDescription('85', _('Castanets'), common=False),
1381+
ValueDescription('86', _('Closed Surdo'), common=False),
1382+
ValueDescription('87', _('Open Surdo'), common=False),
13721383
]
13731384
def __init__(self):
13741385
super(MidiDrumInstrumentChangeAction, self).__init__('change_midi_drum_instrument', MidiDrumInstrumentChangeAction.values, matchgroup='druminstrument', display_name=_('Change percussion instrument'))
@@ -1790,7 +1801,8 @@ class InsertDecorationAction(InsertValueAction):
17901801
ValueImageDescription('!fermata!', 'fermata', _('Articulation')),
17911802
ValueImageDescription('!segno!', 'segno', _('Direction')),
17921803
ValueImageDescription('P', 'pralltriller', _('Shortcut symbol'), common=False),
1793-
ValueImageDescription('!5!', '5', _('Fingering'), common=False)
1804+
ValueImageDescription('!5!', '5', _('Fingering'), common=False),
1805+
ValueImageDescription('!editorial!', 'editorial', _('Accidental'), common=False),
17941806
]
17951807
def __init__(self, name='insert_decoration', matchgroup=None):
17961808
super(InsertDecorationAction, self).__init__(name, InsertDecorationAction.values, matchgroup=matchgroup, display_name=_('Insert decoration'))
@@ -2233,6 +2245,7 @@ class InsertMidiDirectiveAction(InsertValueAction):
22332245
values = [
22342246
ValueDescription(' program 0 % ' + _('Instrument'), _('Set instrument')),
22352247
ValueDescription(' control 7 127 % ' + _('Volume'), _('Set volume')),
2248+
# ValueDescription(' drum dddd 34 33 33 33 100 100 100 100 % {0}\n%%MIDI drumon'.format(_('Metronome')), _('Turn on metronome')),
22362249
ValueDescription(os.linesep.join(play_chords_cmds), _('Play chords')),
22372250
]
22382251
def __init__(self):
@@ -2333,7 +2346,7 @@ class InsertAppendFieldActionEmptyLineAction(InsertValueAction):
23332346
ValueDescription('w:', name_to_display_text['words (note aligned)']),
23342347
ValueDescription('W:', name_to_display_text['words (at the end)'], common=False),
23352348
ValueDescription('s:', name_to_display_text['symbol line'], common=False),
2336-
ValueDescription(r'%%', name_to_display_text['instruction'], common=False),
2349+
ValueDescription(r'%%', name_to_display_text['instruction']),
23372350
]
23382351
def __init__(self):
23392352
super(InsertAppendFieldActionEmptyLineAction, self).__init__('insert_append_field_on_empty_line', InsertAppendFieldActionEmptyLineAction.values, display_name=_('Add...'))

tune_elements.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def __init__(self, value, image_name, description, common=True):
140140

141141
decoration_aliases = {
142142
'!>!' : '!accent!',
143+
'!^!' : '!marcato!',
143144
'!emphasis!': '!accent!',
144145
'!<(!' : '!crescendo(!',
145146
'!<)!' : '!crescendo)!',
@@ -176,6 +177,8 @@ def __init__(self, value, image_name, description, common=True):
176177
'!>!' : _('accent or emphasis'),
177178
'!accent!' : _('accent or emphasis'),
178179
'!emphasis!' : _('accent or emphasis'),
180+
'!^!' : _('marcato'),
181+
'!marcato!' : _('marcato'),
179182
'!fermata!' : _('fermata or hold'),
180183
'!invertedfermata!': _('upside down fermata'),
181184
'!tenuto!' : _('tenuto'),
@@ -230,6 +233,8 @@ def __init__(self, value, image_name, description, common=True):
230233
'!longphrase!' : _('vertical line on the upper part of the staff, extending 3/4 of the way down'),
231234
'!ped!' : _('sustain pedal down'),
232235
'!ped-up!' : _('sustain pedal up'),
236+
'!editorial!' : _('editorial accidental above note'),
237+
'!courtesy!' : _('courtesy accidental between parentheses'),
233238
}
234239

235240
ABC_TUNE_HEADER_NO = 0
@@ -604,7 +609,7 @@ def __init__(self):
604609

605610

606611
class AbcMidiDrumMapDirective(AbcElement):
607-
pattern = r"(?m)^(?:%%|I:)MIDI drummap (?P<note>[_^]*\w[,']*) (?P<druminstrument>\d+)" + AbcElement.rest_of_line_pattern
612+
pattern = r"(?m)^(?:%%|I:)(?:MIDI drummap|percmap) (?P<note>[_^]*\w[,']*) (?P<druminstrument>\d+)" + AbcElement.rest_of_line_pattern
608613
def __init__(self):
609614
super(AbcMidiDrumMapDirective, self).__init__('MIDI_drummap', display_name=_('Drum mapping'), description=_('Maps a note to an instrument.'))
610615
for section in ABC_SECTIONS:
@@ -892,6 +897,7 @@ class AbcArticulationDecoration(AbcDecoration):
892897
'.',
893898
'!tenuto!',
894899
'!accent!', '!>!', '!emphasis!',
900+
'!marcato!', '!^!',
895901
'!wedge!',
896902
'!invertedfermata!',
897903
'!fermata!',

0 commit comments

Comments
 (0)