@temper.sh/pitch
Version:
Utilities for working with pitch in arbitrary equal temperament spaces
65 lines (62 loc) • 1.37 kB
text/typescript
import { describe, expect, it, suite } from 'vitest'
import { pitchClass } from './pitchClass'
suite.concurrent('pitchClass', () => {
describe('integers', () => {
const expectations: Array<[number, number]> = [
[-12, 0],
[-11, 1],
[-10, 2],
[-9, 3],
[-8, 4],
[-7, 5],
[-6, 6],
[-5, 7],
[-4, 8],
[-3, 9],
[-2, 10],
[-1, 11],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
]
for (const [pitch, expectedPitchClass] of expectations) {
it(`should return ${expectedPitchClass} for pitch ${pitch}`, () => {
expect(pitchClass(pitch)).toBe(expectedPitchClass)
})
}
})
describe('floats', () => {
const expectations: Array<[number, number]> = [
[-6.75, 5.25],
[-0.5, 11.5],
[],
[],
]
for (const [pitch, expectedPitchClass] of expectations) {
it(`should return ${expectedPitchClass} for pitch ${pitch}`, () => {
expect(pitchClass(pitch)).toBe(expectedPitchClass)
})
}
})
})