-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.py
146 lines (115 loc) · 3.54 KB
/
base.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
import scales as sc
from music21 import stream, note
octave_adjust = sc.octave_adjust
class Base:
def __init__(self, process, loop=1, base_type=None):
self.base = []
self.loop = loop
# self.create_base(base_type)
self.first_chord = process[0]
self.keys = sc.make_scale(self.first_chord[0], self.first_chord[1])
self.base = self.create_base0(process, loop)
def make_base(self, base):
base_melody = stream.Stream()
for itr_note in base:
name = itr_note[0]
duration = itr_note[1]
if name == 'r':
temp_note = note.Rest(type='quarter')
else:
temp_note = note.Note(name, quarterLength=duration)
base_melody.append(temp_note)
return base_melody
############## Canon process base ##################
def create_base0(self, process, loop, name='new'):
# base0 = [['c3*',4], ['g3*',4], ['c4*',4], ['r',4],
# ['g2*',4], ['d3*',4], ['g3*',4], ['r',4],
# ['a2*',4], ['e3*',4], ['a3*',4], ['r',4],
# ['e2*',4], ['b2*',4], ['e3*',4], ['r',4],
# ['f2*',4], ['c3*',4], ['f3*',4], ['r',4],
# ['c2*',4], ['g2*',4], ['c3*',4], ['r',4],
# ['f2*',4], ['c3*',4], ['f3*',4], ['r',4],
# ['g2*',4], ['d3*',4], ['g3*',4], ['r',4]]
base_1 = []
first_chord = True
for loop_index in range(loop):
for chord in process:
if first_chord:
first_chord = False
scale = sc.make_scale(chord[0], chord[1], 3)
else:
scale = sc.make_scale(chord[0], chord[1], 2)
do = scale[0+octave_adjust]
mi = scale[2+octave_adjust]
so = scale[4+octave_adjust]
do_octave = scale[7+octave_adjust]
base_1.append((do,1))
base_1.append((so,1))
base_1.append((do_octave,1))
base_1.append(('r',1))
base_melody = self.make_base(base_1)
return base_melody
def create_base1(self, process, name='new'):
base_1 = []
base_2 = []
for chord in process:
scale = sc.make_scale(chord[0],chord[1], 3)
do = scale[0+octave_adjust]
mi = scale[2+octave_adjust]
so = scale[4+octave_adjust]
base_1.append((do+'*',8))
base_1.append(('r',8))
base_1.append((so+'*',8))
base_1.append(('r',8))
base_2.append(('r',8))
base_2.append(('r',8))
base_2.append((mi+'*',8))
base_2.append(('r',8))
##### Tried to make last chord different as a ending chord #####
# last_chord = process[-1]
# last_scale = make_scale(last_chord[0],last_chord[1])
# do = last_scale[0]
# mi = last_scale[2]
# so = last_scale[4]
# base_1.append((so,8))
# base_1.append(('r',8))
# base_1.append((mi,8))
# base_1.append(('r',8))
# base_1.append((do,4))
# base_2.append((mi,8))
# base_2.append(('r',8))
# base_2.append((do,8))
# base_2.append(('r',8))
return None
def create_base2(self, process, name='new'):
base_1 = []
base_2 = []
for chord in process:
scale = make_scale(chord[0],chord[1], 3)
do = scale[0+octave_adjust]
mi = scale[2+octave_adjust]
so = scale[4+octave_adjust]
base_1.append((do+'*',8))
base_1.append(('r',8))
base_1.append((so+'*',8))
base_1.append(('r',8))
base_2.append(('r',8))
base_2.append(('r',8))
base_2.append((mi+'*',8))
base_2.append(('r',8))
##### Tried to make last chord different as a ending chord #####
# last_chord = process[-1]
# last_scale = make_scale(last_chord[0],last_chord[1])
# do = last_scale[0]
# mi = last_scale[2]
# so = last_scale[4]
# base_1.append((so,8))
# base_1.append(('r',8))
# base_1.append((mi,8))
# base_1.append(('r',8))
# base_1.append((do,4))
# base_2.append((mi,8))
# base_2.append(('r',8))
# base_2.append((do,8))
# base_2.append(('r',8))
return None