Ejemplo n.º 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")
Ejemplo n.º 2
0
def make_small_example(
        score: abjad.Score,
        path: str,
        size: float = None,
        staff_size: float = 20,
        resolution: int = 500,
        header_block=abjad.Block("header"),
) -> subprocess.Popen:
    includes = ["lilypond-book-preamble.ly"]

    score_block = abjad.Block("score")
    score_block.items.append(score)

    layout_block = abjad.Block("layout")
    layout_block.items.append(r"indent = 0\mm")
    layout_block.items.append(r"short-indent = 0\mm")
    layout_block.items.append(r"ragged-last = ##f")
    layout_block.items.append(r"ragged-right = ##f")

    lilypond_file = abjad.LilyPondFile(
        lilypond_version_token=abjad.LilyPondVersionToken(LILYPOND_VERSION),
        global_staff_size=staff_size,
        includes=includes,
        items=[layout_block, header_block, score_block],
    )
    write_lily_file(lilypond_file, path)
    return render_lily_file(path,
                            write2png=True,
                            resolution=resolution,
                            output_name=path)
Ejemplo n.º 3
0
    def annotate_material_names(self, material_name):
        """Add markups to identify materials."""
        copied_container = abjad.mutate.copy(self.container)

        if isinstance(material_name, str):
            material_name = [material_name]

        if material_name is None:
            selectables = [copied_container]
        else:
            selectables = []
            for mat_name in material_name:
                selectable = self.select_material(copied_container,
                                                  material_name=mat_name)
                selectables.append(selectable)

        for i, name in enumerate(material_name):
            selectable = self.select_material(copied_container, name)
            containers = abjad.select.components(selectable, abjad.Container)
            for container in containers:
                if ((not isinstance(
                        container, abjad.Tuplet or abjad.Voice
                        or abjad.BeforeGraceContainer))
                        and (container.name and container.identifier)
                        and (name in container.name)):
                    s = container.name
                    lit = r'\once \override HorizontalBracketText.text = "%s"' % s
                    abjad.attach(abjad.LilyPondLiteral(lit), container[0])

                    abjad.horizontal_bracket(container)
                    for i, leaf in enumerate(abjad.select.leaves(container)):
                        str_ = r"\markup \tiny {\null { \raise #2 {%i}}}" % i
                        abjad.attach(
                            abjad.Markup(str_, direction=abjad.Up),
                            leaf,
                        )

        illustration_score = abjad.Score()
        illustration_staff = abjad.Staff()
        illustration_voice = abjad.Voice()
        illustration_voice.consists_commands.append(
            "Horizontal_bracket_engraver")
        illustration_voice.append(copied_container)
        illustration_staff.append(illustration_voice)
        illustration_score.append(illustration_staff)
        lilypond_file = abjad.LilyPondFile(items=[illustration_score], )
        import os

        os.chdir(os.path.dirname(__file__))
        abjad.persist.as_ly(lilypond_file, "illustration_score.ly")
        # print(abjad.lilypond(illustration_score))
        os.system("lilypond illustration.ly")
        os.system("open ./illustration.pdf")
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 def _make_build_file(self, previous_metadata=None):
     includes = self._get_lilypond_includes()
     build_file_score = copy.deepcopy(self._score)
     if previous_metadata is not None:
         first_tempo = self._get_first_tempo()
         first_time_signature = self._get_first_time_signature()
         first_leaf = abjad.get.leaf(build_file_score, 0)
         if first_tempo == previous_metadata["last_tempo"]:
             abjad.detach(abjad.MetronomeMark, first_leaf)
         if first_time_signature == previous_metadata[
                 "last_time_signature"]:
             abjad.detach(abjad.TimeSignature, first_leaf)
     build_file = abjad.LilyPondFile(items=[build_file_score],
                                     includes=includes,
                                     use_relative_includes=True)
     self._build_file = build_file
Ejemplo n.º 6
0
 def _render_file(self):
     print("Rendering file ...")
     abjad.SegmentMaker.comment_measure_numbers(self.score_template)
     score_block = abjad.Block(name="score")
     score_block.items.append(self.score_template)
     score_file = abjad.LilyPondFile(items=[score_block],
                                     includes=self.score_includes)
     for leaf in abjad.iterate(self.score_template).leaves():
         literal = abjad.LilyPondLiteral("", "absolute_before")
         abjad.attach(literal, leaf, tag=None)
     for container in abjad.iterate(self.score_template).components(
             abjad.Container):
         if hasattr(container, "_main_leaf"):
             literal = abjad.LilyPondLiteral("", "absolute_after")
             abjad.attach(literal, container, tag=None)
         else:
             literal = abjad.LilyPondLiteral("", "absolute_before")
             abjad.attach(literal, container, tag=None)
         literal = abjad.LilyPondLiteral("", "closing")
         abjad.attach(literal, container, tag=None)
     directory = self.current_directory
     pdf_path = baca.Path(f"{directory}/illustration.pdf")
     if pdf_path.exists():
         pdf_path.unlink()
     print(f"Persisting {pdf_path.trim()} ...")
     result = abjad.persist.as_pdf(
         score_file,
         pdf_path,
         align_tags=79,
     )
     success = result[3]
     if success is False:
         print("LilyPond failed!")
     if pdf_path.exists():
         print(f"Opening {pdf_path.trim()} ...")
         os.system(f"open {pdf_path}")
     with open(f"{directory}/illustration.ly") as pointer_1:
         score_lines = pointer_1.readlines()
         build_path = self.current_directory.parent.with_name("build")
         build_path /= "score"
         lines = score_lines[7:-1]  # was 15:-1
         with open(f"{build_path}/{self.segment_name}.ly", "w") as fp:
             fp.writelines(lines)
Ejemplo n.º 7
0
    def convert(
            self,
            abjad_scores: typing.Sequence[abjad.Block]) -> abjad.LilyPondFile:
        lilypond_file = abjad.LilyPondFile(
            includes=["ekme-heji-ref-c-not-tuned.ily"],
            default_paper_size=self._paper_format.name,
        )

        for abjad_score in abjad_scores:
            lilypond_file.items.append(abjad_score)

        if not self._render_video:
            lilypond_file.items.append(
                AbjadScoresToLilypondFileConverter._make_header_block(
                    self._instrument_tag))
        lilypond_file.items.append(self._make_paper_block())

        lilypond_file.items.append("\\pointAndClickOff\n")

        return lilypond_file
Ejemplo n.º 8
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")
Ejemplo n.º 9
0
def illustrate(
    name: str,
    *abjad_score: abjad.Score,
    add_book_preamble: bool = True,
    add_ekmeheji: bool = True,
    title: str = None,
):
    margin = 0
    layout_block = abjad.Block("layout")
    layout_block.items.append(r"short-indent = {}\mm".format(margin))
    layout_block.items.append(r"ragged-last = ##f")
    layout_block.items.append(r"indent = {}\mm".format(margin))
    paper_block = abjad.Block("paper")
    paper_block.items.append(r"""#(define fonts
    (make-pango-font-tree "EB Garamond"
                          "Nimbus Sans"
                          "Luxi Mono"
                          (/ staff-height pt 20)))""")
    paper_block.items.append(r"""score-system-spacing =
      #'((basic-distance . 30)
       (minimum-distance . 18)
       (padding . 1)
       (stretchability . 12))""")
    includes = []
    if add_ekmeheji:
        includes.append("ekme-heji-ref-c-not-tuned.ily")
    if add_book_preamble:
        includes.append("lilypond-book-preamble.ly")
    lilypond_file = abjad.LilyPondFile(
        items=list(abjad_score) + [paper_block, layout_block],
        includes=includes,
    )
    if title:
        header_block = abjad.Block("header")
        header_block.title = title
        header_block.tagline = '""'
        lilypond_file.items.append(header_block)

    abjad.persist.as_pdf(
        lilypond_file, f"{ot2_constants.paths.ILLUSTRATIONS_PATH}/{name}.pdf")
Ejemplo n.º 10
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")
Ejemplo n.º 11
0
def _show_transforms():
    voice = abjad.Voice(name="Voice")
    staff = abjad.Staff([voice], name="Staff")
    score = abjad.Score([staff], name="Score")
    segments, names = library.silver_start()
    _add_segments_to_voice(voice, "start", segments, names, do_not_page_break=True)
    segments, names = library.silver_transform_1()
    _add_segments_to_voice(
        voice, "transform 1", segments, names, do_not_page_break=True
    )
    segments, names = library.silver_transform_2()
    _add_segments_to_voice(voice, "transform 2", segments, names)
    segments, names = library.silver_transform_3()
    _add_segments_to_voice(voice, "transform 3", segments, names)
    segments, names = library.silver_transform_4()
    _add_segments_to_voice(voice, "transform 4", segments, names)
    segments, names = library.silver_transform_5()
    _add_segments_to_voice(voice, "transform 5", segments, names)
    segments, names = library.silver_transform_6()
    _add_segments_to_voice(voice, "transform 6", segments, names)
    segments, names = library.silver_transform_7()
    _add_segments_to_voice(voice, "transform 7", segments, names)

    leaf = abjad.select.leaf(score, 0)
    time_signature = abjad.TimeSignature((1, 8))
    abjad.attach(time_signature, leaf)
    literal = abjad.LilyPondLiteral("#(set-accidental-style 'forget)")
    abjad.attach(literal, leaf)
    preamble = r"""#(set-default-paper-size "letter")
    #(set-global-staff-size 14)

    \paper
    {
      bottom-margin = 15
      evenFooterMarkup = \markup \fill-line { "Mráz (silver transforms)" }
      indent = 0
      oddFooterMarkup = \evenFooterMarkup
      ragged-last = ##t
      ragged-last-bottom = ##t
      ragged-right = ##t
      top-margin = 20
      left-margin = 15
      print-page-number = ##f
      system-system-spacing.padding = 12
      tagline = ##f
    }

    \layout
    {
      \context
      {
        \Voice
        \remove Forbid_line_break_engraver
        \consists Horizontal_bracket_engraver
      }
      \context
      {
        \Score
        \remove Bar_number_engraver
        \override BarLine.transparent = ##t
        \override Flag.stencil = ##f
        \override HorizontalBracket.bracket-flare = #'(0 . 0)
        \override HorizontalBracket.staff-padding = 5
        \override HorizontalBracket.thickness = 2
        \override HorizontalBracketText.bracket = ##f
        \override HorizontalBracketText.padding = 1.5
        \override NonMusicalPaperColumn.line-break-permission = ##f
        \override Rest.transparent = ##t
        \override SpacingSpanner.strict-note-spacing = ##t
        \override SpacingSpanner.uniform-stretching = ##t
        \override SpanBar.transparent = ##t
        \override Stem.stencil = ##f
        \override TimeSignature.stencil = ##f
        autoBeaming = ##f
        proportionalNotationDuration = #(ly:make-moment 1 16)
      }
    }"""
    preamble = _trim_block_string(preamble)
    lilypond_file = abjad.LilyPondFile([preamble, score])
    name = "show/transforms"
    print(f"Writing {name} ...")
    abjad.persist.as_pdf(lilypond_file, name)
Ejemplo n.º 12
0
    def notate(self, name: str) -> None:
        pitches, delays = self.pitch, self.delay

        bar_grid = tuple(
            fractions.Fraction(ts.numerator, ts.denominator) for ts in self.bars
        )
        grid = tuple(
            fractions.Fraction(1, 4)
            for i in range(int(math.ceil(self.duration / fractions.Fraction(1, 4))))
        )

        notes = abjad.Voice([])

        absolute_delay = tools.accumulate_from_zero(delays)
        for pitch, delay, start, stop in zip(
            pitches, delays, absolute_delay, absolute_delay[1:]
        ):
            seperated_by_bar = tools.accumulate_from_n(
                lily.seperate_by_grid(start, stop, bar_grid, hard_cut=True), start
            )
            sub_delays = functools.reduce(
                operator.add,
                tuple(
                    functools.reduce(
                        operator.add,
                        tuple(
                            lily.seperate_by_assignability(d)
                            for d in lily.seperate_by_grid(start, stop, grid)
                        ),
                    )
                    for start, stop in zip(seperated_by_bar, seperated_by_bar[1:])
                ),
            )
            subnotes = []
            if pitch.is_empty:
                ct = None
            else:
                if self.ratio2pitchclass_dict:
                    ct = lily.convert2abjad_pitch(pitch, self.ratio2pitchclass_dict)

                else:
                    ct = lily.round_cents_to_12th_tone(pitch.cents)

            for delay in sub_delays:
                if ct is None:
                    obj = abjad.Rest(delay)
                else:
                    obj = abjad.Note(ct, delay)

                subnotes.append(obj)

            if ct is not None and len(subnotes) > 1:
                for note in subnotes[:-1]:
                    abjad.attach(abjad.Tie(), note)

            notes.extend(subnotes)

        abjad.attach(
            abjad.LilyPondLiteral("\\accidentalStyle dodecaphonic", "before"), notes[0]
        )
        abjad.attach(self.bars[0], notes[0], context="Voice")

        score = abjad.Score([notes])

        lf = abjad.LilyPondFile(
            score,
            lilypond_version_token=abjad.LilyPondVersionToken("2.19.83"),
            includes=["lilypond-book-preamble.ly"],
        )

        lily_name = "{}.ly".format(name)

        with open(lily_name, "w") as f:
            f.write(lily.EKMELILY_PREAMBLE)
            f.write(format(lf))

        subprocess.call(["lilypond", "--png", "-dresolution=400", lily_name])
Ejemplo n.º 13
0
import abjad
import muda
from muda_score.score_structure import score
from muda_score.materials import materials_01 as materials

# SEGMENT 01
# Write time signatures
muda.score.MakeSkips(materials.time_signatures, score)

# Write materials to voices
for material in materials.material_list:
    score[material.name].extend(material.container)

muda.functions.RewriteMeter(score, materials.time_signatures)

segment_01 = abjad.LilyPondFile(items=[score])
# Save LilyPond file to be collected (as ganha)
current_file = os.path.splitext(__file__)[0]  # Path
segment_ly = str(str(current_file) + ".ly")
abjad.persist.as_ly(segment_01, ly_file_path=segment_ly)  # Lilypond

# Save LilyPond and PDF files to be illustrated (as brinca)
if __name__ == "__main__":
    segment_01_illustration = abjad.LilyPondFile(
        items=[score], includes=["muda_score/stylesheet.ily"]
    ).__illustrate__()
    file_name = os.path.basename(__file__)
    file_name = os.path.splitext(file_name)[0]
    new_file_pdf = (
        os.path.dirname(__file__) + "/illustrations/" + str(file_name) + ".pdf"
    )
Ejemplo n.º 14
0
 def save_ly(self, file_name: str):
     lilypond_file = abjad.LilyPondFile(items=[self.score], )
     abjad.persist.as_ly(lilypond_file, file_name)
     print("Current working directory: {0}".format(os.getcwd()))
Ejemplo n.º 15
0
 def _make_lilypond_file(self):
     includes = self._get_lilypond_includes()
     lilypond_file = abjad.LilyPondFile(items=[self._score],
                                        includes=includes,
                                        use_relative_includes=True)
     self._lilypond_file = lilypond_file
Ejemplo n.º 16
0
def make_tableaux_chart(fundamental_patterns, subdivisions):
    print("instantiating parser, staff group, and patterns ...")
    parser = abjad.rhythmtrees.RhythmTreeParser()
    print("beginning loop ...")
    for i, fundamental_pattern in enumerate(fundamental_patterns):
        print(fundamental_pattern)
        print("gathering pattern ...")
        print("permuting pattern ...")
        for permutation in list(
                set([_ for _ in itertools.permutations(fundamental_pattern)])):
            permutation = list(permutation)
            print(permutation)
            title = fr"Mutations of {permutation}"
            final_patterns = []
            parsed_patterns = abjad.Staff(lilypond_type="RhythmicStaff")
            for num_indices in range(len(permutation) + 1):
                print("gathing number of possible dividable beats ...")
                if num_indices == 0:
                    print("do not subdivide!")
                    print("converting to string ...")
                    subgrouped_permutation = (
                        f"(1 {evans.nested_list_to_rtm(permutation)})")
                    print("gathing number of rotatable positions ...")
                    l_ = -1
                    for symbol in subgrouped_permutation:
                        if symbol.isdigit():
                            l_ = l_ + 1
                    for y in range(l_):
                        print("rotating ...")
                        rotation = evans.rotate_tree(
                            rtm_string=subgrouped_permutation, n=y)
                        print(rotation)
                        print("funneling rotation to 1 ...")
                        for funnel in evans.funnel_inner_tree_to_x(
                                rtm_string=rotation, x=1):
                            print("caching funnel ...")
                            print(funnel)
                            final_patterns.append(funnel)
                else:
                    print("subdivide!")
                    print("gathering possible subdivisions ...")
                    for division_group in itertools.combinations_with_replacement(
                            subdivisions, num_indices):
                        division_group = list(division_group)
                        print("gathering possible subdivision locations ...")
                        possible_indices = [_ for _ in range(len(permutation))]
                        for index_group in itertools.combinations(
                                possible_indices, num_indices):
                            index_group = list(index_group)
                            print("adding subgroups ...")
                            subdivided_permutation = add_subgroups(
                                input_list=permutation,
                                index_list=index_group,
                                subgroup_list=division_group,
                            )
                            print("converting to string ...")
                            subgrouped_permutation = evans.nested_list_to_rtm(
                                subdivided_permutation)
                            print(subgrouped_permutation)
                            print("gathing number of rotatable positions ...")
                            l_ = -1
                            for symbol in subgrouped_permutation:
                                if symbol.isdigit():
                                    l_ = l_ + 1
                            for y in range(l_):
                                print("rotating ...")
                                rotation = evans.rotate_tree(
                                    rtm_string=subgrouped_permutation, n=y)
                                print(rotation)
                                print("funneling rotation to 1 ...")
                                for funnel in evans.funnel_inner_tree_to_x(
                                        rtm_string=rotation, x=1):
                                    print("caching funnel ...")
                                    print(funnel)
                                    final_patterns.append(funnel)
            print("parsing cached funnels ...")
            for pattern in final_patterns:
                print(pattern)
                pair = (1, 2)
                time_signature = abjad.TimeSignature(pair)
                rhythm_tree_list = parser(pattern)
                rhythm_tree_container = rhythm_tree_list[0]
                r = rhythm_tree_container(pair)
                m = abjad.Markup(fr"\markup {pattern}",
                                 direction=abjad.Up,
                                 literal=True)
                abjad.attach(m, abjad.select(r).leaves()[0])
                abjad.attach(time_signature, abjad.select(r).leaves()[0])
                print("adding parsed funnel to staff ...")
                parsed_patterns.extend(r)
            print("adding staff to staff group ...")
            score = abjad.Score([parsed_patterns])
            scheme = abjad.SchemeMoment((1, 50))
            abjad.setting(score).proportional_notation_duration = scheme
            new_brackets = evans.NoteheadBracketMaker()
            for staff in abjad.select(score).components(abjad.Staff):
                new_brackets(staff)
            abjad.override(score).TupletBracket.bracket_visibility = True
            print("rendering staff group ...")
            file = abjad.LilyPondFile(
                items=[
                    score,
                    abjad.Block(name="layout"),
                    abjad.Block(name="header")
                ],
                includes=[
                    "/Users/evansdsg2/abjad/docs/source/_stylesheets/abjad.ily"
                ],
                global_staff_size=14,
                default_paper_size=("11x17landscape", "portrait"),
            )
            file.layout_block.items.append("indent = 0")
            file.header_block.items.append("tagline = ##f")
            file.header_block.items.append(f'title = "{title}"')
            abjad.show(file)
Ejemplo n.º 17
0
        print(f"Skipping card {i}")
        i += 1
        continue
    score = abjad.Score(name="Score")
    notes = card_base + [abjad.Rest('r2') for _ in range(3)
                         ] + [abjad.Note("C5", (1, 4)) for _ in range(4)]
    container = abjad.Container(notes)
    repeat = abjad.Repeat()
    abjad.attach(repeat, container)
    staff = abjad.Staff([container])
    score.append(staff)
    note = abjad.select(score).note(0)
    time_signature = abjad.TimeSignature((12, 4))
    abjad.attach(time_signature, note)

    lilypond_file = abjad.LilyPondFile(items=[preamble, score])
    abjad.show(lilypond_file)

    all_pdfs = glob.glob(
        r"C:\Users\bkier\projects\draw(0)\abjad\output_dir\*.pdf")

    path = r"C:\Users\bkier\OneDrive\Desktop\poppler-21.03.0\Library\bin"

    for pdf in all_pdfs:
        pdf_images = convert_from_path(pdf, poppler_path=path)

        for pdf_image in pdf_images:
            pdf_image.save(r"output_dir\staff.jpg", "JPEG")

        jpeg_im = Image.open(
            r"C:\Users\bkier\projects\draw(0)\abjad\output_dir\staff.jpg")
Ejemplo n.º 18
0
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))
        )
Ejemplo n.º 19
0
abjad.attach(abjad.Clef("bass"), staff1[0])

abjad.attach(abjad.Clef("treble"), staff1[4])

abjad.attach(abjad.Clef("treble^8"), staff1[-2])

h2(staff2)

abjad.attach(abjad.Clef("bass"), staff2[0])

group = abjad.StaffGroup([staff1, staff2])

score = abjad.Score([group])

moment = "#(ly:make-moment 1 25)"
abjad.setting(score).proportional_notation_duration = moment

file = abjad.LilyPondFile(
    items=[
        score,
        abjad.Block(name="layout"),
    ],
    includes=[
        "/Users/evansdsg2/abjad/docs/source/_stylesheets/abjad.ily",
        "/Users/evansdsg2/abjad/docs/source/_stylesheets/ekmelos-ji-accidental-markups.ily",
    ],
)
file.layout_block.items.append(r'\accidentalStyle "dodecaphonic"')

abjad.show(file)
Ejemplo n.º 20
0
s.fork(oboe_part)
s.fork(bassoon_part)
# have the session wait for the child processes to finish (return)
s.wait_for_children_to_finish()
performance = s.stop_transcribing()
score1 = performance.to_score()

performance2 = s.start_transcribing()
# start the oboe and bassoon parts as two parallel child processes
s.fork(oboe_part)
s.fork(bassoon_part)
# have the session wait for the child processes to finish (return)
s.wait_for_children_to_finish()
s.stop_transcribing()
score2 = performance2.to_score()

score1_block = abjad.Block(name="score")
score1_block.items.append(score1.to_abjad(wrap_as_file=False))

score2_block = abjad.Block(name="score")
score2_block.items.append(score2.to_abjad(wrap_as_file=False))

lilypond_file = abjad.LilyPondFile(items=[score1_block, score2_block])

s.kill()


def test_results():
    return (performance, performance2, score1, score2,
            abjad.lilypond(lilypond_file))
Ejemplo n.º 21
0
global_context.write_time_signatures(time_signatures)


# mats.material_name_markups()
# SCORE
score = muda.Score()
inst = muda.Instrument(
    abjad_instrument=abjad.SopranoVoice(),
    name="Soprano",
    staff_count=1,
    voice_count=[1],
    lyrics_target="Soprano_Voice_1",
)
score.append([inst])
score.write_materials([mats, lyrics, global_context])
# print(abjad.lilypond(score.score))
# score.make_skips(time_signatures)
# score.rewrite_meter(time_signatures)
lilypond_file = abjad.LilyPondFile(
    items=[score.score],
)
# print(abjad.lilypond(score.score))
os.chdir(os.path.dirname(__file__))
abjad.persist.as_ly(lilypond_file, "aperghis_score.ly")
os.system("pwd")
os.system("lilypond aperghis_example.ly")


# if __name__ == '__main__':
# aperghis_example()
Ejemplo n.º 22
0
h1(staff1)

abjad.attach(abjad.Clef("bass"), staff1[0])

abjad.attach(abjad.Clef("treble"), staff1[4])

abjad.attach(abjad.Clef("treble^8"), staff1[-2])

h2(staff2)

abjad.attach(abjad.Clef("bass"), staff2[0])

group = abjad.StaffGroup([staff1, staff2])

score = abjad.Score([group])

moment = "#(ly:make-moment 1 25)"
abjad.setting(score).proportional_notation_duration = moment

file = abjad.LilyPondFile(items=[
    '#(set-default-paper-size "a4" \'letter)',
    r"#(set-global-staff-size 16)",
    "\\include 'Users/gregoryevans/abjad/docs/source/_stylesheets/abjad.ily'",
    "\\include '/Users/gregoryevans/abjad/abjad/_stylesheets/ekmelos-ji-accidental-markups.ily'",
    score,
    abjad.Block(name="layout"),
], )
file["layout"].items.append(r'\accidentalStyle "dodecaphonic"')

abjad.show(file)
Ejemplo n.º 23
0
for handler, staff in zip(handlers_3, quartet_group):
    handler(staff)

moment = "#(ly:make-moment 1 10)"
abjad.setting(score).proportional_notation_duration = moment

block = abjad.Block(name="score")
block.items.append(score)

style = '"dodecaphonic"'
layout = abjad.Block(name="layout")
layout.items.append(rf"\accidentalStyle {style}")

file = abjad.LilyPondFile(items=[
    r'\include "/Users/gregoryevans/abjad/abjad/_stylesheets/ekmelos-ji-accidental-markups.ily"',
    r'\include "/Users/gregoryevans/scores/polillas/polillas/build/score_stylesheet.ily"',
    layout,
    block,
])

evans.make_sc_file(
    score=score,
    tempo=tempo_pair,
    current_directory=pathlib.Path(__file__).parent,
)

abjad.mutate.transpose(group_2, abjad.NamedInterval("+P8"))

abjad.show(file)
Ejemplo n.º 24
0
    abjad.attach(sig, leaf)
    global_context.append(leaf)

score = abjad.Score(
    [
        global_context,
        abjad.StaffGroup(
            [
                staff_1,
                staff_2,
            ],
            name="StaffGroup",
        ),
    ],
    name="score",
)

# brackets = evans.NoteheadBracketMaker()
# brackets(score)

file = abjad.LilyPondFile(
    items=[score],
    includes=[
        "/Users/evansdsg2/abjad/docs/source/_stylesheets/abjad.ily",
        "/Users/evansdsg2/abjad/docs/source/_stylesheets/default.ily",
        "/Users/evansdsg2/abjad/docs/source/_stylesheets/rhythm-maker-docs.ily",
    ],
)

abjad.show(file)
Ejemplo n.º 25
0
        leaf1 = iterable[i]
        leaf2 = iterable[i + 1]
        pitch1 = leaf1.written_pitch
        pitch2 = leaf2.written_pitch
        interval = abjad.NamedInterval.from_pitch_carriers(pitch1, pitch2)
        inverted_interval = abjad.NamedInterval("P1") - interval
        new_pitch = inverted_interval.transpose(leaf1.written_pitch)
        new_leaf = copy.copy(leaf1)
        new_leaf.written_pitch = new_pitch
        out.append(new_leaf)
    return out


staff1 = abjad.Staff(
    "a'8 f'8 d'8 a'8 f'8 d'8 d''8 bf'8 g'8 bf'8 g'8 e'8 g'8 e'8 cs'8 g'8 e'8 cs'8 a'8 f'8 d'8",
    name="first_staff",
)
new_leaves = adjacent_interval_inversion(staff1)
staff2 = abjad.Staff(new_leaves, name="second_staff")
score = abjad.Score([abjad.StaffGroup([staff1, staff2], name="my_group")],
                    name="my_score")
moment = abjad.SchemeMoment((1, 20))
abjad.setting(score).proportional_notation_duration = moment
file = abjad.LilyPondFile(
    items=[score],
    includes=["/Users/evansdsg2/abjad/docs/source/_stylesheets/abjad.ily"],
    global_staff_size=16,
)
abjad.show(file)
abjad.play(score)
Ejemplo n.º 26
0
                            nth_pitch_variant_combination,
                            intervallv,
                        )

                        midi_file_converter = midi.MidiFileConverter(
                            "{}/{}.mid".format(harmony_path,
                                               pitch_variant_name))
                        midi_file_converter.convert(sequential_event)

                        abjad_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
                            mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
                            MutwoPitchToHEJIAbjadPitchConverter())
                        abjad_voice = abjad_converter.convert(sequential_event)
                        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,
                            "{}/{}.pdf".format(harmony_path,
                                               pitch_variant_name),
                        )

try:
    os.mkdir(DRONE_BUILD_PATH)
except FileExistsError:
    pass

DRONE_AMBITUS = ambitus.Ambitus(pitches.JustIntonationPitch("1/4"),
                                pitches.JustIntonationPitch("1/2"))