def test_scoretools_NoteHeadList___contains___02(): chord = abjad.Chord("<ef' cs'' f''>4") assert not 18 in chord.note_heads assert not 18.0 in chord.note_heads assert not abjad.NamedPitch(18) in chord.note_heads assert not abjad.NamedPitch("fs''") in chord.note_heads assert not abjad.NoteHead(18) in chord.note_heads assert not abjad.NoteHead("fs''") in chord.note_heads
def test_scoretools_NoteHead___init___03(): r'''Initialize note-head by other note-head instance. ''' notehead = abjad.NoteHead(6) new = abjad.NoteHead(notehead) assert notehead is not new assert notehead.written_pitch == 6 assert new.written_pitch == 6
def test_scoretools_NoteHead___cmp___02(): note_head_1 = abjad.NoteHead(12) note_head_2 = abjad.NoteHead(13) assert not note_head_2 < note_head_1 assert not note_head_2 <= note_head_1 assert not note_head_2 == note_head_1 assert note_head_2 != note_head_1 assert note_head_2 > note_head_1 assert note_head_2 >= note_head_1
def test_NoteHead___init___03(): """ Initialize note-head by other note-head instance. """ notehead = abjad.NoteHead(6) new = abjad.NoteHead(notehead) assert notehead is not new assert notehead.written_pitch == 6 assert new.written_pitch == 6
def test_scoretools_NoteHead___cmp___01(): note_head_1 = abjad.NoteHead(12) note_head_2 = abjad.NoteHead(12) assert not note_head_1 < note_head_2 assert note_head_1 <= note_head_2 assert note_head_1 == note_head_2 assert not note_head_1 != note_head_2 assert not note_head_1 > note_head_2 assert note_head_1 >= note_head_2
def test_scoretools_NoteHead___setattr___01(): r'''Slots constrain note-head attributes. ''' note_head = abjad.NoteHead("cs''") assert pytest.raises(AttributeError, "note_head.foo = 'bar'")
def test_NoteHead___init___02(): """ Initialize note-head by LilyPond-style pitch string. """ notehead = abjad.NoteHead('cs,,,') assert notehead.written_pitch == abjad.NamedPitch('cs,,,')
def test_NoteHead___init___01(): """ Initialize note-head by number. """ notehead = abjad.NoteHead(6) assert notehead.written_pitch == abjad.NamedPitch(6)
def test_NoteHead___init___04(): """ Initialize note-head with tweak manager. """ note_head = abjad.NoteHead("cs''", tweaks=abjad.tweak('red').color) assert format(note_head) == "\\tweak color #red\ncs''"
def test_NoteHead_is_cautionary_01(): note_head = abjad.NoteHead(written_pitch="c'") assert note_head.is_cautionary is None note_head.is_cautionary = True assert note_head.is_cautionary is True note_head.is_cautionary = False assert note_head.is_cautionary is False
def test_scoretools_NoteHead_is_parenthesized_02(): note_head = abjad.NoteHead(written_pitch="c'") note_head.is_parenthesized = True assert format(note_head) == abjad.String.normalize(r''' \parenthesize c' ''')
def test_NoteHead___setattr___01(): """ Slots constrain note-head attributes. """ note_head = abjad.NoteHead("cs''") assert pytest.raises(AttributeError, "note_head.foo = 'bar'")
def test_NoteHead_is_parenthesized_02(): note_head = abjad.NoteHead(written_pitch="c'") note_head.is_parenthesized = True assert abjad.lilypond(note_head) == abjad.String.normalize(r""" \parenthesize c' """)
def test_NoteHead_is_parenthesized_01(): note_head = abjad.NoteHead(written_pitch="c'") assert note_head.is_parenthesized is None note_head.is_parenthesized = True assert note_head.is_parenthesized == True note_head.is_parenthesized = False assert note_head.is_parenthesized == False
def test_scoretools_NoteHead_is_forced_01(): note_head = abjad.NoteHead(written_pitch="c'") assert note_head.is_forced is None note_head.is_forced = True assert note_head.is_forced == True note_head.is_forced = False assert note_head.is_forced == False
def test_NoteHead___init___04(): """ Initialize note-head with tweak manager. """ note_head = abjad.NoteHead("cs''", tweaks=abjad.tweak("#red").color) assert abjad.lilypond(note_head) == "\\tweak color #red\ncs''"
def test_NoteHead___setattr___01(): """ Slots constrain note-head attributes. """ note_head = abjad.NoteHead("cs''") with pytest.raises(AttributeError): note_head.foo = "bar"
def test_scoretools_NoteHead___init___04(): r'''Initialize note-head with tweak pairs. ''' note_head = abjad.NoteHead("cs''", tweak_pairs=(('color', 'red'), )) tweak = abjad.lilypondnametools.LilyPondNameManager() tweak.color = 'red' assert note_head.written_pitch == abjad.NamedPitch("cs''") assert note_head.tweak == tweak
def test_scoretools_NoteHeadList___contains___01(): chord = abjad.Chord("<ef' cs'' f''>4") assert 17 in chord.note_heads assert 17.0 in chord.note_heads assert abjad.NamedPitch(17) in chord.note_heads assert abjad.NamedPitch("f''") in chord.note_heads assert chord.note_heads[1] in chord.note_heads assert abjad.NoteHead("f''") in chord.note_heads
def test_NoteHead___cmp___03(): note_head_1 = abjad.NoteHead(12) note_head_2 = 12 assert not note_head_1 < note_head_2 assert note_head_1 <= note_head_2 assert note_head_1 == note_head_2 assert not note_head_1 != note_head_2 assert not note_head_1 > note_head_2 assert note_head_1 >= note_head_2
def test_NoteHead___cmp___04(): note_head_1 = abjad.NoteHead(12) note_head_2 = 13 assert not note_head_2 < note_head_1 assert not note_head_2 <= note_head_1 assert not note_head_2 == note_head_1 assert note_head_2 != note_head_1 assert note_head_2 > note_head_1 assert note_head_2 >= note_head_1
def test_NoteHead___deepcopy___01(): note_head_1 = abjad.NoteHead("cs''") abjad.tweak(note_head_1).color = "red" note_head_1.is_cautionary = True note_head_1.is_forced = True note_head_2 = copy.deepcopy(note_head_1) assert isinstance(note_head_1, abjad.NoteHead) assert isinstance(note_head_2, abjad.NoteHead) assert note_head_1 == note_head_2 assert note_head_1 is not note_head_2 assert note_head_1.is_cautionary == note_head_2.is_cautionary assert note_head_1.is_forced == note_head_2.is_forced assert note_head_1.tweaks == note_head_2.tweaks assert note_head_1.tweaks is not note_head_2.tweaks
def invertChord(chord, inv): if 0 > inv > 4: print("can't invert beyond tetrads") invertedChord = abjad.Chord() _chord = chord.__copy__() if isinstance(chord, abjad.Chord): for i in range(inv): noteList = _chord.note_heads # copy noteheads to new list lowestNoteHead = noteList.pop(0) # get lowest note_head lowestPitch = lowestNoteHead.named_pitch # note_head to pitch highestPitch = lowestPitch.transpose(12) # transpose up an octave highestNoteHead = abjad.NoteHead(highestPitch.name) # Pitch to NoteHead newNoteList = noteList[0::] # make new list of upper tones newNoteList.append(highestNoteHead) # append notehead to list _chord.note_heads = newNoteList # reset _chord with permuted list # print(_chord) return _chord # return target inversion
def test_scoretools_NoteHead___deepcopy___01(): note_head_1 = abjad.NoteHead("cs''") note_head_1.tweak.color = 'red' note_head_1.is_cautionary = True note_head_1.is_forced = True note_head_2 = copy.deepcopy(note_head_1) assert isinstance(note_head_1, abjad.NoteHead) assert isinstance(note_head_2, abjad.NoteHead) assert note_head_1 == note_head_2 assert note_head_1 is not note_head_2 assert note_head_1.is_cautionary == note_head_2.is_cautionary assert note_head_1.is_forced == note_head_2.is_forced assert note_head_1.tweak == note_head_2.tweak assert note_head_1.tweak is not note_head_2.tweak
def test_NoteHead___copy___01(): note_head_1 = abjad.NoteHead("cs''") note_head_1.is_cautionary = True note_head_1.is_forced = True abjad.tweak(note_head_1).color = 'red' abjad.tweak(note_head_1).font_size = -2 note_head_2 = copy.copy(note_head_1) assert isinstance(note_head_1, abjad.NoteHead) assert isinstance(note_head_2, abjad.NoteHead) assert note_head_1 == note_head_2 assert note_head_1 is not note_head_2 assert note_head_1.is_cautionary == note_head_2.is_cautionary assert note_head_1.is_forced == note_head_2.is_forced assert note_head_1.tweaks == note_head_2.tweaks assert note_head_1.tweaks is not note_head_2.tweaks
def test_scoretools_NoteHeadList___setitem___03(): r'''Set note-head with tweaked note-head. ''' chord = abjad.Chord("<c' cs'' f''>4") note_head = abjad.NoteHead(3) note_head.tweak.color = 'red' chord.note_heads[0] = note_head assert format(chord) == abjad.String.normalize(r''' < \tweak color #red ef' cs'' f'' >4 ''') assert abjad.inspect(chord).is_well_formed()
def test_scoretools_NoteHeadList_append_01(): r'''Append tweaked note-head to chord. ''' chord = abjad.Chord("<c' d'>4") note_head = abjad.NoteHead("b'") note_head.tweak.style = 'harmonic' chord.note_heads.append(note_head) assert format(chord) == abjad.String.normalize(r''' < c' d' \tweak style #'harmonic b' >4 ''') assert note_head._client is chord
def test_NoteHeadList___setitem___03(): """ Set note-head with tweaked note-head. """ chord = abjad.Chord("<c' cs'' f''>4") note_head = abjad.NoteHead(3) abjad.tweak(note_head).color = "red" chord.note_heads[0] = note_head assert format(chord) == abjad.String.normalize(r""" < \tweak color #red ef' cs'' f'' >4 """) assert abjad.inspect(chord).wellformed()
def test_NoteHeadList_append_01(): """ Append tweaked note-head to chord. """ chord = abjad.Chord("<c' d'>4") note_head = abjad.NoteHead("b'") abjad.tweak(note_head).style = 'harmonic' chord.note_heads.append(note_head) assert format(chord) == abjad.String.normalize(r""" < c' d' \tweak style #'harmonic b' >4 """) assert note_head._client is chord
[[4,6],1], [[7,5],2], [[1,6],4], [[2,7],1], [[4,1],1], [[7,5],1], [[1,6],4], [[7,5],1], [[1,6],2], [[7,5],1], [[1,6],2], [[2,7],2], [[6,3],2], [[5,2],3], [[6,3],1], [[5,2],4], [[6,3],1], [[5,2],2] ] pitches = {1:"e''",2:"d''",3:"c''",4:"b'",5:"a'",6:"g'",7:"f'",8:"e'",9:"d'",10:"c'"} QUAVER = abjad.Duration(1,8) CROTCHET = 2*QUAVER staff = abjad.Staff() for (interval, length) in hymn: for i in range(length): staff.append(abjad.Note(pitches[interval[1]], CROTCHET)) if interval[1] in (1,2): low_note = abjad.NoteHead(pitches[interval[1]+7]) abjad.tweak(low_note).font_size = -3 chord = abjad.Chord([], CROTCHET) chord.note_heads.extend([staff[-1].note_head, low_note]) staff[-1] = chord abjad.attach(abjad.TimeSignature((18, 4)), staff[0]) abjad.attach(abjad.TimeSignature((9, 4)), staff[18]) abjad.attach(abjad.TimeSignature((10, 4)), staff[27]) abjad.attach(abjad.TimeSignature((10, 4)), staff[37]) abjad.attach(abjad.TimeSignature((12, 4)), staff[47]) abjad.attach(abjad.TimeSignature((13, 4)), staff[59]) score = abjad.Score([staff]) score.add_final_bar_line() abjad.show(score)