Created
February 23, 2021 14:17
-
-
Save nucliweb/97e2a536b951bc7acba50aebac40ffb6 to your computer and use it in GitHub Desktop.
FromMiditoHue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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