Musical keyboard component written in React.
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.
 
 
 
 

11 line
387 B

  1. import getKeyXOffset from './getKeyXOffset'
  2. import isNaturalKey from './isNaturalKey'
  3. // expect firstKey and lastKey within the same octave
  4. export default (firstKey: number, lastKey: number) => (
  5. // see if there are missing higher notes
  6. getKeyXOffset(lastKey) + (isNaturalKey(lastKey) ? 1 / 7 : 1 / 7 * 18/36)
  7. // see if there are missing lower notes
  8. - getKeyXOffset(firstKey)
  9. )