Ejemplo n.º 1
0
def test_equality_an2():
    n1 = m21.note.Note(nameWithOctave='D5', quarterLength=2)
    n1.id = 344
    n1.tie = m21.tie.Tie('stop')
    n2 = m21.note.Note(nameWithOctave='D5', quarterLength=2)
    n2.id = 344
    n2.tie = m21.tie.Tie('stop')
    #create annotated note
    anote1 = nlin.AnnotatedNote(n1, [], [])
    anote2 = nlin.AnnotatedNote(n2, [], [])
    assert (anote1 == anote2)
    assert (repr(anote1) == repr(anote2))
Ejemplo n.º 2
0
def test_pitches_diff1():
    n1 = m21.note.Note(nameWithOctave='D#5', quarterLength=1)
    n2 = m21.note.Note(nameWithOctave='D--5', quarterLength=1)
    #create AnnotatedNotes
    note1 = nlin.AnnotatedNote(n1, [], [])
    note2 = nlin.AnnotatedNote(n2, [], [])
    #pitches to compare
    pitch1 = note1.pitches[0]
    pitch2 = note2.pitches[0]
    #compare
    op_list, cost = scl.pitches_diff(pitch1, pitch2, note1, note2, (0, 0))
    assert (cost == 1)
    assert (op_list == [("accidentedit", note1, note2, 1, (0, 0))])
Ejemplo n.º 3
0
def test_pitches_diff2():
    n1 = m21.note.Note(nameWithOctave='E5', quarterLength=2)
    n2 = m21.note.Note(nameWithOctave='D--5', quarterLength=1)
    note1 = nlin.AnnotatedNote(n1, [], [])
    note2 = nlin.AnnotatedNote(n2, [], [])
    #pitches to compare
    pitch1 = note1.pitches[0]
    pitch2 = note2.pitches[0]
    #compare
    op_list, cost = scl.pitches_diff(pitch1, pitch2, note1, note2, (0, 0))
    assert (cost == 2)
    assert (len(op_list) == 2)
    assert (("accidentins", None, note2, 1, (0, 0)) in op_list)
    assert (("pitchnameedit", note1, note2, 1, (0, 0)) in op_list)
Ejemplo n.º 4
0
def test_pitches_diff4():
    n1 = m21.note.Note(nameWithOctave='D5', quarterLength=2)
    n1.tie = m21.tie.Tie('stop')
    n2 = m21.note.Note(nameWithOctave='D#5', quarterLength=3)
    n2.tie = m21.tie.Tie('stop')
    note1 = nlin.AnnotatedNote(n1, [], [])
    note2 = nlin.AnnotatedNote(n2, [], [])
    #pitches to compare
    pitch1 = note1.pitches[0]
    pitch2 = note2.pitches[0]
    #compare
    op_list, cost = scl.pitches_diff(pitch1, pitch2, note1, note2, (0, 0))
    assert (cost == 1)
    assert (len(op_list) == 1)
    assert (("accidentins", None, note2, 1, (0, 0)) in op_list)
Ejemplo n.º 5
0
def test_pitches_diff3():
    n1 = m21.note.Note(nameWithOctave='D--5', quarterLength=2)
    n1.tie = m21.tie.Tie('stop')
    n2 = m21.note.Rest(quarterLength=0.5)
    note1 = nlin.AnnotatedNote(n1, [], [])
    note2 = nlin.AnnotatedNote(n2, [], [])
    #pitches to compare
    pitch1 = note1.pitches[0]
    pitch2 = note2.pitches[0]
    #compare
    op_list, cost = scl.pitches_diff(pitch1, pitch2, note1, note2, (0, 0))
    assert (cost == 3)
    assert (len(op_list) == 3)
    assert (("accidentdel", note1, None, 1, (0, 0)) in op_list)
    assert (("pitchtypeedit", note1, note2, 1, (0, 0)) in op_list)
    assert (("tiedel", note1, None, 1, (0, 0)) in op_list)
Ejemplo n.º 6
0
def test_annotNote1():
    n1 = m21.note.Note(nameWithOctave='D#5', quarterLength=1)
    n1.id = 344
    #create annotated note
    anote = nlin.AnnotatedNote(n1, [], [])
    assert (anote.__repr__() == "[('D5', 'sharp', False)],4,0,[],[],344")
    assert (str(anote) == "[D5sharp]4")
Ejemplo n.º 7
0
def test_annotNote3():
    n1 = m21.note.Note(nameWithOctave='D5', quarterLength=2)
    n1.id = 344
    n1.tie = m21.tie.Tie('stop')
    #create annotated note
    anote = nlin.AnnotatedNote(n1, [], [])
    assert (anote.__repr__() == "[('D5', 'None', True)],2,0,[],[],344")
    assert (str(anote) == "[D5T]2")
Ejemplo n.º 8
0
def test_annotNote2():
    n1 = m21.note.Note(nameWithOctave='E#5', quarterLength=0.5)
    n1.id = 344
    #create annotated note
    anote = nlin.AnnotatedNote(n1, ["start"], ["start"])
    assert (anote.__repr__() ==
            "[('E5', 'sharp', False)],4,0,['start'],['start'],344")
    assert (str(anote) == "[E5sharp]4BsrTsr")
Ejemplo n.º 9
0
def test_noteNode_size4():
    n1 = m21.note.Note(nameWithOctave='D5')
    n2 = m21.note.Note(nameWithOctave='F#5')
    n2.tie = m21.tie.Tie('stop')
    n3 = m21.note.Note(nameWithOctave='G#5')
    d = m21.duration.Duration(1.75)
    chord = m21.chord.Chord([n1, n2, n3], duration=d)
    #create annotated note
    anote = nlin.AnnotatedNote(chord, [], [])
    assert (anote.notation_size() == 12)
Ejemplo n.º 10
0
def test_noteNode_size3():
    d = m21.duration.Duration(1.5)
    n1 = m21.chord.Chord(['D', 'F#', 'A'], duration=d)
    #create annotated note
    anote = nlin.AnnotatedNote(n1, [], [])
    assert (anote.notation_size() == 7)
Ejemplo n.º 11
0
def test_annotNote_size2():
    n1 = m21.note.Note(nameWithOctave='D#5', quarterLength=1.5)
    n1.tie = m21.tie.Tie('stop')
    #create annotated note
    anote = nlin.AnnotatedNote(n1, [], [])
    assert (anote.notation_size() == 4)