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

  1. from load_asset import load
  2. from math import log
  3. import convert_to
  4. device = load('device')
  5. #cents between notes
  6. def cents(f1,f2):
  7. return 1200*log(f1/f2,2)
  8. #fingering based off of valves or slide
  9. def fingering(note,dev,_a = 440):
  10. dev = device['devices'][dev]
  11. fund = convert_to.frequency(convert_to.above_c(dev['fund']))
  12. sys = device[dev['sys']]
  13. f_note = convert_to.frequency(convert_to.above_c(note),a =_a)
  14. n = int(f_note/fund)
  15. t = abs(cents(f_note,n*fund))
  16. if t >= 31:
  17. n += 1
  18. if n == 7:
  19. n += 1
  20. try:
  21. return sys[round(convert_to.frequency(n*fund,invert = True,a = _a)) - convert_to.above_c(note)]
  22. except IndexError:
  23. return 'Note too damn low'