|
@@ -28,7 +28,7 @@ os.sched_setscheduler(os.getpid(), os.SCHED_FIFO, os.sched_param(1))
|
|
class Compose:
|
|
class Compose:
|
|
_DEFAULT_PARAM={
|
|
_DEFAULT_PARAM={
|
|
'keys' : [57, 59,60,62,64,65,67],
|
|
'keys' : [57, 59,60,62,64,65,67],
|
|
- "times": [ [0.5,4], [1,4], [1.5, 1]]
|
|
|
|
|
|
+ "times": [ [0.5,10], [1,3], [1.5, 1]]
|
|
}
|
|
}
|
|
|
|
|
|
def __init__(self, param=_DEFAULT_PARAM):
|
|
def __init__(self, param=_DEFAULT_PARAM):
|
|
@@ -38,13 +38,15 @@ class Compose:
|
|
for i in keys: self.keys.append((i, randint(0,10)))
|
|
for i in keys: self.keys.append((i, randint(0,10)))
|
|
self.times=param["times"] if "times" in param else Compose._DEFAULT_PARAM["times"]
|
|
self.times=param["times"] if "times" in param else Compose._DEFAULT_PARAM["times"]
|
|
|
|
|
|
- temps=64
|
|
|
|
- while temps>0:
|
|
|
|
- x=self.randTime(temps)
|
|
|
|
- k=self.randKey()
|
|
|
|
- self.track.addNote(x, k)
|
|
|
|
- temps-=x
|
|
|
|
- print("Mesure: "+str(8-temps))
|
|
|
|
|
|
+
|
|
|
|
+ for i in range(128):
|
|
|
|
+ temps=16
|
|
|
|
+ while temps>0:
|
|
|
|
+ x=self.randTime(temps)
|
|
|
|
+ k=self.randKey()
|
|
|
|
+ self.track.addNote(x, k)
|
|
|
|
+ temps-=x
|
|
|
|
+ print("Mesure: "+str(8-temps))
|
|
|
|
|
|
def randTime(self, max):
|
|
def randTime(self, max):
|
|
x=0
|
|
x=0
|
|
@@ -58,12 +60,13 @@ class Compose:
|
|
|
|
|
|
def randKey(self):
|
|
def randKey(self):
|
|
x = 0
|
|
x = 0
|
|
|
|
+ transpose=12
|
|
for i in self.keys: x += i[1] if len(i) > 1 else 1
|
|
for i in self.keys: x += i[1] if len(i) > 1 else 1
|
|
dice = randint(0, x - 1)
|
|
dice = randint(0, x - 1)
|
|
for i in self.keys:
|
|
for i in self.keys:
|
|
dice -= i[1]
|
|
dice -= i[1]
|
|
- if dice <= 0: return i[0]
|
|
|
|
- return self.keys[0][0]
|
|
|
|
|
|
+ if dice <= 0: return i[0]+transpose
|
|
|
|
+ return self.keys[0][0]+transpose
|
|
|
|
|
|
|
|
|
|
def play(self):
|
|
def play(self):
|
|
@@ -80,6 +83,7 @@ class Compose:
|
|
while True:
|
|
while True:
|
|
mp.play()
|
|
mp.play()
|
|
print("===========")
|
|
print("===========")
|
|
|
|
+ exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
|