Simple monitor for displaying MIDI status for digital pianos.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

22 lignes
551 B

  1. const NATURAL_KEYS = [0, 2, 4, 5, 7, 9, 11]
  2. interface IsNaturalKey {
  3. (k: number): boolean
  4. }
  5. const isNaturalKey: IsNaturalKey = (k: number): boolean => {
  6. const type = typeof (k as unknown)
  7. if ((type as string) !== 'number') {
  8. throw TypeError(`Invalid value type passed to isNaturalKey, expected 'number', got ${type}.`)
  9. }
  10. if (isNaN(k)) {
  11. throw RangeError('Value passed is NaN.')
  12. }
  13. if (k < 0) {
  14. throw RangeError('Value must be positive.')
  15. }
  16. return NATURAL_KEYS.includes(Math.floor(k) % 12)
  17. }
  18. export default isNaturalKey