Spaces:
Running
Running
fix for random
Browse files- beat_manipulator/main.py +4 -0
beat_manipulator/main.py
CHANGED
|
@@ -206,7 +206,9 @@ class song:
|
|
| 206 |
import random,math
|
| 207 |
pattern = ''
|
| 208 |
rand_length=0
|
|
|
|
| 209 |
while True:
|
|
|
|
| 210 |
rand_num = int(math.floor(random.triangular(1, 16, rand_length-1)))
|
| 211 |
if random.uniform(0, rand_num)>rand_length: rand_num = rand_length+1
|
| 212 |
rand_slice = random.choices(['','>0.5','>0.25', '<0.5', '<0.25', '<1/3', '<2/3', '>1/3', '>2/3', '<0.75', '>0.75',
|
|
@@ -223,12 +225,14 @@ class song:
|
|
| 223 |
if random.uniform(rand_num,16)>14: break
|
| 224 |
else:
|
| 225 |
if random.uniform(rand_num,16)>15.5: break
|
|
|
|
| 226 |
pattern_length = 4
|
| 227 |
if rand_length > 6: pattern_length = 8
|
| 228 |
if rand_length > 12: pattern_length = 16
|
| 229 |
if rand_length > 24: pattern_length = 32
|
| 230 |
|
| 231 |
|
|
|
|
| 232 |
|
| 233 |
from . import parse
|
| 234 |
pattern, operators, pattern_length, shuffle_groups, shuffle_beats, c_slice, c_misc, c_join = parse.parse(pattern = pattern, samples = samples, pattern_length = length, log = self.log)
|
|
|
|
| 206 |
import random,math
|
| 207 |
pattern = ''
|
| 208 |
rand_length=0
|
| 209 |
+
limit = 100
|
| 210 |
while True:
|
| 211 |
+
limit -= 1
|
| 212 |
rand_num = int(math.floor(random.triangular(1, 16, rand_length-1)))
|
| 213 |
if random.uniform(0, rand_num)>rand_length: rand_num = rand_length+1
|
| 214 |
rand_slice = random.choices(['','>0.5','>0.25', '<0.5', '<0.25', '<1/3', '<2/3', '>1/3', '>2/3', '<0.75', '>0.75',
|
|
|
|
| 225 |
if random.uniform(rand_num,16)>14: break
|
| 226 |
else:
|
| 227 |
if random.uniform(rand_num,16)>15.5: break
|
| 228 |
+
if limit <= 0: break
|
| 229 |
pattern_length = 4
|
| 230 |
if rand_length > 6: pattern_length = 8
|
| 231 |
if rand_length > 12: pattern_length = 16
|
| 232 |
if rand_length > 24: pattern_length = 32
|
| 233 |
|
| 234 |
|
| 235 |
+
|
| 236 |
|
| 237 |
from . import parse
|
| 238 |
pattern, operators, pattern_length, shuffle_groups, shuffle_beats, c_slice, c_misc, c_join = parse.parse(pattern = pattern, samples = samples, pattern_length = length, log = self.log)
|