Skip to content

Commit cd048fa

Browse files
authored
Merge pull request #1762 from gregchapman-dev/gregc/pedalmarks
PedalMark support
2 parents 3fb7eb6 + 4670316 commit cd048fa

File tree

9 files changed

+1152
-19
lines changed

9 files changed

+1152
-19
lines changed

music21/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
'''
5151
from __future__ import annotations
5252

53-
__version__ = '9.6.0b2'
53+
__version__ = '9.6.0b3'
5454

5555
def get_version_tuple(vv):
5656
v = vv.split('.')

music21/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<class 'music21.base.Music21Object'>
2828
2929
>>> music21.VERSION_STR
30-
'9.6.0b2'
30+
'9.6.0b3'
3131
3232
Alternatively, after doing a complete import, these classes are available
3333
under the module "base":

music21/expressions.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,98 @@ def nextMark(self):
325325
return RehearsalMark(self.nextContent(), numbering=self.numbering)
326326

327327

328+
# ------------------------------------------------------------------------------
329+
class PedalType(common.StrEnum):
330+
Sustain = 'sustain'
331+
Sostenuto = 'sostenuto'
332+
Soft = 'soft'
333+
Silent = 'silent'
334+
335+
class PedalForm(common.StrEnum):
336+
Line = 'line'
337+
Symbol = 'symbol'
338+
SymbolAlt = 'symbolalt'
339+
SymbolLine = 'symbolline'
340+
341+
class PedalMark(spanner.Spanner):
342+
'''
343+
A pedal mark spanner contains a pedaled set of notes.
344+
The spanner starts at the moment of down-pedal, and
345+
ends at the moment of up-pedal. There can be any
346+
number of pedal "bounces" in the middle of the spanner.
347+
348+
The visual form of the pedal mark can vary. The following
349+
examples use a pedal mark with one "bounce" in the middle::
350+
351+
Pedal marks can be lines: |_______^________|
352+
Pedal marks can be normal symbolic: Ped. * Ped. *
353+
Pedal marks can be altered symbolic: Ped. Ped. *
354+
Pedal marks can be symbol and line: Ped.____^________|
355+
356+
Pedal marks, whether lines, symbols, or a combination, can
357+
represent the sustain pedal (Ped.), the sostenuto pedal
358+
(Sost.), the soft (una corda) pedal, or (more rarely) the
359+
silent (muting) pedal.
360+
361+
Pedal marks that are symbolic can be abbreviated: e.g. P. instead
362+
of Ped., S. instead of Sost.
363+
364+
Pedal marks that are lines can have non-printed portions
365+
(gaps) in them; these are usually started with "simile",
366+
but not necessarily.
367+
'''
368+
def __init__(
369+
self,
370+
*spannedElements,
371+
**keywords
372+
) -> None:
373+
super().__init__(*spannedElements, **keywords)
374+
from music21 import note
375+
self.fillElementTypes = [note.GeneralNote]
376+
377+
self.pedalType: PedalType|None = None
378+
self.pedalForm: PedalForm|None = None
379+
self.abbreviated: bool = False
380+
self.placement: str|None = None
381+
382+
383+
class PedalObject(base.Music21Object):
384+
'''
385+
Base class of individual objects that mark various transitions
386+
in a PedalMark spanner.
387+
'''
388+
def __init__(self, **keywords) -> None:
389+
super().__init__(**keywords)
390+
self.placement: str | None = None
391+
392+
def _reprInternal(self) -> str:
393+
if self.activeSite is None:
394+
return 'uninserted'
395+
return f'at {self.offset}'
396+
397+
398+
class PedalBounce(PedalObject):
399+
'''
400+
This object, when seen in a PedalMark spanner, represents an up/down bounce
401+
of the pedal.
402+
'''
403+
404+
405+
class PedalGapStart(PedalObject):
406+
'''
407+
This object, when seen in a PedalMark spanner, represents a disappearance of
408+
the pedal line, usually with a TextExpression('simile'). The pedaling should
409+
continue (similarly to before), but the line is invisible during this gap.
410+
'''
411+
412+
413+
class PedalGapEnd(PedalObject):
414+
'''
415+
This object, when seen in a PedalMark spanner, represents the reappearance of
416+
the pedal line.
417+
'''
418+
419+
328420
# ------------------------------------------------------------------------------
329421
class TextExpression(Expression):
330422
'''

0 commit comments

Comments
 (0)