You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
import convert_toimport load_assetfrom Fingering import fingeringscales = load_asset.load('scales')mod = False#scales[0] = ailias,scales[1] = scales
#adds scale with namedef add(ns,name): new = scale(ns).transpose('c').notes scales[1].append(new) scales[0][name] = len(scales[1])-1 load_asset.save(scales,'scales') #adds alternative name to scaledef alias(exist,con): scale[0][con] = scale[0][exist] load_asset.save(scales,'scales') #creates scale with specified starting note, type, and notationdef create(n,scale_type,notation = 'flats'): return scale( scales[1][ scales[0][scale_type.lower()] ] ).transpose(n,notation)
class scale: #converts scale notes to above c0, in effect giving raw intervals from the start note def normalize(self): #ensures that the start note is the same as the end note. This affects the data returned by the .notes method if convert_to.above_c(self.notes[0])%12 != convert_to.above_c(self.notes[-1])%12: self.notes.append(self.notes[0])
#subtracts starting note from each note start = convert_to.above_c(self.notes[0]) note_list = list( map( lambda n: convert_to.above_c(n)-start, self.notes ) ) #ensures scales are ascending for i in range(len(note_list)-1): while note_list[i] > note_list[i+1]: note_list[i+1] += 12 return note_list
#returns fingering with specified device def fingers(self,d,tuning_a = 440): return list( map(
lambda n: '{} ({})'.format(n,fingering(n,d,tuning_a)), self.notes ) ) #transposes scale to specified note def transpose(self,n,notation = 'flats'): n = convert_to.above_c(n) return scale( list( map( lambda m: convert_to.notename(m+n,notation), self.intv ) ) ) def __init__(self,notes): self.notes = notes self.intv = self.normalize()
|