https://github.com/danigb/music.note.transpose
Note transposition fast and easy
https://github.com/danigb/music.note.transpose
Last synced: 7 months ago
JSON representation
Note transposition fast and easy
- Host: GitHub
- URL: https://github.com/danigb/music.note.transpose
- Owner: danigb
- License: mit
- Created: 2015-10-25T14:54:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-28T10:24:28.000Z (over 10 years ago)
- Last Synced: 2024-12-27T11:34:50.684Z (over 1 year ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# music.note.transpose
[](https://travis-ci.org/danigb/music.note.transpose)
[](https://codeclimate.com/github/danigb/music.note.transpose/coverage)
[](https://codeclimate.com/github/danigb/music.note.transpose)
[](https://github.com/feross/standard)
[](https://www.npmjs.com/package/music.note.transpose)
[](https://www.npmjs.com/package/music.note.transpose)
[](https://www.npmjs.com/package/music.kit)
Simple and fast pitch transposition:
```js
var transpose = require('music.note.transpose')
transpose('E2', '2M') // => 'F#2'
transpose('F4', '3m') // => 'Ab4'
```
This is part of [music.kit](https://www.npmjs.com/package/music.kit)
## Installation
Via npm module: `npm i --save music.note.transpose` or the [browser ready distribution file]()
## Usage
#### Note transposition
The simplest usage is with a note name (pitch) and interval (the order doesn't matter):
```js
transpose('C2', '4A') // => 'F#2'
transpose('4A', 'C2') // => 'F#2'
```
#### Pitch class transposition
You can transpose pitch classes (note names without octaves), and the returned value will be a pitch class:
```js
tranpose('A', '3M') // => 'C#'
tranpose('A5', '3M') // => 'C#5'
```
#### Add intervals
If you need it you can transpose an interval:
```js
transpose('3M', '3M') // => '5A'
```
#### Transposers
Also, you can partially apply the function to get a transposer:
```js
var major3th = transpose('3M')
major3th('D') // => 'F#'
```
#### Map arrays
Partially applied transposers allows to work with arrays seamlessly:
```
['C', 'D', 'E', 'F', 'G'].map(transpose('3M')) // => ['E', 'F#', 'G#', 'A', 'B']
['1P', '3m', '5P'].map(transpose('C')) // => ['C', 'Eb', 'G']
```
#### Using different interval or pitch representations
This library can work with [pitches or intervals expressed as arrays](https://github.com/danigb/a-pitch):
```js
transpose([0, 1, 3], [2, 0, 0]) // => [3, 1, 3]
// is the same as: transpose('C#3', '3M') => 'E#3'
```
#### More...
See [music.kit](https://www.npmjs.com/package/music.kit)
## License
MIT License