Beispiel #1
0
    def visit_Score(self, obj):
        sco = """\score {{
        <<
        {0}
        >>
        }}"""

        staff = """
        \\new Staff {{
        {0}
        }}
        """

        result = []
        pickup_value = obj.get_pickup_value()

        for spine in reversed(obj.get_spines()):
            out = []
            note_count = 0
            for voice in spine:
                print(voice)
                if type(voice) is list:
                    # FIXME
                    # If voice is a list it should have 1 or more EXTRA voices.
                    # In every WTC the number of items in voice is 2
                    # We will have the main voice and the new one
                    # Should it behave differently if the new spine was created by *+ or *^?
                    print(voice)
                else:
                    if type(voice) is Note:
                        note_count += 1

                    if type(voice) is Note and note_count == 1 and pickup_value:
                        out.append("\\partial {0}".format(music.frac_to_dur(pickup_value, "lily")))

                    out.append(show_lilypond(voice))

            result.append(staff.format(" ".join(out)))

        return sco.format("\n".join(result))
Beispiel #2
0
 def visit_Rest(self, obj):
     dur = music.frac_to_dur(obj.duration)
     return "r{0}".format(dur)
Beispiel #3
0
 def visit_Note(self, obj):
     name = music.notename_to_lily(obj.name, obj.octave)
     dur = music.frac_to_dur(obj.duration)
     return "{0}{1}".format(name,  dur)
Beispiel #4
0
 def visit_Note(self, obj):
     name = music.notename_to_lily(obj.name, obj.octave)
     dur = music.frac_to_dur(obj.duration)
     articulations = [NOTE_TABLE[a]['lily'] for a in obj.articulations]
     return "{0}{1}{2}".format(name, dur, "".join(articulations))
Beispiel #5
0
def test_frac_to_dur_7_16():
    assert music.frac_to_dur(Fraction(7, 16)) == "4.."
Beispiel #6
0
def test_frac_to_dur_7_8():
    assert music.frac_to_dur(Fraction(7, 8)) == "2.."
Beispiel #7
0
def test_frac_to_dur_3_4():
    assert music.frac_to_dur(Fraction(3, 4)) == "2."
Beispiel #8
0
def test_frac_to_dur_3_8():
    assert music.frac_to_dur(Fraction(3, 8)) == "4."
Beispiel #9
0
def test_frac_to_dur_2():
    assert music.frac_to_dur(2) == "0"
Beispiel #10
0
 def visit_Note(self, obj):
     name = music.notename_to_humdrum(obj.name, obj.octave)
     dur = music.frac_to_dur(obj.duration)
     articulations = [humdrum_table[a] for a in obj.articulations]
     return "{0}{1}{2}".format(dur, name, "".join(articulations))