mutwo.abjad_converters¶
Build Lilypond scores via Abjad from Mutwo data.
The following converter classes help to quantize and translate Mutwo data to
Western notation. Due to the complex nature of this task, Mutwo tries to offer as
many optional arguments as possible through which the user can affect the conversion
routines. The most important class and best starting point for organising a conversion
setting is ConsecutionToAbjadVoice
.
If one wants to build complete scores from within mutwo, the module offers the
NestedCompoundToAbjadContainer
.
Known bugs and limitations:
Indicators attached to rests which follow another rest won’t be translated to abjad. This behaviour happens because
LeafMakerConsecutionToQuantizedAbjadContainer
andNauertConsecutionToQuantizedAbjadContainer
tie rests before converting the data to abjad objects. With a different (maybe user-declared) quantizer this limitation can be fixed. For more details see the comment `here <https://github.com/mutwo-org/mutwo.abjad/blob/58b0044/mutwo/abjad_converters/events/quantization.py#L102-L128>_.Quantization can be slow and not precise. Try both quantization classes. Change the parameters. Use different settings and classes for different parts of your music.
Object |
Documentation |
---|---|
Quantize |
|
|
Quantize |
|
Quantize |
|
Quantize |
|
Quantize |
Convert |
|
|
|
|
|
|
|
Convert Mutwo Pitch objects to Abjad Pitch objects. |
|
Convert tempo envelope to |
|
Convert tempo to |
|
Convert Mutwo Volume objects to |
|
Convert |
|
- class ConsecutionToQuantizedAbjadContainer(default_time_signature_sequence=(TimeSignature(pair=(4, 4), hide=False, partial=None),), event_to_time_signature_tuple=None, is_chronon_rest=None)[source]¶
Bases:
Converter
Quantize
Consecution
objects.- Parameters:
default_time_signature_sequence (Sequence[abjad.TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
Consecution
is longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.event_to_time_signature_tuple (Optional[Callable[[Event], Optional[tuple[abjad.indicators.TimeSignature, ...]]]]) – Function which extracts a tuple[abjad.TimeSignature, …] from a
mutwo.core_events.abc.Event
. If set to None mutwo falls back to default_time_signature_sequence. Default to None.is_chronon_rest (Callable[[core_events.Chronon], bool], optional) – Function to detect if the the inspected
mutwo.core_events.Chronon
is a Rest. By default Mutwo simply checks if ‘pitch_list’ contain any objects. If not, the Event will be interpreted as a rest.
Public Methods:
convert
(consecution_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- abstract convert(consecution_to_convert)[source]¶
- Parameters:
consecution_to_convert (Consecution) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …], tuple[bool, …]]
- class NauertConsecutionToQuantizedAbjadContainer(default_time_signature_sequence=(TimeSignature(pair=(4, 4), hide=False, partial=None), ), duration_unit='beats', attack_point_optimizer=<abjadext.nauert.attackpointoptimizers.MeasurewiseAttackPointOptimizer object>, search_tree=None, **kwargs)[source]¶
Bases:
ConsecutionToQuantizedAbjadContainer
Quantize
Consecution
objects viaabjadext.nauert
.- Parameters:
default_time_signature_sequence (Sequence[abjad.TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
Consecution
is longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.duration_unit (str) – This defines the duration_unit of the passed
Consecution
(how theduration
attribute will be interpreted). Can either be ‘beats’ (default) or ‘miliseconds’. WARNING: ‘miliseconds’ isn’t working properly yet!attack_point_optimizer (Optional[AttackPointOptimizer]) – Optionally the user can pass a
nauert.AttackPointOptimizer
object. Attack point optimizer help to split events and tie them for better looking notation. The default attack point optimizer isnauert.MeasurewiseAttackPointOptimizer
which splits events to better represent metrical structures within bars. If no optimizer is desired this argument can be set toNone
.search_tree (Optional[SearchTree]) –
Unlike
LeafMakerConsecutionToQuantizedAbjadContainer
this converter supports nested tuplets and ties across tuplets. But this converter is much slower than theLeafMakerConsecutionToQuantizedAbjadContainer
. Because the converter depends on the abjad extension nauert its quality is dependent on the inner mechanism of the used package. Because the quantization made by the nauert package can be somewhat indeterministic a lot of tweaking may be necessary for complex musical structures.Public Methods:
convert
(consecution_to_convert)Inherited from
ConsecutionToQuantizedAbjadContainer
convert
(consecution_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- convert(consecution_to_convert)[source]¶
- Parameters:
consecution_to_convert (Consecution) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …], tuple[bool, …]]
- class NauertConsecutionToDurationLineBasedQuantizedAbjadContainer(*args, duration_line_minimum_length=6, duration_line_thickness=3, **kwargs)[source]¶
Bases:
NauertConsecutionToQuantizedAbjadContainer
,_DurationLineBasedQuantizedAbjadContainerMixin
Quantize
Consecution
objects viaabjadext.nauert
.- Parameters:
default_time_signature_sequence (Sequence[abjad.TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
Consecution
is longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.duration_unit – This defines the duration_unit of the passed
Consecution
(how theduration
attribute will be interpreted). Can either be ‘beats’ (default) or ‘miliseconds’. WARNING: ‘miliseconds’ isn’t working properly yet!attack_point_optimizer – Optionally the user can pass a
nauert.AttackPointOptimizer
object. Attack point optimizer help to split events and tie them for better looking notation. The default attack point optimizer isnauert.MeasurewiseAttackPointOptimizer
which splits events to better represent metrical structures within bars. If no optimizer is desired this argument can be set toNone
.duration_line_minimum_length (int) – The minimum length of a duration line.
duration_line_thickness (int) – The thickness of a duration line.
This converter differs from its parent class through the usage of duration lines for indicating rhythm instead of using flags, beams, dots and note head colors.
Note:
Don’t forget to add the ‘Duration_line_engraver’ to the resulting abjad Voice, otherwise Lilypond won’t be able to render the desired output.
Example:
>>> import abjad >>> from mutwo import abjad_converters >>> from mutwo import core_events, music_events >>> converter = abjad_converters.ConsecutionToAbjadVoice( ... abjad_converters.LeafMakerConsecutionToDurationLineBasedQuantizedAbjadContainer( ... ) ... ) >>> seq = core_events.Consecution( ... [ ... music_events.NoteLike("c", 0.25), ... music_events.NoteLike("d", 1), ... music_events.NoteLike([], 0.25), ... music_events.NoteLike("e", 1), ... music_events.NoteLike("e", 1) ... ] ... ) >>> voice = converter.convert(seq) >>> voice.consists_commands.append("Duration_line_engraver")
Public Methods:
convert
(consecution_to_convert)Inherited from
NauertConsecutionToQuantizedAbjadContainer
convert
(consecution_to_convert)Inherited from
ConsecutionToQuantizedAbjadContainer
convert
(consecution_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- convert(consecution_to_convert)[source]¶
- Parameters:
consecution_to_convert (Consecution) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …], tuple[bool, …]]
- class LeafMakerConsecutionToQuantizedAbjadContainer(*args, do_rewrite_meter=True, add_beams=True, concatenate_adjacent_tuplets=True, reduce_multiplier=True, **kwargs)[source]¶
Bases:
ConsecutionToQuantizedAbjadContainer
Quantize
Consecution
object viaabjad.LeafMaker
.- Parameters:
default_time_signature_sequence (Sequence[abjad.TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
Consecution
is longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.concatenate_adjacent_tuplets (bool) – Set to True if quantizer should concatenate adjacent tuplets via
mutwo.abjad_utilities.concatenate_adjacent_tuplets()
. Because this function can make processing slower (and may lead to not-yet-fixed bugs) it can be deactivated if not used. Default to True.reduce_multiplier (bool) – Set to True if quantizer should call
mutwo.abjad_utilities.reduce_multiplier()
after consecution has been quantized. Can be useful if working with tuplets. If no tuplets are used it can be deactivated for faster conversion. Default toTrue
.do_rewrite_meter (bool) –
add_beams (bool) –
This method is significantly faster than the
NauertConsecutionToQuantizedAbjadContainer
. But it also has several known limitations:LeafMakerConsecutionToQuantizedAbjadContainer
doesn’t support nested tuplets.LeafMakerConsecutionToQuantizedAbjadContainer
doesn’t support ties across tuplets with different prolation (or across tuplets and not-tuplet notation). If ties are desired the user has to build them manually before passing theConsecution
to the converter.
Public Methods:
convert
(consecution_to_convert)Inherited from
ConsecutionToQuantizedAbjadContainer
convert
(consecution_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- convert(consecution_to_convert)[source]¶
- Parameters:
consecution_to_convert (Consecution) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …], tuple[bool, …]]
- class LeafMakerConsecutionToDurationLineBasedQuantizedAbjadContainer(*args, duration_line_minimum_length=6, duration_line_thickness=3, **kwargs)[source]¶
Bases:
LeafMakerConsecutionToQuantizedAbjadContainer
,_DurationLineBasedQuantizedAbjadContainerMixin
Quantize
Consecution
object viaabjad.LeafMaker
.- Parameters:
default_time_signature_sequence (Sequence[abjad.TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
Consecution
is longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.concatenate_adjacent_tuplets (bool) – Set to True if quantizer should concatenate adjacent tuplets via
mutwo.abjad_utilities.concatenate_adjacent_tuplets()
. Because this function can make processing slower (and may lead to not-yet-fixed bugs) it can be deactivated if not used. Default to True.reduce_multiplier (bool) – Set to True if quantizer should call
mutwo.abjad_utilities.reduce_multiplier()
after consecution has been quantized. Can be useful if working with tuplets. If no tuplets are used it can be deactivated for faster conversion. Default toTrue
.duration_line_minimum_length (int) – The minimum length of a duration line.
duration_line_thickness (int) – The thickness of a duration line.
This converter differs from its parent class through the usage of duration lines for indicating rhythm instead of using flags, beams, dots and note head colors.
Note:
Don’t forget to add the ‘Duration_line_engraver’ to the resulting abjad Voice, otherwise Lilypond won’t be able to render the desired output.
Example:
>>> import abjad >>> from mutwo import abjad_converters >>> from mutwo import core_events, music_events >>> converter = abjad_converters.ConsecutionToAbjadVoice( ... abjad_converters.LeafMakerConsecutionToDurationLineBasedQuantizedAbjadContainer( ... ) ... ) >>> seq = core_events.Consecution( ... [ ... music_events.NoteLike("c", 0.25), ... music_events.NoteLike("d", 1), ... music_events.NoteLike([], 0.25), ... music_events.NoteLike("e", 1), ... music_events.NoteLike("e", 1) ... ] ... ) >>> voice = converter.convert(seq) >>> voice.consists_commands.append("Duration_line_engraver")
Public Methods:
convert
(consecution_to_convert)Inherited from
LeafMakerConsecutionToQuantizedAbjadContainer
convert
(consecution_to_convert)Inherited from
ConsecutionToQuantizedAbjadContainer
convert
(consecution_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- convert(consecution_to_convert)[source]¶
- Parameters:
consecution_to_convert (Consecution) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …], tuple[bool, …]]
- class CompoundToAbjadContainer(abjad_container_class, lilypond_type_of_abjad_container, compound_to_abjad_container_name, pre_process_abjad_container_routine_sequence, post_process_abjad_container_routine_sequence)[source]¶
Bases:
Converter
Public Methods:
convert
(compound_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- Parameters:
abjad_container_class (Type[Container]) –
lilypond_type_of_abjad_container (str) –
compound_to_abjad_container_name (Callable[[Compound], str]) –
pre_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
post_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
- class ConsecutionToAbjadVoice(consecution_to_quantized_abjad_container=LeafMakerConsecutionToQuantizedAbjadContainer(), default_tempo=FlexTempo(30.0), chronon_to_pitch_list=ChrononToPitchList(), chronon_to_volume=ChrononToVolume(), chronon_to_grace_note_consecution=ChrononToGraceNoteConsecution(), chronon_to_after_grace_note_consecution=ChrononToAfterGraceNoteConsecution(), chronon_to_playing_indicator_collection=ChrononToPlayingIndicatorCollection(), chronon_to_notation_indicator_collection=ChrononToNotationIndicatorCollection(), chronon_to_lyric=ChrononToLyric(), mutwo_pitch_to_abjad_pitch=MutwoPitchToAbjadPitch(), mutwo_volume_to_abjad_attachment_dynamic=MutwoVolumeToAbjadAttachmentDynamic(), tempo_to_abjad_attachment_tempo=ComplexTempoToAbjadAttachmentTempo(), mutwo_lyric_to_abjad_string=MutwoLyricToAbjadString(), event_to_tempo=None, abjad_attachment_class_sequence=None, write_multimeasure_rests=True, abjad_container_class=<class 'abjad.score.Voice'>, lilypond_type_of_abjad_container='Voice', compound_to_abjad_container_name=<function ConsecutionToAbjadVoice.<lambda>>, pre_process_abjad_container_routine_sequence=(), post_process_abjad_container_routine_sequence=(), duration_line_engraver=True, prepare_for_duration_line_based_notation=True)[source]¶
Bases:
CompoundToAbjadContainer
Convert
Consecution
toabjad.Voice
.- Parameters:
consecution_to_quantized_abjad_container (ConsecutionToQuantizedAbjadContainer, optional) – Class which defines how the Mutwo data will be quantized. See
ConsecutionToQuantizedAbjadContainer
for more information.default_tempo (core_parameters.abc.Tempo) – Fallback value in case event_to_tempo is set to None or returns None. This is the default for now, but likely to be removed in the future. If possible, better use event_to_tempo.
chronon_to_pitch_list (Callable[[core_events.Chronon], music_parameters.abc.Pitch], optional) – Function to extract from a
mutwo.core_events.Chronon
a tuple that contains pitch objects (objects that inherit frommutwo.music_parameters.abc.Pitch
). By default it asks the Event for itspitch_list
attribute (because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their pitch property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no pitch can be extracted), mutwo will assume an event without any pitches.chronon_to_volume (Callable[[core_events.Chronon], music_parameters.abc.Volume], optional) – Function to extract the volume from a
mutwo.core_events.Chronon
in the purpose of generating dynamic indicators. The function should return an object that inherits frommutwo.music_parameters.abc.Volume
. By default it asks the Event for itsvolume
attribute (because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their volume property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no volume can be extracted), mutwo will setpitch_list
to an empty list and set volume to 0.chronon_to_grace_note_consecution (Callable[[core_events.Chronon], core_events.Consecution[core_events.Chronon]], optional) – Function to extract from a
mutwo.core_events.Chronon
aConsecution
object filled withChronon
. By default it asks the Event for itsgrace_note_consecution
attribute (because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their grace_note_consecution property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no grace_note_consecution can be extracted), mutwo will use an emptyConsecution
.chronon_to_after_grace_note_consecution (Callable[[core_events.Chronon], core_events.Consecution[core_events.Chronon]], optional) – Function to extract from a
mutwo.core_events.Chronon
aConsecution
object filled withChronon
. By default it asks the Event for itsafter_grace_note_consecution
attribute (because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their after_grace_note_consecution property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no after_grace_note_consecution can be extracted), mutwo will use an emptyConsecution
.chronon_to_playing_indicator_collection (Callable[[core_events.Chronon], music_parameters.PlayingIndicatorCollection,], optional) – Function to extract from a
mutwo.core_events.Chronon
amutwo.music_parameters.playing_indicators.PlayingIndicatorCollection
object. By default it asks the Event for itsplaying_indicator_collection
attribute (because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their playing_indicators property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no playing indicator collection can be extracted), mutwo will build a playing indicator collection fromDEFAULT_PLAYING_INDICATORS_COLLECTION_CLASS
.chronon_to_notation_indicator_collection (Callable[[core_events.Chronon], music_parameters.NotationIndicatorCollection,], optional) – Function to extract from a
mutwo.core_events.Chronon
amutwo.music_parameters.notation_indicators.NotationIndicatorCollection
object. By default it asks the Event for itsnotation_indicators
(because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their playing_indicators property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no notation indicator collection can be extracted), mutwo will build a notation indicator collection fromDEFAULT_NOTATION_INDICATORS_COLLECTION_CLASS
chronon_to_lyric (Callable[[core_events.Chronon], music_parameters.abc.Lyric], optional) – Function to extract the lyric from a
mutwo.core_events.Chronon
in the purpose of generating lyrics. The function should return an object that inherits frommutwo.music_parameters.abc.Lyric
. By default it asks the Event for itslyric
attribute (because by defaultmutwo.music_events.NoteLike
objects are expected). When using different Event classes thanNoteLike
with a different name for their lyric property, this argument should be overridden. If the function call raises anAttributeError
(e.g. if no lyric can be extracted), mutwo will setlyric
to an empty text.mutwo_pitch_to_abjad_pitch (MutwoPitchToAbjadPitch, optional) – Class which defines how to convert
mutwo.music_parameters.abc.Pitch
objects toabjad.Pitch
objects. SeeMutwoPitchToAbjadPitch
for more information.mutwo_volume_to_abjad_attachment_dynamic (MutwoVolumeToAbjadAttachmentDynamic, optional) – Class which defines how to convert
mutwo.music_parameters.abc.Volume
objects tomutwo.abjad_parameters.Dynamic
objects. SeeMutwoVolumeToAbjadAttachmentDynamic
for more information.tempo_to_abjad_attachment_tempo (TempoToAbjadAttachmentTempo, optional) – Class which defines how to convert tempo envelopes to
mutwo.abjad_parameters.Tempo
objects. SeeTempoToAbjadAttachmentTempo
for more information.mutwo_lyric_to_abjad_string (MutwoLyricToAbjadString) – Callable which defines how to convert
mutwo.music_parameters.abc.Lyric
to a string. Consultmutwo.abjad_converters.MutwoLyricToAbjadString
for more information.event_to_tempo (Optional[Callable[[core_events.abc.Event], Optional[core_parameters.abc.Tempo]]]) – A function which extracts a
mutwo.core_parameters.abc.Tempo
from amutwo.core_events.abc.Event
. If set to None or if the function returns None mutwo falls back to default_tempo. Default toNone
, but this will likely change in the future.abjad_attachment_class_sequence (Sequence[abjad_parameters.abc.AbjadAttachment], optional) – A tuple which contains all available abjad attachment classes which shall be used by the converter.
write_multimeasure_rests (bool) – Set to
True
if the converter should replace rests that last a complete bar with multimeasure rests (rests with uppercase “R” in Lilypond). Default toTrue
.duration_line_engraver (bool) – If consecution_to_quantized_abjad_container is any duration line based converter, the converter adds
mutwo.abjad_converters.AddDurationLineEngraver
to post_process_abjad_container_routine_sequence. Default toTrue
.prepare_for_duration_line_based_notation (bool) – If consecution_to_quantized_abjad_container is any duration line based converter, the converter adds
mutwo.abjad_converters.PrepareForDurationLineBasedNotation
to post_process_abjad_container_routine_sequence. Default toTrue
.abjad_container_class (Type[Container]) –
lilypond_type_of_abjad_container (str) –
compound_to_abjad_container_name (Callable[[Compound], Optional[str]]) –
pre_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
post_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
Public Methods:
convert
(consecution_to_convert)Convert passed
Consecution
.Inherited from
CompoundToAbjadContainer
convert
(compound_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- ExtractedData¶
alias of
tuple
[list
[Pitch
],Volume
,Consecution
[Chronon
],Consecution
[Chronon
],PlayingIndicatorCollection
,NotationIndicatorCollection
,Lyric
]
- ExtractedDataPerChronon¶
alias of
tuple
[tuple
[list
[Pitch
],Volume
,Consecution
[Chronon
],Consecution
[Chronon
],PlayingIndicatorCollection
,NotationIndicatorCollection
,Lyric
], …]
- convert(consecution_to_convert)[source]¶
Convert passed
Consecution
.- Parameters:
consecution_to_convert (mutwo.core_events.Consecution) – The
Consecution
which shall be converted to theabjad.Voice
object.- Return type:
Voice
Example:
>>> import abjad >>> from mutwo import core_events, music_events >>> from mutwo import abjad_converters >>> seq = core_events.Consecution( ... [ ... music_events.NoteLike(p, d) ... for p, d in zip("c a g e".split(" "), (1, 1 / 6, 1 / 6, 1 / 6)) ... ] ... ) >>> converter = abjad_converters.ConsecutionToAbjadVoice() >>> voice = converter.convert(seq)
- class NestedCompoundToAbjadContainer(nested_compound_to_compound_to_abjad_container_converters_converter, abjad_container_class, lilypond_type_of_abjad_container, compound_to_abjad_container_name=<function NestedCompoundToAbjadContainer.<lambda>>, pre_process_abjad_container_routine_sequence=(), post_process_abjad_container_routine_sequence=())[source]¶
Bases:
CompoundToAbjadContainer
Public Methods:
Inherited from
CompoundToAbjadContainer
convert
(compound_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- Parameters:
nested_compound_to_compound_to_abjad_container_converters_converter (NestedCompoundToCompoundToAbjadContainers) –
abjad_container_class (Type[Container]) –
lilypond_type_of_abjad_container (str) –
compound_to_abjad_container_name (Callable[[Compound], str]) –
pre_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
post_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
- class NestedCompoundToCompoundToAbjadContainers[source]¶
Bases:
Converter
Public Methods:
convert
(nested_compound_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- abstract convert(nested_compound_to_convert)[source]¶
- Parameters:
nested_compound_to_convert (Compound) –
- Return type:
tuple[mutwo.abjad_converters.events.building.CompoundToAbjadContainer, …]
- class CycleBasedNestedCompoundToCompoundToAbjadContainers(compound_to_abjad_container_converter_sequence)[source]¶
Bases:
NestedCompoundToCompoundToAbjadContainers
Public Methods:
convert
(nested_compound_to_convert)Inherited from
NestedCompoundToCompoundToAbjadContainers
convert
(nested_compound_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- Parameters:
compound_to_abjad_container_converter_sequence (Sequence[CompoundToAbjadContainer]) –
- convert(nested_compound_to_convert)[source]¶
- Parameters:
nested_compound_to_convert (Compound) –
- Return type:
tuple[mutwo.abjad_converters.events.building.CompoundToAbjadContainer, …]
- class TagBasedNestedCompoundToCompoundToAbjadContainers(tag_to_abjad_converter_dict, compound_to_tag=<function TagBasedNestedCompoundToCompoundToAbjadContainers.<lambda>>)[source]¶
Bases:
NestedCompoundToCompoundToAbjadContainers
Public Methods:
convert
(nested_compound_to_convert)Inherited from
NestedCompoundToCompoundToAbjadContainers
convert
(nested_compound_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- Parameters:
tag_to_abjad_converter_dict (dict[str, mutwo.abjad_converters.events.building.CompoundToAbjadContainer]) –
compound_to_tag (Callable[[Compound], str]) –
- convert(nested_compound_to_convert)[source]¶
- Parameters:
nested_compound_to_convert (Compound) –
- Return type:
tuple[mutwo.abjad_converters.events.building.CompoundToAbjadContainer, …]
- class MutwoLyricToAbjadString[source]¶
Bases:
Converter
Public Methods:
convert
(mutwo_lyric_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- class MutwoPitchToAbjadPitch(allowed_division_sequence=(Fraction(1, 2),))[source]¶
Bases:
Converter
Convert Mutwo Pitch objects to Abjad Pitch objects.
- Parameters:
allowed_division_sequence (Sequence[fractions.Fraction]) –
MutwoPitchToAbjadPitch
rounds microtonalmusic_parameters.WesternPitch
in order to make them notatable with Lilypond. By default they are rounded to quarter-tones (because Lilypond support quarter-tones). If you’d like to omit quarter tones you can set this to(fractions.Fraction(1, 1),)
. See also the documentation of round_to method frommusic_parameters.WesternPitch
for further information.
This default class simply checks if the passed Mutwo object belongs to
mutwo.music_parameters.WesternPitch
. If it does, Mutwo will initialise the Abjad Pitch from thename
attribute. Otherwise Mutwo will simply initialise the Abjad Pitch from the objectshertz
attribute.If users desire to make more complex conversions (for instance due to
scordatura
or transpositions of instruments), one can simply inherit from this class to define more complex cases.Public Methods:
convert
(pitch_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- class TempoToAbjadAttachmentTempo[source]¶
Bases:
Converter
Convert tempo envelope to
Tempo
.Abstract base class for tempo envelope conversion. See
ComplexTempoToAbjadAttachmentTempo
for a concrete class.Public Methods:
convert
(tempo_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- abstract convert(tempo_to_convert)[source]¶
- Parameters:
tempo_to_convert (Tempo) –
- Return type:
tuple[tuple[float | fractions.Fraction | int | quicktions.Fraction, mutwo.abjad_parameters.attachments.Tempo], …]
- class ComplexTempoToAbjadAttachmentTempo[source]¶
Bases:
TempoToAbjadAttachmentTempo
Convert tempo to
Tempo
.This object tries to intelligently set correct tempo abjad_parameters to an
abjad.Voice
object, appropriate to Western notation standards. Therefore it will not repeat tempo indications if they are merely repetitions of previous tempo indications and it will write ‘a tempo’ when returning to the same tempo after ritardandi or accelerandi.Public Methods:
convert
(tempo_to_convert)Inherited from
TempoToAbjadAttachmentTempo
convert
(tempo_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- convert(tempo_to_convert)[source]¶
- Parameters:
tempo_to_convert (Tempo) –
- Return type:
tuple[tuple[float | fractions.Fraction | int | quicktions.Fraction, mutwo.abjad_parameters.attachments.Tempo], …]
- class MutwoVolumeToAbjadAttachmentDynamic[source]¶
Bases:
Converter
Convert Mutwo Volume objects to
Dynamic
.This default class simply checks if the passed Mutwo object belongs to
mutwo.music_parameters.WesternVolume
. If it does, Mutwo will initialise theTempo
object from thename
attribute. Otherwise Mutwo will first initialise aWesternVolume
object via its py:method:mutwo.music_parameters.WesternVolume.from_amplitude method.Hairpins aren’t notated with the aid of
mutwo.music_parameters.abc.Volume
objects, but withmutwo.music_parameters.Hairpin
.Public Methods:
convert
(volume_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- class MutwoPitchToHEJIAbjadPitch(reference_pitch='a', prime_to_heji_accidental_name=None, otonality_indicator=None, utonality_indicator=None, exponent_to_exponent_indicator=None, tempered_pitch_indicator=None)[source]¶
Bases:
MutwoPitchToAbjadPitch
Convert
JustIntonationPitch
to abjad pitches.- Parameters:
reference_pitch (str, optional) – The reference pitch (1/1). Should be a diatonic pitch name (see
DIATONIC_PITCH_CLASS_CONTAINER
) in English nomenclature. For any other reference pitch than ‘c’, Lilyponds midi rendering for pitches with the diatonic pitch ‘c’ will be slightly out of tune (because the first value of :arg:`global_scale` always have to be 0).prime_to_heji_accidental_name (dict[int, str], optional) – Mapping of a prime number to a string which indicates the respective prime number in the resulting accidental name. See
mutwo.ekmelily_converters.configurations.DEFAULT_PRIME_TO_HEJI_ACCIDENTAL_NAME_DICT
for the default mapping.otonality_indicator (str, optional) – String which indicates that the respective prime alteration is otonal. See
mutwo.ekmelily_converters.configurations.DEFAULT_OTONALITY_INDICATOR
for the default value.utonality_indicator (str, optional) – String which indicates that the respective prime alteration is utonal. See
mutwo.ekmelily_converters.configurations.DEFAULT_OTONALITY_INDICATOR
for the default value.exponent_to_exponent_indicator (Callable[[int], str], optional) – Function to convert the exponent of a prime number to string which indicates the respective exponent. See
mutwo.ekmelily_converters.configurations.DEFAULT_EXPONENT_TO_EXPONENT_INDICATOR()
for the default function.tempered_pitch_indicator (str, optional) – String which indicates that the respective accidental is tempered (12 EDO). See
mutwo.ekmelily_converters.configurations.DEFAULT_TEMPERED_PITCH_INDICATOR
for the default value.
The resulting Abjad pitches are expected to be used in combination with tuning files that are generated by
mutwo.ekmelily_converters.HEJIEkmelilyTuningFileConverter
and with the Lilypond extension Ekmelily. You can find pre-generated tuning files here.Example:
>>> from mutwo import music_parameters >>> from mutwo import abjad_converters >>> p = music_parameters.JustIntonationPitch('5/4') >>> converter_on_a = abjad_converters.MutwoPitchToHEJIAbjadPitch(reference_pitch='a') >>> converter_on_c = abjad_converters.MutwoPitchToHEJIAbjadPitch(reference_pitch='c') >>> converter_on_a.convert(p) NamedPitch("csoaa''") >>> converter_on_c.convert(p) NamedPitch("eoaa'")
Public Methods:
convert
(pitch_to_convert)Inherited from
MutwoPitchToAbjadPitch
convert
(pitch_to_convert)Inherited from
MutwoObject
copy
()Return a deep copy of mutwo object.
- class AddDurationLineEngraver[source]¶
Bases:
ProcessAbjadContainerRoutine
- class PrepareForDurationLineBasedNotation[source]¶
Bases:
ProcessAbjadContainerRoutine
- class AddInstrumentName(compound_to_instrument_name=<function AddInstrumentName.<lambda>>, compound_to_short_instrument_name=<function AddInstrumentName.<lambda>>, instrument_name_font_size='teeny', short_instrument_name_font_size='teeny')[source]¶
Bases:
ProcessAbjadContainerRoutine
- class AddAccidentalStyle(accidental_style)[source]¶
Bases:
ProcessAbjadContainerRoutine
- Parameters:
accidental_style (str) –
- class SetStaffSize(difference_of_size)[source]¶
Bases:
ProcessAbjadContainerRoutine
- Parameters:
difference_of_size (int) –
mutwo.abjad_converters.configurations¶
Configure mutwo.abjad_converters
.
- DEFAULT_ABJAD_ATTACHMENT_CLASS_TUPLE = (<class 'mutwo.abjad_parameters.attachments.AfterGraceNoteConsecution'>, <class 'mutwo.abjad_parameters.attachments.Arpeggio'>, <class 'mutwo.abjad_parameters.attachments.Articulation'>, <class 'mutwo.abjad_parameters.attachments.ArtificalHarmonic'>, <class 'mutwo.abjad_parameters.attachments.BarLine'>, <class 'mutwo.abjad_parameters.attachments.BartokPizzicato'>, <class 'mutwo.abjad_parameters.attachments.BendAfter'>, <class 'mutwo.abjad_parameters.attachments.BreathMark'>, <class 'mutwo.abjad_parameters.attachments.Clef'>, <class 'mutwo.abjad_parameters.attachments.Cue'>, <class 'mutwo.abjad_parameters.attachments.DurationLineDashed'>, <class 'mutwo.abjad_parameters.attachments.DurationLineTriller'>, <class 'mutwo.abjad_parameters.attachments.Dynamic'>, <class 'mutwo.abjad_parameters.attachments.DynamicChangeIndicationStop'>, <class 'mutwo.abjad_parameters.attachments.Fermata'>, <class 'mutwo.abjad_parameters.attachments.Glissando'>, <class 'mutwo.abjad_parameters.attachments.GraceNoteConsecution'>, <class 'mutwo.abjad_parameters.attachments.Hairpin'>, <class 'mutwo.abjad_parameters.attachments.LaissezVibrer'>, <class 'mutwo.abjad_parameters.attachments.MarginMarkup'>, <class 'mutwo.abjad_parameters.attachments.Markup'>, <class 'mutwo.abjad_parameters.attachments.NaturalHarmonicNodeList'>, <class 'mutwo.abjad_parameters.attachments.Ornamentation'>, <class 'mutwo.abjad_parameters.attachments.Ottava'>, <class 'mutwo.abjad_parameters.attachments.Pedal'>, <class 'mutwo.abjad_parameters.attachments.Prall'>, <class 'mutwo.abjad_parameters.attachments.RehearsalMark'>, <class 'mutwo.abjad_parameters.attachments.Slur'>, <class 'mutwo.abjad_parameters.attachments.StringContactPoint'>, <class 'mutwo.abjad_parameters.attachments.Tempo'>, <class 'mutwo.abjad_parameters.attachments.Tie'>, <class 'mutwo.abjad_parameters.attachments.Tremolo'>, <class 'mutwo.abjad_parameters.attachments.Trill'>, <class 'mutwo.abjad_parameters.attachments.WoodwindFingering'>)¶
Default value for argument abjad_attachment_classes in
ConsecutionToAbjadVoiceConverter
.
mutwo.abjad_converters.constants¶
Constants for mutwo.abjad_converters
.
- INEFFECTIVE_INDICATOR_FOR_MULTIMEASURE_REST_TUPLE = (<class 'abjad.indicators.Fermata'>,)¶
Define indicators which don’t work with multimeasure rests.
Some indicators aren’t rendered in Lilypond when applied to multimeasure rests. Therefore mutwo.abjad avoids creating multimeasure rests if a to a rest any of the given indicator classes where attached.