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.
 
 
 
 

12 line
301 B

  1. interface GetOctaveCount {
  2. (startKey: number, endKey: number): number,
  3. }
  4. const getOctaveCount: GetOctaveCount = (startKey, endKey) => {
  5. const startOctave = Math.floor(startKey / 12)
  6. const endOctave = Math.floor(endKey / 12)
  7. return endOctave - startOctave + 1
  8. }
  9. export default getOctaveCount