Skip to content

Instantly share code, notes, and snippets.

@victormurcia
Created September 3, 2022 01:46
Show Gist options
  • Save victormurcia/e37cd36a8b4cb1b7762373d3f38ca881 to your computer and use it in GitHub Desktop.
Save victormurcia/e37cd36a8b4cb1b7762373d3f38ca881 to your computer and use it in GitHub Desktop.
Hue to Frequency Converter
#Define frequencies that make up A-Harmonic Minor Scale
scale_freqs = [220.00, 246.94 ,261.63, 293.66, 329.63, 349.23, 415.30]
def hue2freq(h,scale_freqs):
thresholds = [26 , 52 , 78 , 104, 128 , 154 , 180]
note = scale_freqs[0]
if (h <= thresholds[0]):
note = scale_freqs[0]
elif (h > thresholds[0]) & (h <= thresholds[1]):
note = scale_freqs[1]
elif (h > thresholds[1]) & (h <= thresholds[2]):
note = scale_freqs[2]
elif (h > thresholds[2]) & (h <= thresholds[3]):
note = scale_freqs[3]
elif (h > thresholds[3]) & (h <= thresholds[4]):
note = scale_freqs[4]
elif (h > thresholds[4]) & (h <= thresholds[5]):
note = scale_freqs[5]
elif (h > thresholds[5]) & (h <= thresholds[6]):
note = scale_freqs[6]
else:
note = scale_freqs[0]
return note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment