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 SequentialEventToAbjadVoiceConverter.
If one wants to build complete scores from within mutwo, the module offers the
NestedComplexEventToAbjadContainerConverter.
Known bugs and limitations:
Indicators attached to rests which follow another rest won’t be translated to abjad. This behaviour happens because the
SequentialEventToAbjadVoiceConverterties rests before converting the data to abjad objects.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.
- class SequentialEventToQuantizedAbjadContainer(time_signature_sequence=(TimeSignature((4, 4)),), tempo_envelope=None)[source]§
Quantize
SequentialEventobjects.- Parameters:
time_signature_sequence (Sequence[TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
SequentialEventis longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.tempo_envelope (TempoEnvelope) – Defines the tempo of the converted music. This is an
core_events.TempoEnvelopeobject which durations are beats and which levels are either numbers (that will be interpreted as beats per minute (‘BPM’)) orTempoPointobjects. If no tempo envelope has been defined, Mutwo will assume a constant tempo of 1/4 = 120 BPM.
Public Data Attributes:
Public Methods:
__init__([time_signature_sequence, ...])convert(sequential_event_to_convert)Inherited from
Converterconvert(sequential_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- abstract convert(sequential_event_to_convert)[source]§
- Parameters:
sequential_event_to_convert (SequentialEvent) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …]]
- property tempo_envelope: TempoEnvelope§
- class NauertSequentialEventToQuantizedAbjadContainer(time_signature_sequence=(TimeSignature((4, 4)), ), duration_unit='beats', tempo_envelope=None, attack_point_optimizer=<abjadext.nauert.attackpointoptimizers.MeasurewiseAttackPointOptimizer object>, search_tree=None)[source]§
Quantize
SequentialEventobjects viaabjadext.nauert.- Parameters:
time_signature_sequence (Sequence[TimeSignature]) – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
SequentialEventis 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
SequentialEvent(how thedurationattribute will be interpreted). Can either be ‘beats’ (default) or ‘miliseconds’. WARNING: ‘miliseconds’ isn’t working properly yet!tempo_envelope (TempoEnvelope) – Defines the tempo of the converted music. This is an
core_events.TempoEnvelopeobject which durations are beats and which levels are either numbers (that will be interpreted as beats per minute (‘BPM’)) orTempoPointobjects. If no tempo envelope has been defined, Mutwo will assume a constant tempo of 1/4 = 120 BPM.attack_point_optimizer (Optional[AttackPointOptimizer]) – Optionally the user can pass a
nauert.AttackPointOptimizerobject. Attack point optimizer help to split events and tie them for better looking notation. The default attack point optimizer isnauert.MeasurewiseAttackPointOptimizerwhich 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
LeafMakerSequentialEventToQuantizedAbjadContainerthis converter supports nested tuplets and ties across tuplets. But this converter is much slower than theLeafMakerSequentialEventToQuantizedAbjadContainer. 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 Data Attributes:
Inherited from
SequentialEventToQuantizedAbjadContainerPublic Methods:
__init__([time_signature_sequence, ...])convert(sequential_event_to_convert)Inherited from
SequentialEventToQuantizedAbjadContainer__init__([time_signature_sequence, ...])convert(sequential_event_to_convert)Inherited from
Converterconvert(sequential_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
SequentialEventToQuantizedAbjadContainer_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- convert(sequential_event_to_convert)[source]§
- Parameters:
sequential_event_to_convert (SequentialEvent) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …]]
- property tempo_envelope: TempoEnvelope§
- class NauertSequentialEventToDurationLineBasedQuantizedAbjadContainer(*args, duration_line_minimum_length=6, duration_line_thickness=3, **kwargs)[source]§
Quantize
SequentialEventobjects viaabjadext.nauert.- Parameters:
time_signature_sequence – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
SequentialEventis 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
SequentialEvent(how thedurationattribute will be interpreted). Can either be ‘beats’ (default) or ‘miliseconds’. WARNING: ‘miliseconds’ isn’t working properly yet!tempo_envelope – Defines the tempo of the converted music. This is an
core_events.TempoEnvelopeobject which durations are beats and which levels are either numbers (that will be interpreted as beats per minute (‘BPM’)) orTempoPointobjects. If no tempo envelope has been defined, Mutwo will assume a constant tempo of 1/4 = 120 BPM.attack_point_optimizer – Optionally the user can pass a
nauert.AttackPointOptimizerobject. Attack point optimizer help to split events and tie them for better looking notation. The default attack point optimizer isnauert.MeasurewiseAttackPointOptimizerwhich 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 >>> converter = abjad_converters.SequentialEventToAbjadVoiceConverter( >>> abjad_converters.LeafMakerSequentialEventToDurationLineBasedQuantizedAbjadContainer( >>> ) >>> ) >>> sequential_event_to_convert = core_events.SequentialEvent( >>> [ >>> music_events.NoteLike("c", 0.125), >>> music_events.NoteLike("d", 1), >>> music_events.NoteLike([], 0.125), >>> music_events.NoteLike("e", 0.16666), >>> music_events.NoteLike("e", 0.08333333333333333) >>> ] >>> ) >>> converted_sequential_event = converter.convert(sequential_event_to_convert) >>> converted_sequential_event.consists_commands.append("Duration_line_engraver")
Public Data Attributes:
Inherited from
SequentialEventToQuantizedAbjadContainerPublic Methods:
__init__(*args[, ...])convert(sequential_event_to_convert)Inherited from
NauertSequentialEventToQuantizedAbjadContainer__init__(*args[, ...])convert(sequential_event_to_convert)Inherited from
SequentialEventToQuantizedAbjadContainer__init__(*args[, ...])convert(sequential_event_to_convert)Inherited from
Converterconvert(sequential_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Inherited from
_DurationLineBasedQuantizedAbjadContainerMixin__init__(*args[, ...])Private Data Attributes:
_abc_implInherited from
NauertSequentialEventToQuantizedAbjadContainer_abc_implInherited from
SequentialEventToQuantizedAbjadContainer_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- convert(sequential_event_to_convert)[source]§
- Parameters:
sequential_event_to_convert (SequentialEvent) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …]]
- property tempo_envelope: TempoEnvelope§
- class LeafMakerSequentialEventToQuantizedAbjadContainer(*args, do_rewrite_meter=True, add_beams=True, **kwargs)[source]§
Quantize
SequentialEventobject viaabjad.LeafMaker.- Parameters:
time_signature_sequence – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
SequentialEventis longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.tempo_envelope – Defines the tempo of the converted music. This is an
core_events.TempoEnvelopeobject which durations are beats and which levels are either numbers (that will be interpreted as beats per minute (‘BPM’)) orTempoPointobjects. If no tempo envelope has been defined, Mutwo will assume a constant tempo of 1/4 = 120 BPM.do_rewrite_meter (bool) –
add_beams (bool) –
This method is significantly faster than the
NauertSequentialEventToQuantizedAbjadContainer. But it also has several known limitations:LeafMakerSequentialEventToQuantizedAbjadContainerdoesn’t support nested tuplets.LeafMakerSequentialEventToQuantizedAbjadContainerdoesn’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 theSequentialEventto the converter.
Public Data Attributes:
Inherited from
SequentialEventToQuantizedAbjadContainerPublic Methods:
__init__(*args[, do_rewrite_meter, add_beams])convert(sequential_event_to_convert)Inherited from
SequentialEventToQuantizedAbjadContainer__init__(*args[, do_rewrite_meter, add_beams])convert(sequential_event_to_convert)Inherited from
Converterconvert(sequential_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_maximum_dot_count_abc_implInherited from
SequentialEventToQuantizedAbjadContainer_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- convert(sequential_event_to_convert)[source]§
- Parameters:
sequential_event_to_convert (SequentialEvent) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …]]
- property tempo_envelope: TempoEnvelope§
- class LeafMakerSequentialEventToDurationLineBasedQuantizedAbjadContainer(*args, duration_line_minimum_length=6, duration_line_thickness=3, **kwargs)[source]§
Quantize
SequentialEventobject viaabjad.LeafMaker.- Parameters:
time_signature_sequence – Set time signatures to divide the quantized abjad data in desired bar sizes. If the converted
SequentialEventis longer than the sum of all passed time signatures, the last time signature will be repeated for the remaining bars.tempo_envelope – Defines the tempo of the converted music. This is an
core_events.TempoEnvelopeobject which durations are beats and which levels are either numbers (that will be interpreted as beats per minute (‘BPM’)) orTempoPointobjects. If no tempo envelope has been defined, Mutwo will assume a constant tempo of 1/4 = 120 BPM.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 >>> converter = abjad_converters.SequentialEventToAbjadVoiceConverter( >>> abjad_converters.LeafMakerSequentialEventToDurationLineBasedQuantizedAbjadContainer( >>> ) >>> ) >>> sequential_event_to_convert = core_events.SequentialEvent( >>> [ >>> music_events.NoteLike("c", 0.125), >>> music_events.NoteLike("d", 1), >>> music_events.NoteLike([], 0.125), >>> music_events.NoteLike("e", 0.16666), >>> music_events.NoteLike("e", 0.08333333333333333) >>> ] >>> ) >>> converted_sequential_event = converter.convert(sequential_event_to_convert) >>> converted_sequential_event.consists_commands.append("Duration_line_engraver")
Public Data Attributes:
Inherited from
SequentialEventToQuantizedAbjadContainerPublic Methods:
__init__(*args[, ...])convert(sequential_event_to_convert)Inherited from
LeafMakerSequentialEventToQuantizedAbjadContainer__init__(*args[, ...])convert(sequential_event_to_convert)Inherited from
SequentialEventToQuantizedAbjadContainer__init__(*args[, ...])convert(sequential_event_to_convert)Inherited from
Converterconvert(sequential_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Inherited from
_DurationLineBasedQuantizedAbjadContainerMixin__init__(*args[, ...])Private Data Attributes:
_abc_implInherited from
LeafMakerSequentialEventToQuantizedAbjadContainer_maximum_dot_count_abc_implInherited from
SequentialEventToQuantizedAbjadContainer_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- convert(sequential_event_to_convert)[source]§
- Parameters:
sequential_event_to_convert (SequentialEvent) –
- Return type:
tuple[abjad.score.Container, tuple[tuple[tuple[int, …], …], …]]
- property tempo_envelope: TempoEnvelope§
- class ComplexEventToAbjadContainer(abjad_container_class, lilypond_type_of_abjad_container, complex_event_to_abjad_container_name, pre_process_abjad_container_routine_sequence, post_process_abjad_container_routine_sequence)[source]§
Public Methods:
__init__(abjad_container_class, ...)convert(complex_event_to_convert)Inherited from
Converterconvert(complex_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- Parameters:
abjad_container_class (Type[Container]) –
lilypond_type_of_abjad_container (str) –
complex_event_to_abjad_container_name (Callable[[ComplexEvent], str]) –
pre_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
post_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
- convert(complex_event_to_convert)[source]§
- Parameters:
complex_event_to_convert (ComplexEvent) –
- Return type:
Container
- class SequentialEventToAbjadVoice(sequential_event_to_quantized_abjad_container=<mutwo.abjad_converters.events.quantization.NauertSequentialEventToQuantizedAbjadContainer object>, simple_event_to_pitch_list=<mutwo.music_converters.parsers.SimpleEventToPitchList object>, simple_event_to_volume=<mutwo.music_converters.parsers.SimpleEventToVolume object>, simple_event_to_grace_note_sequential_event=<mutwo.music_converters.parsers.SimpleEventToGraceNoteSequentialEvent object>, simple_event_to_after_grace_note_sequential_event=<mutwo.music_converters.parsers.SimpleEventToAfterGraceNoteSequentialEvent object>, simple_event_to_playing_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToPlayingIndicatorCollection object>, simple_event_to_notation_indicator_collection=<mutwo.music_converters.parsers.SimpleEventToNotationIndicatorCollection object>, simple_event_to_lyric=<mutwo.music_converters.parsers.SimpleEventToLyric object>, is_simple_event_rest=None, mutwo_pitch_to_abjad_pitch=<mutwo.abjad_converters.parameters.pitches.MutwoPitchToAbjadPitch object>, mutwo_volume_to_abjad_attachment_dynamic=<mutwo.abjad_converters.parameters.volumes.MutwoVolumeToAbjadAttachmentDynamic object>, tempo_envelope_to_abjad_attachment_tempo=<mutwo.abjad_converters.parameters.tempos.ComplexTempoEnvelopeToAbjadAttachmentTempo object>, mutwo_lyric_to_abjad_string=<mutwo.abjad_converters.parameters.lyrics.MutwoLyricToAbjadString object>, abjad_attachment_class_sequence=None, write_multimeasure_rests=True, abjad_container_class=<class 'abjad.score.Voice'>, lilypond_type_of_abjad_container='Voice', complex_event_to_abjad_container_name=<function SequentialEventToAbjadVoice.<lambda>>, pre_process_abjad_container_routine_sequence=(), post_process_abjad_container_routine_sequence=())[source]§
Convert
SequentialEventtoabjad.Voice.- Parameters:
sequential_event_to_quantized_abjad_container (SequentialEventToQuantizedAbjadContainer, optional) – Class which defines how the Mutwo data will be quantized. See
SequentialEventToQuantizedAbjadContainerfor more information.simple_event_to_pitch_list (Callable[[core_events.SimpleEvent], music_parameters.abc.Pitch], optional) – Function to extract from a
mutwo.core_events.SimpleEventa tuple that contains pitch objects (objects that inherit frommutwo.music_parameters.abc.Pitch). By default it asks the Event for itspitch_listattribute (because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith 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.simple_event_to_volume (Callable[[core_events.SimpleEvent], music_parameters.abc.Volume], optional) – Function to extract the volume from a
mutwo.core_events.SimpleEventin 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 itsvolumeattribute (because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith 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_listto an empty list and set volume to 0.simple_event_to_grace_note_sequential_event (Callable[[core_events.SimpleEvent], core_events.SequentialEvent[core_events.SimpleEvent]], optional) – Function to extract from a
mutwo.core_events.SimpleEventaSequentialEventobject filled withSimpleEvent. By default it asks the Event for itsgrace_note_sequential_eventattribute (because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith a different name for their grace_note_sequential_event property, this argument should be overridden. If the function call raises anAttributeError(e.g. if no grace_note_sequential_event can be extracted), mutwo will use an emptySequentialEvent.simple_event_to_after_grace_note_sequential_event (Callable[[core_events.SimpleEvent], core_events.SequentialEvent[core_events.SimpleEvent]], optional) – Function to extract from a
mutwo.core_events.SimpleEventaSequentialEventobject filled withSimpleEvent. By default it asks the Event for itsafter_grace_note_sequential_eventattribute (because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith a different name for their after_grace_note_sequential_event property, this argument should be overridden. If the function call raises anAttributeError(e.g. if no after_grace_note_sequential_event can be extracted), mutwo will use an emptySequentialEvent.simple_event_to_playing_indicator_collection (Callable[[core_events.SimpleEvent], music_parameters.PlayingIndicatorCollection,], optional) – Function to extract from a
mutwo.core_events.SimpleEventamutwo.music_parameters.playing_indicators.PlayingIndicatorCollectionobject. By default it asks the Event for itsplaying_indicator_collectionattribute (because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith 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.simple_event_to_notation_indicator_collection (Callable[[core_events.SimpleEvent], music_parameters.NotationIndicatorCollection,], optional) – Function to extract from a
mutwo.core_events.SimpleEventamutwo.music_parameters.notation_indicators.NotationIndicatorCollectionobject. By default it asks the Event for itsnotation_indicators(because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith 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_CLASSsimple_event_to_lyric (Callable[[core_events.SimpleEvent], music_parameters.abc.Lyric], optional) – Function to extract the lyric from a
mutwo.core_events.SimpleEventin 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 itslyricattribute (because by defaultmutwo.events.music.NoteLikeobjects are expected). When using different Event classes thanNoteLikewith 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 setlyricto an empty text.is_simple_event_rest (Callable[[core_events.SimpleEvent], bool], optional) – Function to detect if the the inspected
mutwo.core_events.SimpleEventis a Rest. By default Mutwo simply checks if ‘pitch_list’ contain any objects. If not, the Event will be interpreted as a rest.mutwo_pitch_to_abjad_pitch (MutwoPitchToAbjadPitch, optional) – Class which defines how to convert
mutwo.music_parameters.abc.Pitchobjects toabjad.Pitchobjects. SeeMutwoPitchToAbjadPitchfor more information.mutwo_volume_to_abjad_attachment_dynamic (MutwoVolumeToAbjadAttachmentDynamic, optional) – Class which defines how to convert
mutwo.music_parameters.abc.Volumeobjects tomutwo.converters.frontends.abjad_parameters.Dynamicobjects. SeeMutwoVolumeToAbjadAttachmentDynamicfor more information.tempo_envelope_to_abjad_attachment_tempo (TempoEnvelopeToAbjadAttachmentTempo, optional) – Class which defines how to convert tempo envelopes to
mutwo.converters.frontends.abjad_parameters.Tempoobjects. SeeTempoEnvelopeToAbjadAttachmentTempofor more information.mutwo_lyric_to_abjad_string (MutwoLyricToAbjadString) – Callable which defines how to convert
mutwo.music_parameters.abc.Lyricto a string. Consultmutwo.abjad_converters.MutwoLyricToAbjadStringfor more information.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
Trueif the converter should replace rests that last a complete bar with multimeasure rests (rests with uppercase “R” in Lilypond). Default toTrue.abjad_container_class (Type[Container]) –
lilypond_type_of_abjad_container (str) –
complex_event_to_abjad_container_name (Callable[[ComplexEvent], Optional[str]]) –
pre_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
post_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
Public Methods:
__init__([...])convert(sequential_event_to_convert)Convert passed
SequentialEvent.Inherited from
ComplexEventToAbjadContainer__init__([...])convert(sequential_event_to_convert)Convert passed
SequentialEvent.Inherited from
Converterconvert(sequential_event_to_convert)Convert passed
SequentialEvent.__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ComplexEventToAbjadContainer_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- ExtractedData§
alias of
tuple[list[Pitch],Volume,SequentialEvent[SimpleEvent],SequentialEvent[SimpleEvent],PlayingIndicatorCollection,NotationIndicatorCollection,Lyric]
- ExtractedDataPerSimpleEvent§
alias of
tuple[tuple[list[Pitch],Volume,SequentialEvent[SimpleEvent],SequentialEvent[SimpleEvent],PlayingIndicatorCollection,NotationIndicatorCollection,Lyric], …]
- convert(sequential_event_to_convert)[source]§
Convert passed
SequentialEvent.- Parameters:
sequential_event_to_convert (mutwo.core_events.SequentialEvent) – The
SequentialEventwhich shall be converted to theabjad.Voiceobject.- Return type:
Voice
Example:
>>> import abjad >>> from mutwo.events import basic, music >>> from mutwo.converters.frontends import abjad as mutwo_abjad >>> mutwo_melody = basic.SequentialEvent( >>> [ >>> music.NoteLike(pitch, duration) >>> for pitch, duration in zip("c a g e".split(" "), (1, 1 / 6, 1 / 6, 1 / 6)) >>> ] >>> ) >>> converter = mutwo_abjad.SequentialEventToAbjadVoice() >>> abjad_melody = converter.convert(mutwo_melody) >>> abjad.lilypond(abjad_melody) \new Voice { { \tempo 4=120 %%% \time 4/4 %%% c'1 \mf } { \times 2/3 { a'4 g'4 e'4 } r2 } }
- class NestedComplexEventToAbjadContainer(nested_complex_event_to_complex_event_to_abjad_container_converters_converter, abjad_container_class, lilypond_type_of_abjad_container, complex_event_to_abjad_container_name=<function NestedComplexEventToAbjadContainer.<lambda>>, pre_process_abjad_container_routine_sequence=(), post_process_abjad_container_routine_sequence=())[source]§
Public Methods:
__init__(...[, ...])Inherited from
ComplexEventToAbjadContainer__init__(...[, ...])convert(complex_event_to_convert)Inherited from
Converterconvert(complex_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ComplexEventToAbjadContainer_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- Parameters:
nested_complex_event_to_complex_event_to_abjad_container_converters_converter (NestedComplexEventToComplexEventToAbjadContainers) –
abjad_container_class (Type[Container]) –
lilypond_type_of_abjad_container (str) –
complex_event_to_abjad_container_name (Callable[[ComplexEvent], str]) –
pre_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
post_process_abjad_container_routine_sequence (Sequence[ProcessAbjadContainerRoutine]) –
- convert(complex_event_to_convert)§
- Parameters:
complex_event_to_convert (ComplexEvent) –
- Return type:
Container
- class NestedComplexEventToComplexEventToAbjadContainers[source]§
Public Methods:
convert(nested_complex_event_to_convert)Inherited from
Converterconvert(nested_complex_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- abstract convert(nested_complex_event_to_convert)[source]§
- Parameters:
nested_complex_event_to_convert (ComplexEvent) –
- Return type:
tuple[mutwo.abjad_converters.events.building.ComplexEventToAbjadContainer, …]
- class CycleBasedNestedComplexEventToComplexEventToAbjadContainers(complex_event_to_abjad_container_converter_sequence)[source]§
Public Methods:
__init__(...)convert(nested_complex_event_to_convert)Inherited from
NestedComplexEventToComplexEventToAbjadContainersconvert(nested_complex_event_to_convert)Inherited from
Converterconvert(nested_complex_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
NestedComplexEventToComplexEventToAbjadContainers_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- Parameters:
complex_event_to_abjad_container_converter_sequence (Sequence[ComplexEventToAbjadContainer]) –
- convert(nested_complex_event_to_convert)[source]§
- Parameters:
nested_complex_event_to_convert (ComplexEvent) –
- Return type:
tuple[mutwo.abjad_converters.events.building.ComplexEventToAbjadContainer, …]
- class TagBasedNestedComplexEventToComplexEventToAbjadContainers(tag_to_abjad_converter_dict, complex_event_to_tag=<function TagBasedNestedComplexEventToComplexEventToAbjadContainers.<lambda>>)[source]§
Public Methods:
__init__(tag_to_abjad_converter_dict[, ...])convert(nested_complex_event_to_convert)Inherited from
NestedComplexEventToComplexEventToAbjadContainersconvert(nested_complex_event_to_convert)Inherited from
Converterconvert(nested_complex_event_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
NestedComplexEventToComplexEventToAbjadContainers_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- Parameters:
tag_to_abjad_converter_dict (dict[str, mutwo.abjad_converters.events.building.ComplexEventToAbjadContainer]) –
complex_event_to_tag (Callable[[ComplexEvent], str]) –
- convert(nested_complex_event_to_convert)[source]§
- Parameters:
nested_complex_event_to_convert (ComplexEvent) –
- Return type:
tuple[mutwo.abjad_converters.events.building.ComplexEventToAbjadContainer, …]
- class MutwoLyricToAbjadString[source]§
Public Methods:
convert(mutwo_lyric_to_convert)Inherited from
Converterconvert(mutwo_lyric_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- class MutwoPitchToAbjadPitch[source]§
Convert Mutwo Pitch objects to Abjad Pitch objects.
This default class simply checks if the passed Mutwo object belongs to
mutwo.ext.parameters.pitches.WesternPitch. If it does, Mutwo will initialise the Abjad Pitch from thenameattribute. Otherwise Mutwo will simply initialise the Abjad Pitch from the objectsfrequencyattribute.If users desire to make more complex conversions (for instance due to
scordaturaor transpositions of instruments), one can simply inherit from this class to define more complex cases.Public Methods:
convert(pitch_to_convert)Inherited from
Converterconvert(pitch_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- class TempoEnvelopeToAbjadAttachmentTempo[source]§
Convert tempo envelope to
Tempo.Abstract base class for tempo envelope conversion. See
ComplexTempoEnvelopeToAbjadAttachmentTempofor a concrete class.Public Methods:
convert(tempo_envelope_to_convert)Inherited from
Converterconvert(tempo_envelope_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- abstract convert(tempo_envelope_to_convert)[source]§
- Parameters:
tempo_envelope_to_convert (TempoEnvelope) –
- Return type:
tuple[tuple[Union[float, fractions.Fraction, int], mutwo.abjad_parameters.attachments.Tempo], …]
- class ComplexTempoEnvelopeToAbjadAttachmentTempo[source]§
Convert tempo envelope to
Tempo.This object tries to intelligently set correct tempo abjad_parameters to an
abjad.Voiceobject, 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_envelope_to_convert)Inherited from
TempoEnvelopeToAbjadAttachmentTempoconvert(tempo_envelope_to_convert)Inherited from
Converterconvert(tempo_envelope_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
TempoEnvelopeToAbjadAttachmentTempo_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- convert(tempo_envelope_to_convert)[source]§
- Parameters:
tempo_envelope_to_convert (TempoEnvelope) –
- Return type:
tuple[tuple[Union[float, fractions.Fraction, int], mutwo.abjad_parameters.attachments.Tempo], …]
- class MutwoVolumeToAbjadAttachmentDynamic[source]§
Convert Mutwo Volume objects to
Dynamic.This default class simply checks if the passed Mutwo object belongs to
mutwo.ext.parameters.volumes.WesternVolume. If it does, Mutwo will initialise theTempoobject from thenameattribute. Otherwise Mutwo will first initialise aWesternVolumeobject via its py:method:mutwo.ext.parameters.volumes.WesternVolume.from_amplitude method.Hairpins aren’t notated with the aid of
mutwo.ext.parameters.abc.Volumeobjects, but withmutwo.ext.parameters.playing_indicators.Hairpin.Public Methods:
convert(volume_to_convert)Inherited from
Converterconvert(volume_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- 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]§
Convert Mutwo
JustIntonationPitchobjects to Abjad Pitch objects.- 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_DICTfor the default mapping.otonality_indicator (str, optional) – String which indicates that the respective prime alteration is otonal. See
mutwo.ekmelily_converters.configurations.DEFAULT_OTONALITY_INDICATORfor the default value.utonality_indicator (str, optional) – String which indicates that the respective prime alteration is utonal. See
mutwo.ekmelily_converters.configurations.DEFAULT_OTONALITY_INDICATORfor 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_INDICATORfor the default value.
The resulting Abjad pitches are expected to be used in combination with tuning files that are generated by
HEJIEkmelilyTuningFileConverterand with the Lilypond extension Ekmelily. You can find pre-generated tuning files here.Example:
>>> from mutwo.ext.parameters import pitches >>> from mutwo.converters.frontends import abjad >>> my_ji_pitch = pitches.JustIntonationPitch('5/4') >>> converter_on_a = abjad.MutwoPitchToHEJIAbjadPitch(reference_pitch='a') >>> converter_on_c = abjad.MutwoPitchToHEJIAbjadPitch(reference_pitch='c') >>> converter_on_a.convert(my_ji_pitch) NamedPitch("csoaa''") >>> converter_on_c.convert(my_ji_pitch) NamedPitch("eoaa'")
Public Methods:
__init__([reference_pitch, ...])convert(pitch_to_convert)Inherited from
MutwoPitchToAbjadPitchconvert(pitch_to_convert)Inherited from
Converterconvert(pitch_to_convert)__call__(*args, **kwargs)Call self as a function.
Private Data Attributes:
_abc_implInherited from
MutwoPitchToAbjadPitch_abc_implInherited from
Converter_abc_implInherited from
ABC_abc_impl
- class ProcessAbjadContainerRoutine[source]§
Public Methods:
__call__(complex_event_to_convert, ...)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ABC_abc_impl
- class AddDurationLineEngraver[source]§
Public Methods:
__call__(complex_event_to_convert, ...)Call self as a function.
Inherited from
ProcessAbjadContainerRoutine__call__(complex_event_to_convert, ...)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ProcessAbjadContainerRoutine_abc_implInherited from
ABC_abc_impl
- class PrepareForDurationLineBasedNotation[source]§
Public Methods:
__call__(_, container_to_process)Call self as a function.
Inherited from
ProcessAbjadContainerRoutine__call__(_, container_to_process)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ProcessAbjadContainerRoutine_abc_implInherited from
ABC_abc_impl
- class AddInstrumentName(complex_event_to_instrument_name=<function AddInstrumentName.<lambda>>, complex_event_to_short_instrument_name=<function AddInstrumentName.<lambda>>, instrument_name_font_size='teeny', short_instrument_name_font_size='teeny')[source]§
Public Methods:
__init__([complex_event_to_instrument_name, ...])__call__(complex_event_to_convert, ...)Call self as a function.
Inherited from
ProcessAbjadContainerRoutine__call__(complex_event_to_convert, ...)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ProcessAbjadContainerRoutine_abc_implInherited from
ABC_abc_impl
- Parameters:
complex_event_to_instrument_name (Callable[[ComplexEvent], str]) –
complex_event_to_short_instrument_name (Callable[[ComplexEvent], str]) –
instrument_name_font_size (str) –
short_instrument_name_font_size (str) –
- class AddAccidentalStyle(accidental_style)[source]§
Public Methods:
__init__(accidental_style)__call__(complex_event_to_convert, ...)Call self as a function.
Inherited from
ProcessAbjadContainerRoutine__call__(complex_event_to_convert, ...)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ProcessAbjadContainerRoutine_abc_implInherited from
ABC_abc_impl
- Parameters:
accidental_style (str) –
- class SetStaffSize(difference_of_size)[source]§
Public Methods:
__init__(difference_of_size)__call__(complex_event_to_convert, ...)Call self as a function.
Inherited from
ProcessAbjadContainerRoutine__call__(complex_event_to_convert, ...)Call self as a function.
Private Data Attributes:
_abc_implInherited from
ProcessAbjadContainerRoutine_abc_implInherited from
ABC_abc_impl
- Parameters:
difference_of_size (int) –
mutwo.abjad_converters.configurations§
Configure mutwo.abjad_converters.
- DEFAULT_ABJAD_ATTACHMENT_CLASS_TUPLE = (<class 'mutwo.abjad_parameters.attachments.AfterGraceNoteSequentialEvent'>, <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.GraceNoteSequentialEvent'>, <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.NaturalHarmonic'>, <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.PreciseNaturalHarmonic'>, <class 'mutwo.abjad_parameters.attachments.RehearsalMark'>, <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
SequentialEventToAbjadVoiceConverter.