コード例 #1
0
def illustrate_applied_brahms_melodies(
        applied_brahms_melodies: basic.SequentialEvent):
    applied_brahms_melodies = functools.reduce(operator.add,
                                               applied_brahms_melodies)
    import abjad

    from mutwo.converters.frontends import abjad as mutwo_abjad

    time_signatures = tuple(
        abjad.TimeSignature((int(event.duration * 2), 2))
        for event in applied_cantus_firmus.APPLIED_CANTUS_FIRMUS)

    abjad_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
        mutwo_abjad.SequentialEventToQuantizedAbjadContainerConverter(
            time_signatures),
        mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
        MutwoPitchToHEJIAbjadPitchConverter(),
    )
    abjad_voice = abjad_converter.convert(applied_brahms_melodies)

    abjad.attach(abjad.LilyPondLiteral('\\accidentalStyle "dodecaphonic"'),
                 abjad_voice[0][0])
    abjad.attach(
        abjad.LilyPondLiteral(
            "\\override Staff.TimeSignature.style = #'single-digit"),
        abjad_voice[0][0],
    )
    abjad_score = abjad.Score([abjad.Staff([abjad_voice])])
    lilypond_file = abjad.LilyPondFile(items=[abjad_score],
                                       includes=["ekme-heji-ref-c.ily"])
    abjad.persist.as_pdf(lilypond_file, "builds/applied_brahms_melodies.pdf")
コード例 #2
0
 def __init__(
     self,
     post_process_abjad_container_routines: typing.Sequence = [],
     lilypond_type_of_abjad_container: str = "StaffGroup",
     mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
     MutwoPitchToHEJIAbjadPitchConverter(),
 ):
     self._mutwo_pitch_to_abjad_pitch_converter = (
         mutwo_pitch_to_abjad_pitch_converter)
     sequential_event_to_abjad_voice_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
         mutwo_abjad.
         SequentialEventToDurationLineBasedQuantizedAbjadContainerConverter(
             time_signatures=(abjad.TimeSignature((1, 4)), )),
         mutwo_pitch_to_abjad_pitch_converter=
         mutwo_pitch_to_abjad_pitch_converter,
         tempo_envelope_to_abjad_attachment_tempo_converter=None,
         write_multimeasure_rests=False,
     )
     super().__init__(
         mutwo_abjad.
         CycleBasedNestedComplexEventToComplexEventToAbjadContainerConvertersConverter(
             (sequential_event_to_abjad_voice_converter, )),
         abjad.StaffGroup,
         lilypond_type_of_abjad_container,
         pre_process_abjad_container_routines=[],
         post_process_abjad_container_routines=
         post_process_abjad_container_routines,
     )
コード例 #3
0
 def _make_sequential_event_to_abjad_voice_converter_for_sustaining_instrument(
     self, ) -> mutwo_abjad.SequentialEventToAbjadVoiceConverter:
     return mutwo_abjad.SequentialEventToAbjadVoiceConverter(
         mutwo_abjad.
         SequentialEventToDurationLineBasedQuantizedAbjadContainerConverter(
             self._time_signatures,
             tempo_envelope=self._tempo_envelope,
             # search_tree=self.search_tree,
         ),
         mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
         MutwoPitchToHEJIAbjadPitchConverter(),
     )
コード例 #4
0
ファイル: events.py プロジェクト: levinericzimmermann/ot2
def illustrate_melody(
        path: str,
        melody_to_illustrate: basic.SequentialEvent[music.NoteLike]):
    abjad_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
        mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
        MutwoPitchToHEJIAbjadPitchConverter(), )
    abjad_voice = abjad_converter.convert(melody_to_illustrate)
    abjad.attach(abjad.LilyPondLiteral('\\accidentalStyle "dodecaphonic"'),
                 abjad_voice[0][0])
    abjad_score = abjad.Score([abjad.Staff([abjad_voice])])
    lilypond_file = abjad.LilyPondFile(items=[abjad_score],
                                       includes=["ekme-heji-ref-c.ily"])
    abjad.persist.as_pdf(lilypond_file, path)
コード例 #5
0
def illustrate_cantus_firmus(cantus_firmus: basic.SequentialEvent):
    import abjad

    from mutwo.converters.frontends import abjad as mutwo_abjad

    abjad_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
        mutwo_abjad.SequentialEventToQuantizedAbjadContainerConverter(
            (abjad.TimeSignature((2, 1)),)
        ),
        mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.MutwoPitchToHEJIAbjadPitchConverter(),
    )
    abjad_voice = abjad_converter.convert(cantus_firmus)

    abjad.attach(
        abjad.LilyPondLiteral('\\accidentalStyle "dodecaphonic"'), abjad_voice[0][0]
    )
    abjad_score = abjad.Score([abjad.Staff([abjad_voice])])
    lilypond_file = abjad.LilyPondFile(
        items=[abjad_score], includes=["ekme-heji-ref-c.ily"]
    )
    abjad.persist.as_pdf(lilypond_file, "builds/cantus_firmus.pdf")
コード例 #6
0
import fractions
import json

import abjad

from mutwo.converters.frontends import abjad as mutwo_abjad
from mutwo.events import basic
from mutwo.events import music
from mutwo.parameters import pitches

with open("solutions.json", "r") as f:
    DATA = json.load(f)


converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
    mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.MutwoPitchToHEJIAbjadPitchConverter()
)
lilypond_file = abjad.LilyPondFile(includes=["ekme-heji-ref-c.ily"])
for current_pitch, previous_pitch, next_pitch, solution, harmonicity in DATA:
    movement_pitches = tuple(
        pitches.JustIntonationPitch(exponents)
        for exponents in (previous_pitch, current_pitch, next_pitch)
    )
    solution_pitches = tuple(
        pitches.JustIntonationPitch(exponents) for exponents in solution
    )

    sequential_event = basic.SequentialEvent([])
    for movement_pitch in movement_pitches:
        sequential_event.append(
            music.NoteLike(movement_pitch, fractions.Fraction(1, 3))
コード例 #7
0
def illustrate_cengkoks(applied_melodies):
    import abjad
    from abjadext import nauert

    from mutwo.converters.frontends import abjad as mutwo_abjad

    time_signatures = tuple(
        abjad.TimeSignature((int(event.duration * 2), 2))
        for event in applied_cantus_firmus.APPLIED_CANTUS_FIRMUS)

    search_tree = nauert.UnweightedSearchTree(definition={
        2: {
            2: {
                2: {
                    2: {
                        2: {
                            2: None,
                        },
                    },
                },
                3: {
                    2: {
                        2: {
                            2: {
                                2: None,
                            },
                        },
                    },
                }
            },
            3: {
                2: {
                    2: {
                        2: {
                            2: None,
                        },
                    },
                },
                3: {
                    2: {
                        2: {
                            2: {
                                2: None,
                            },
                        },
                    },
                }
            },
        },
        3: {
            2: {
                2: {
                    2: {
                        2: {
                            2: None,
                        },
                    },
                },
                3: {
                    2: {
                        2: {
                            2: {
                                2: None,
                            },
                        },
                    },
                }
            },
            3: {
                2: {
                    2: {
                        2: {
                            2: None,
                        },
                    },
                },
                3: {
                    2: {
                        2: {
                            2: {
                                2: None,
                            },
                        },
                    },
                }
            },
        },
    }, )
    abjad_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
        mutwo_abjad.SequentialEventToQuantizedAbjadContainerConverter(
            time_signatures, search_tree=search_tree),
        mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
        MutwoPitchToHEJIAbjadPitchConverter(),
    )
    abjad_voice = abjad_converter.convert(applied_melodies)

    abjad.attach(abjad.LilyPondLiteral('\\accidentalStyle "dodecaphonic"'),
                 abjad_voice[0][0])
    abjad.attach(
        abjad.LilyPondLiteral(
            "\\override Staff.TimeSignature.style = #'single-digit"),
        abjad_voice[0][0],
    )
    abjad_score = abjad.Score([abjad.Staff([abjad_voice])])
    lilypond_file = abjad.LilyPondFile(items=[abjad_score],
                                       includes=["ekme-heji-ref-c.ily"])
    abjad.persist.as_pdf(lilypond_file, "builds/applied_cengkoks.pdf")