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.

26 lines
729 B

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'