def keynote_to_keyname(song): pitchhz, keynum = getfreq() o = [] for a, b in song: for x in keynum.keys(): if keynum[x] == a - 1: k = x o.append((k, b)) return o
# Dotted notes can be written in two ways: # 1.33 = -2 = dotted half # 2.66 = -4 = dotted quarter # 5.33 = -8 = dotted eighth """ import sys assert sys.version >= '3.3', "This program does not work with older versions of Python.\ Please install Python 3.3 or later." import random from math import exp from demosongs import * from mkfreq import getfreq pitchhz, keynum = getfreq(pr=True) ########################################################################## #### Main program starts below ########################################################################## # Some parameters: # Beats (quarters) per minute # e.g. bpm = 95 # Octave shift (neg. integer -> lower; pos. integer -> higher) # e.g. transpose = 0 # Pause between notes as a fraction (0. = legato and e.g., 0.5 = staccato) # e.g. pause = 0.05
# Finally the octave number (defaults to octave 4 if not given). # An asterisk at the end makes the note a little louder (useful for the beat). # 'r' is a rest. # Note value is a number: # 1=Whole Note; 2=Half Note; 4=Quarter Note, etc. # Dotted notes can be written in two ways: # 1.33 = -2 = dotted half # 2.66 = -4 = dotted quarter # 5.33 = -8 = dotted eighth """ from demosongs import * from mkfreq import getfreq pitchhz, keynum = getfreq(pr = True) ########################################################################## #### Main program starts below ########################################################################## # Some parameters: # Beats (quarters) per minute # e.g. bpm = 95 # Octave shift (neg. integer -> lower; pos. integer -> higher) # e.g. transpose = 0 # Pause between notes as a fraction (0. = legato and e.g., 0.5 = staccato) # e.g. pause = 0.05
# Note value is a number: # 1=Whole Note; 2=Half Note; 4=Quarter Note, etc. # Dotted notes can be written in two ways: # 1.33 = -2 = dotted half # 2.66 = -4 = dotted quarter # 5.33 = -8 = dotted eighth """ import wave, struct import numpy as np from math import sin, cos, pi, log, exp from mixfiles import mix_files from demosongs import * from mkfreq import getfreq pitchhz, keynum = getfreq() # Harmonic intensities (dB) for selected piano keys, # measured with output from a Yamaha P-85 harmo = ( (1, -15.8, -3., -15.3, -22.8, -40.7), (16, -15.8, -3., -15.3, -22.8, -40.7), (28, -5.7, -4.4, -17.7, -16., -38.7), (40, -6.8, -17.2, -22.4, -16.8, -75.6), (52, -8.4, -19.7, -23.5, -21.6, -76.8), (64, -9.3, -20.8, -37.2, -36.3, -76.4), (76, -18., -64.5, -74.4, -77.3, -80.8), (88, -24.8, -53.8, -77.2, -80.8, -90.), ) def linint(arr, x):
# Finally the octave number (defaults to octave 4 if not given). # An asterisk at the end makes the note a little louder (useful for the beat). # 'r' is a rest. # Note value is a number: # 1=Whole Note; 2=Half Note; 4=Quarter Note, etc. # Dotted notes can be written in two ways: # 1.33 = -2 = dotted half # 2.66 = -4 = dotted quarter # 5.33 = -8 = dotted eighth """ # from demosongs import * from mkfreq import getfreq pitchhz, keynum = getfreq(pr = False) ########################################################################## #### Main program starts below ########################################################################## # Some parameters: # Beats (quarters) per minute # e.g. bpm = 95 # Octave shift (neg. integer -> lower; pos. integer -> higher) # e.g. transpose = 0 # Pause between notes as a fraction (0. = legato and e.g., 0.5 = staccato) # e.g. pause = 0.05
# Note value is a number: # 1=Whole Note; 2=Half Note; 4=Quarter Note, etc. # Dotted notes can be written in two ways: # 1.33 = -2 = dotted half # 2.66 = -4 = dotted quarter # 5.33 = -8 = dotted eighth """ import wave, struct import numpy as np from math import sin, cos, pi, log, exp from mixfiles import mix_files from demosongs import * from mkfreq import getfreq pitchhz, keynum = getfreq() # Harmonic intensities (dB) for selected piano keys, # measured with output from a Yamaha P-85 harmo = ( (1, -15.8, -3., -15.3, -22.8, -40.7), (16, -15.8, -3., -15.3, -22.8, -40.7), (28, -5.7, -4.4, -17.7, -16., -38.7), (40, -6.8, -17.2, -22.4, -16.8, -75.6), (52, -8.4, -19.7, -23.5, -21.6, -76.8), (64, -9.3, -20.8, -37.2, -36.3, -76.4), (76, -18., -64.5, -74.4, -77.3, -80.8), (88, -24.8, -53.8, -77.2, -80.8, -90.), )