Last active
May 15, 2018 00:45
-
-
Save nunenuh/4beca9108bad778e024e221c3c2fe9ae to your computer and use it in GitHub Desktop.
Generating tone based on Factor 9 built on 432
This file contains hidden or 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
| from pysine import sine | |
| import numpy as np | |
| def genfreq(num): | |
| tone = [] | |
| lbfreq = [126, 135, 144, 153, 162, 171, 180, | |
| 189, 198, 207, 216, 225, 234, 243] | |
| lbfreq = np.array(lbfreq) | |
| for i in range(0, num): | |
| val = lbfreq * (2**i) | |
| tone.append(val) | |
| return np.array(tone).T | |
| def getfreq(num=5): | |
| freq = { | |
| 'C' : "", 'C#' : None, | |
| 'D' : "", 'D#' : None, | |
| 'E' : "", | |
| 'F' : "", 'F#' : None, | |
| 'G' : "", 'G#' : None, | |
| 'Ab' : "", 'A' : "", | |
| 'A#' : "", | |
| 'B' : "", 'B#' : None, | |
| } | |
| lname = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', | |
| 'G', 'G#', 'Ab', 'A', 'A#' ,'B', 'B#'] | |
| idx = 0 | |
| fgen = genfreq(num) | |
| for fn in lname: | |
| freq[fn] = fgen[idx] | |
| idx = idx + 1 | |
| return freq | |
| def play_major(octave=0): | |
| lname = ["C","D","E","F","G","A","B"] | |
| freq = getfreq() | |
| for ln in lname: | |
| ff = freq[ln][octave] | |
| sine(frequency=ff, duration=2.0) | |
| play_major() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment