-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote_address.txt
More file actions
78 lines (61 loc) · 2.43 KB
/
note_address.txt
File metadata and controls
78 lines (61 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
>>> from dsn.s_expr.note_address import NoteAddress, TheChild, InScore, SExprELS18NoteAddress, ELS18RenderingAddress
>>> from dsn.s_expr.clef_address import play_simple_score, score_with_global_address
>>> from dsn.s_expr.clef import BecomeList, Insert, Extend, Chord, Score as CScore
>>> from dsn.s_expr.score import Score
>>>
>>> from dsn.s_expr.construct import play_note
>>>
>>> score = Score.from_list([
... BecomeList(),
... Chord(CScore([
... Insert(0, BecomeList()),
... Extend(0, Insert(0, BecomeList())),
... ])),
... ])
>>>
>>> score_wga = score_with_global_address(score)
>>>
>>> score_wga.notes()[0].address
(@0)
>>> score_wga.notes()[1].address
(@1)
>>> score_wga.notes()[1].score.notes[0].address
(@1, @0)
>>> score_wga.notes()[1].score.notes[1].address
(@1, @1)
>>> score_wga.notes()[1].score.notes[1].child_note.address
(@1, @1, >)
>>> tree_wga = play_simple_score(score_wga)
>>> tree_wga.score.last_note().address
(@1)
>>> tree_wga.children[0].children[0].score.last_note().address
(@1, @1, >, >)
## SExprELS18NoteAddress
The below tests for SExprELS18NoteAddress are specific to the method `is_prefix_of`.
>>> item_3_at_root = SExprELS18NoteAddress(NoteAddress((InScore(3),)))
>>> a_child_of_item_2_at_root = SExprELS18NoteAddress(NoteAddress((InScore(2), TheChild(),)))
>>> a_child_of_item_3_at_root = SExprELS18NoteAddress(NoteAddress((InScore(3), TheChild(),)))
>>> index_field_of_item_3_at_root = SExprELS18NoteAddress(NoteAddress((InScore(3),)), 'index')
>>> a_chord_at_4 = SExprELS18NoteAddress(NoteAddress((InScore(4),)))
>>> the_list_of_the_chord = SExprELS18NoteAddress(NoteAddress((InScore(4),)), 'list')
>>> the_name_of_the_chord = SExprELS18NoteAddress(NoteAddress((InScore(4),)), 'name')
>>> item_3_in_list = SExprELS18NoteAddress(NoteAddress((InScore(4), InScore(3))))
>>> item_3_at_root.is_prefix_of(a_child_of_item_2_at_root)
False
>>> item_3_at_root.is_prefix_of(a_child_of_item_3_at_root)
True
>>> item_3_at_root.is_prefix_of(index_field_of_item_3_at_root)
True
>>> a_chord_at_4.is_prefix_of(the_name_of_the_chord)
True
>>> a_chord_at_4.is_prefix_of(the_list_of_the_chord)
True
# Special case: 'list'
>>> the_list_of_the_chord.is_prefix_of(item_3_in_list)
True
>>> the_name_of_the_chord.is_prefix_of(item_3_in_list)
False
>>> the_list_of_the_chord.is_prefix_of(the_name_of_the_chord)
False
>>> the_name_of_the_chord.is_prefix_of(the_list_of_the_chord)
False