https://github.com/danigb/pitch-fifths
Pitches and intervals expressed in fifths
https://github.com/danigb/pitch-fifths
Last synced: 11 months ago
JSON representation
Pitches and intervals expressed in fifths
- Host: GitHub
- URL: https://github.com/danigb/pitch-fifths
- Owner: danigb
- License: mit
- Created: 2015-10-12T19:15:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-12T20:23:35.000Z (over 10 years ago)
- Last Synced: 2025-06-12T21:54:45.858Z (about 1 year ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# pitch-fifths
Pitches and intervals expressed in fifths and octaves:
```js
var fifths = require('pitch-fifths')
fifths([1, 0, 0]) // => [2, -1]
fifths.toPitch([2, -1]) // => [1, 0, 0]
```
This library converts from [a-pitch](https://github.com/danigb/a-pitch) arrays to a `[fifths, octaves]` array. This representation of pitches (or intervals) are useful to do [interval arithmetic](https://github.com/danigb/pitch-op).
This is a low level library. Probably you want to use [tonal](https://github.com/danigb/tonal)
## API
-
fifths(apitch) → {Array}
-
Get a pitch or interval measured in fifths and octaves
Every interval (or pitch) can be expressed by repeating ascending or descending
fifths and octaves. For exaple, interval major second is two fifths up and
one octave down:
fifths([1, 0, 0]) // => [2, -1]
This representation is useful for calculating interval distances, transpositions
or keys
Parameters:
Name
Type
Description
apitch
Array
the pitch or interval as a-pitch
Returns:
an array with the form [fifths, octaves] where both are integers
-
Type
-
Array
Example
var fifths = require('pitch-fifths')
fifths([0, 0, 0]) // => [0, 0]
fifths([0, 0, 1]) // => [0, 1]
fifths([1, 0, 0]) // => [2, -1]
-
toPitch(coord) → {Array}
-
Parameters:
Name
Type
Description
coord
Array
the fifths array
Returns:
the a-pitch structure
-
Type
-
Array
Example
var fifths = require('pitch-fifths')
fifths.toPitch([3, -1]) // => [6, 0, 1]
*generated with [docme](https://github.com/thlorenz/docme)*
## License
MIT License