Simple monitor for displaying MIDI status for digital pianos.
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.

getKeyName.ts 397 B

123456789101112131415
  1. import getKeyOctave from './getKeyOctave'
  2. import keyNames from './keyNames.json'
  3. interface GetKeyName {
  4. (key: number): string,
  5. }
  6. const getKeyName: GetKeyName = (key) => {
  7. const octave = getKeyOctave(key)
  8. const pitch = (Math.floor(key) % 12) as keyof typeof keyNames
  9. const keyName: string = keyNames[pitch] as unknown as string
  10. return `${keyName}${octave}`
  11. }
  12. export default getKeyName