-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_texturizers.py
166 lines (141 loc) · 5.15 KB
/
test_texturizers.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import unittest
from AugmentedNet.texturizers import (
available_number_of_notes,
available_templates,
available_durations,
applyTextureTemplate,
_getRelevantTemplates,
)
basssplit_whole_triad = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,2.0,,['C4'],[],[True]
2.0,2.0,,"['E-4', 'G-4']",['m3'],"[True, True]"
"""
basssplit_quarter_seventh = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,0.5,,['C4'],[],[True]
0.5,0.5,,"['E-4', 'G-4', 'B--4']","['m3', 'd5']","[True, True, True]"
"""
alberti_half_triad = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,0.5,,['C4'],[],[True]
0.5,0.5,,['G-4'],[],[True]
1.0,0.5,,['E-4'],[],[True]
1.5,0.5,,['G-4'],[],[True]
"""
alberti_whole_seventh = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,1.0,,['C4'],[],[True]
1.0,1.0,,['B--4'],[],[True]
2.0,1.0,,['E-4'],[],[True]
3.0,1.0,,['G-4'],[],[True]
"""
syncopation_whole_triad = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,1.0,,['G-4'],[],[True]
1.0,2.0,,['C4'],[],[True]
3.0,1.0,,['E-4'],[],[True]
"""
syncopation_half_seventh = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,0.5,,['B--4'],[],[True]
0.5,1.0,,"['C4', 'E-4', 'G-4']","['m3', 'd5']","[True, True, True]"
1.5,0.5,,"['C4', 'E-4', 'G-4']","['m3', 'd5']","[True, True, True]"
"""
blockchord_quarter_triad = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,1.0,,"['C4', 'E-4', 'G-4']","['m3', 'd5']","[True, True, True]"
"""
blockchord_half_seventh = """\
s_offset,s_duration,s_measure,s_notes,s_intervals,s_isOnset
0.0,2.0,,"['C4', 'E-4', 'G-4', 'B--4']","['m3', 'd5', 'd7']","[True, True, True, True]"
"""
class TestTexturizers(unittest.TestCase):
def test_available_number_of_notes(self):
GT = [4, 3]
self.assertEqual(available_number_of_notes, GT)
def test_available_durations(self):
GT = [4.0, 3.0, 2.0, 1.5, 1.0]
self.assertEqual(available_durations, GT)
def test_available_templates(self):
GT = ["BassSplit", "Alberti", "Syncopation", "BlockChord"]
self.assertEqual(list(available_templates.keys()), GT)
def test_relevant_templates(self):
templates1 = _getRelevantTemplates(4.0, 4)
templates2 = _getRelevantTemplates(1.0, 4)
self.assertEqual(len(templates1), 4)
self.assertEqual(len(templates2), 3)
def test_basssplit_whole_triad(self):
GT = basssplit_whole_triad
duration = 4.0
notes = ["C4", "E-4", "G-4"]
intervals = ["m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="BassSplit"
)
self.assertEqual(template, GT)
def test_basssplit_quarter_seventh(self):
GT = basssplit_quarter_seventh
duration = 1.0
notes = ["C4", "E-4", "G-4", "B--4"]
intervals = ["m3", "d5", "d7", "m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="BassSplit"
)
self.assertEqual(template, GT)
def test_alberti_half_triad(self):
GT = alberti_half_triad
duration = 2.0
notes = ["C4", "E-4", "G-4"]
intervals = ["m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="Alberti"
)
self.assertEqual(template, GT)
def test_alberti_whole_seventh(self):
GT = alberti_whole_seventh
duration = 4.0
notes = ["C4", "E-4", "G-4", "B--4"]
intervals = ["m3", "d5", "d7", "m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="Alberti"
)
self.assertEqual(template, GT)
def test_syncopation_whole_triad(self):
GT = syncopation_whole_triad
duration = 4.0
notes = ["C4", "E-4", "G-4"]
intervals = ["m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="Syncopation"
)
self.assertEqual(template, GT)
def test_syncopation_half_seventh(self):
GT = syncopation_half_seventh
duration = 2.0
notes = ["C4", "E-4", "G-4", "B--4"]
intervals = ["m3", "d5", "d7", "m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="Syncopation"
)
self.assertEqual(template, GT)
def test_blockchord_quarter_triad(self):
GT = blockchord_quarter_triad
duration = 1.0
notes = ["C4", "E-4", "G-4"]
intervals = ["m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="BlockChord"
)
self.assertEqual(template, GT)
def test_blockchord_half_seventh(self):
GT = blockchord_half_seventh
duration = 2.0
notes = ["C4", "E-4", "G-4", "B--4"]
intervals = ["m3", "d5", "d7", "m3", "d5", "m3"]
template = applyTextureTemplate(
duration, notes, intervals, templateName="BlockChord"
)
self.assertEqual(template, GT)
if __name__ == "__main__":
unittest.main()