UNPKG
@temper.sh/pitch
Version:
latest (1.0.2)
1.0.2
1.0.1
Utilities for working with pitch in arbitrary equal temperament spaces
@temper.sh/pitch
/
src
/
invert
/
invert.ts
9 lines
(7 loc)
•
289 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
import
{ intervals }
from
'@/intervals'
import
type
{
Chord
}
from
'@/types'
import
{ accumulate }
from
'@/utils/accumulate'
export
const
invert = (
chord
:
Chord
):
Chord
=>
{
const
deltas =
accumulate
(
intervals
(chord))
return
[chord[
0
]!, ...deltas.
map
(
(
delta
) =>
chord[
0
]! - delta)] }