Last active
May 14, 2018 22:30
-
-
Save drsm79/b351d171e600dea0f428dfc42e028d38 to your computer and use it in GitHub Desktop.
Fibonacci to chord sequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib_next(current, previous): | |
return current + previous, current, int(oct(current + previous).strip('L')[-1]) | |
scale = ['F', 'g', 'a', 'Bb', 'C', 'd', 'em7b5', 'F'] | |
def runme(iterations=False): | |
pattern = [0, 1] | |
previous, current = pattern | |
n = 0 | |
while len(pattern) < 5 or (pattern[:4] != pattern[-4:]): | |
current, previous, pelem = fib_next(current, previous) | |
print current, previous, pelem, scale[pelem] | |
pattern.append(pelem) | |
n += 1 | |
if iterations and n > iterations: | |
break | |
printable_pattern = [] | |
for p in pattern: | |
printable_pattern.append(scale[p]) | |
print ' '.join(printable_pattern) | |
print n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
F g g a Bb d F d d a F g F g g a
- sounds quite nice as it goes