increase pitch range, allow "comments" in csv
This commit is contained in:
parent
b172dacd6f
commit
1a1718973b
|
|
@ -16,7 +16,7 @@ parser.add_argument("--bpm", default=60, type=float, help="beats per minute")
|
|||
args = parser.parse_args()
|
||||
|
||||
# starting from C3 = 130.81 Hz
|
||||
frequencies = [2 ** (i / 12) * 130.81 for i in range(24)]
|
||||
frequencies = [2 ** (i / 12) * 130.81 for i in range(36)]
|
||||
# duration of 1/16th beat
|
||||
base_duration = 60 / args.bpm / 16
|
||||
|
||||
|
|
@ -30,9 +30,12 @@ with open(args.output, "w") as f:
|
|||
for filename in args.input:
|
||||
with open(filename, "r") as notes:
|
||||
for pitch, duration, pause in csv.reader(notes):
|
||||
if pitch == "":
|
||||
# skip comment
|
||||
continue
|
||||
pitch = int(pitch)
|
||||
if pitch < -12 or pitch > 11:
|
||||
sys.exit("pitch goes from -12 == C3 to 11 == B4")
|
||||
if pitch + 12 < 0 or pitch + 12 > len(frequencies) - 1:
|
||||
sys.exit(f"pitch goes from -12 to {len(frequencies) - 1 - 12}")
|
||||
duration = int(duration)
|
||||
pause = int(pause)
|
||||
if duration < 1 or pause < 0:
|
||||
|
|
|
|||
Loading…
Reference in a new issue