Skip to content

Instantly share code, notes, and snippets.

@nucliweb
Created February 23, 2021 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucliweb/97e2a536b951bc7acba50aebac40ffb6 to your computer and use it in GitHub Desktop.
Save nucliweb/97e2a536b951bc7acba50aebac40ffb6 to your computer and use it in GitHub Desktop.
FromMiditoHue
const hueRange = {
min: 0,
max: 360
}
const midiRange = {
min: 36,
max: 96
}
const fromMidiToHue = (value) => {
const midiTotalValues = midiRange.max - midiRange.min
const multiplier = hueRange.max / midiTotalValues
const midiKeyNumber = value - midiRange.min
return multiplier * midiKeyNumber
}
const pressedKeyValue = 36
const result = fromMidiToHue(pressedKeyValue)
console.log(result) // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment