diff --git a/Assets/device.txt b/Assets/device.txt deleted file mode 100644 index d4deb84..0000000 --- a/Assets/device.txt +++ /dev/null @@ -1,42 +0,0 @@ -{ - "devices": { - "baritone": { - "fund": "A#|1", - "sys": "valves" - }, - "french_horn": { - "fund": "F|1", - "sys": "valves" - }, - "trombone": { - "fund": "A#|1", - "sys": "slide" - }, - "trumpet": { - "fund": "A#|2", - "sys": "valves" - }, - "tuba": { - "fund": "A#|0", - "sys": "valves" - } - }, - "slide": [ - "1", - "2", - "3", - "4", - "5", - "6", - "7" - ], - "valves": [ - "0", - "2", - "1", - "1,2", - "2,3", - "1,3", - "1,2,3" - ] -} \ No newline at end of file diff --git a/Assets/notes.txt b/Assets/notes.txt deleted file mode 100644 index 0eca525..0000000 --- a/Assets/notes.txt +++ /dev/null @@ -1,30 +0,0 @@ -{ - "flats": [ - "C", - "D\u266d", - "D", - "E\u266d", - "E", - "F", - "G\u266d", - "G", - "A\u266d", - "A", - "B\u266d", - "B" - ], - "sharps": [ - "C", - "C#", - "D", - "D#", - "E", - "F", - "F#", - "G", - "G#", - "A", - "A#", - "B" - ] -} \ No newline at end of file diff --git a/Assets/scales.txt b/Assets/scales.txt deleted file mode 100644 index b1614a7..0000000 --- a/Assets/scales.txt +++ /dev/null @@ -1,104 +0,0 @@ -[ - { - "aeolian": 5, - "dominant": 4, - "dorian": 1, - "ionian": 0, - "locrian": 6, - "lydian": 3, - "major": 0, - "minor": 5, - "mixolydian": 4, - "pentatonic major": 8, - "pentatonic minor": 7, - "phrygian": 2 - }, - [ - [ - "C", - "D", - "E", - "F", - "G", - "A", - "B", - "C|1" - ], - [ - "C", - "D", - "E\u266d", - "F", - "G", - "A", - "B\u266d", - "C|1" - ], - [ - "C", - "D\u266d", - "E\u266d", - "F", - "G", - "A\u266d", - "B\u266d", - "C|1" - ], - [ - "C", - "D", - "E", - "G\u266d", - "G", - "A", - "B", - "C|1" - ], - [ - "C", - "D", - "E", - "F", - "G", - "A", - "B\u266d", - "C|1" - ], - [ - "C", - "D", - "E\u266d", - "F", - "G", - "A\u266d", - "B\u266d", - "C|1" - ], - [ - "C", - "D\u266d", - "E\u266d", - "F", - "G\u266d", - "A\u266d", - "B\u266d", - "C|1" - ], - [ - "C", - "E\u266d", - "F", - "G", - "B\u266d", - "C|1" - ], - [ - "C", - "E", - "F", - "G", - "B", - "C|1" - ] - ] -] \ No newline at end of file diff --git a/Fingering.py b/Fingering.py index eef6dc0..e69de29 100644 --- a/Fingering.py +++ b/Fingering.py @@ -1,26 +0,0 @@ -from load_asset import load -from math import log -import convert_to -device = load('device') -#cents between notes -def cents(f1,f2): - - return 1200*log(f1/f2,2) - -#fingering based off of valves or slide -def fingering(note,dev,_a = 440): - dev = device['devices'][dev] - fund = convert_to.frequency(convert_to.above_c(dev['fund'])) - sys = device[dev['sys']] - - f_note = convert_to.frequency(convert_to.above_c(note),a =_a) - n = int(f_note/fund) - t = abs(cents(f_note,n*fund)) - if t >= 31: - n += 1 - if n == 7: - n += 1 - try: - return sys[round(convert_to.frequency(n*fund,invert = True,a = _a)) - convert_to.above_c(note)] - except IndexError: - return 'Note too damn low' diff --git a/add_device.py b/add_device.py deleted file mode 100644 index dd23381..0000000 --- a/add_device.py +++ /dev/null @@ -1,17 +0,0 @@ - -from load_asset import save,load -device = load('device') - -def add_device(name,fund,sys): - device['devices'][name] = {} - device['devices'][name]['fund'] = fund.upper() - device['devices'][name]['sys'] = sys - return None -t = '' -while t != 'exit': - t = t.split(' ') - if len(t) == 3: - add_device(*t) - t = input('(name fund sys) (or exit):') - -save(device,'device') diff --git a/convert.py b/convert.py new file mode 100644 index 0000000..8f9be91 --- /dev/null +++ b/convert.py @@ -0,0 +1,2 @@ +def above_c(n): + return 'go fuck yourself' diff --git a/convert_to.py b/convert_to.py deleted file mode 100644 index 87dfdfd..0000000 --- a/convert_to.py +++ /dev/null @@ -1,39 +0,0 @@ -from load_asset import load -from math import log -notes = load('notes') - -#converts from above c0 to frequency in hertz or the inverse -def frequency(n,a = 440,invert = False): - c = a/(2**(57/12)) - if not invert: - return (2**(n/12))*c - else: - return 12 * log(n/c,2) - -#swaps from nn to above c or inverse -##def swap(n,notation): - -def notename(n,notation): - note = n%12 - octave = n//12 - if octave > 0: - return '{}|{}'.format(notes[notation][note],octave) - else: - return notes[notation][note] - - -def above_c(n): - n = n.upper().split('|') - if len(n) == 2: - octave = 12*int(n[1]) - else: - octave = 0 - note = n[0] - notation = 'sharps' if note[-1] == '#' else 'flats' - for i in range(12): - if notes[notation][i] == note: - return octave + i -## if n is int: -## return notename(n,notation): -## else: - diff --git a/load_asset.py b/load_asset.py deleted file mode 100644 index 09219fe..0000000 --- a/load_asset.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -import json -def load(asset): - direct = os.getcwd() - path = '{}{sep}Assets{sep}{}'.format(direct,asset + '.txt',**{'sep':os.sep}) - return json.loads(open(path,'r').read()) -def save(asset,asset_name): - direct = os.getcwd() - path = '{}{sep}Assets{sep}{}'.format(direct,asset_name + '.txt',**{'sep':os.sep}) - file = open(path,'w') - file.write(json.dumps(asset, sort_keys=True,indent=4, separators=(',', ': '))) - print('Saved as: {}'.format(asset_name)) - return diff --git a/main.py b/main.py index d68c86d..e69de29 100644 --- a/main.py +++ b/main.py @@ -1,75 +0,0 @@ -import convert_to -import load_asset -from Fingering import fingering -scales = load_asset.load('scales') -mod = False -#scales[0] = ailias,scales[1] = scales - -#adds scale with name -def 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 scale -def alias(exist,con): - scale[0][con] = scale[0][exist] - load_asset.save(scales,'scales') - -#creates scale with specified starting note, type, and notation -def 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() diff --git a/scale.py b/scale.py new file mode 100644 index 0000000..37f2d9a --- /dev/null +++ b/scale.py @@ -0,0 +1,30 @@ +from load_asset import load +scales = load('scales') +note_names = load('notes') +##def create(scale_type,root): +## +import convert +class scale: + + def __init__(self,*notes): + self.notes = scale.number(notes) + self.raw_intv = self.ri() + self.root = self.notes[0] + + #takes notes from notes to numbers + def number(notes): + print('ran') + return list(map(convert.above_c,notes)) + + #finds raw intervals + def ri(self): + notes = self.notes + return list(map(lambda x: x-notes[0],notes[1:])) + + #returns new scale with given root + def tanspose(self,n): + if type(n) != int: + n = above_c(n) + return scale(*list(map(lambda x: x+n,self.raw_intv))) + + #todo fingers method diff --git a/temp.py b/temp.py deleted file mode 100644 index b6d6e85..0000000 --- a/temp.py +++ /dev/null @@ -1,8 +0,0 @@ -from load_asset import save,load -valves = load('valves') -slide = load('slide') -device = {} -device['valves'] = valves -device['slide'] = slide -device['devices'] = {} -save(device,'device')