Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
tonal-range
Advanced tools
tonal-range
is a collection of functions to create note ranges.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-range
Array
Create a numeric range. As parameters, it accepts numbers or note names. It can create ascending or descending ranges.
String
Given a collection of pitch classes and a midi number, return the note name from the collection or null if not in the collection.
This function can be partially applied.
Array
Create a note range using a function that convert from midi number to note names
Can be partially applied
Array
Create a range of chromatic notes. The altered notes will use flats.
Array
Create a range with a cycle of fifths
Array
Create a scale range. Given a pitch set (a collection of pitch classes), and a start and end it returns a note range.
Array
Create a numeric range. As parameters, it accepts numbers or note names. It can create ascending or descending ranges.
Kind: global function
Returns: Array
- an array of numbers or empty array if not valid parameters
Param | Type | Description |
---|---|---|
begin | Pitch | String | Number | the beginning note or number |
end | Pitch | String | Number | the end note or number |
Example
import { range } from 'tonal-range'
range('C5', 'C4') // => [ 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60 ]
range(10, 5) // => [ 10, 9, 8, 7, 6, 5 ]
// or use tonal
tonal.range('C2', 'C3')
String
Given a collection of pitch classes and a midi number, return the note name from the collection or null if not in the collection.
This function can be partially applied.
Kind: global function
Returns: String
- the note name or null if note in the pitch classes
Param | Type | Description |
---|---|---|
coll | Array | the pitch classes collection |
midi | Number | the midi number |
Example
var fromPitchSet = require('note-ranges').fromPitchSet
fromPitchSet('C D E', 60) // => 'C4'
aMajor = fromPitchSet('A C# E')
[69, 70, 71, 72, 73].map(aMajor) // => [ 'A4', null, null, null, 'C#5' ]
Array
Create a note range using a function that convert from midi number to note names
Can be partially applied
Kind: global function
Returns: Array
- an array of note names
Param | Type | Description |
---|---|---|
gen | function | the note name generator. Its a function with signature (Number) => (String) that receives a note midi number and returns a note name |
start | String | Pitch | Integer | the first note (or midi number) of the range |
end | String | Pitch | Integer | the last note (or midi number) of the range |
Array
Create a range of chromatic notes. The altered notes will use flats.
Kind: global function
Returns: Array
- an array of note names
Param | Type | Description |
---|---|---|
start | String | Pitch | Integer | the first note (or midi number) of the range |
end | String | Pitch | Integer | the last note (or midi number) of the range |
Example
tonal.chromatic('C2', 'E2') // => ['C2', 'Db2', 'D2', 'Eb2', 'E2']
Array
Create a range with a cycle of fifths
Kind: global function
Returns: Array
- a range of cycle of fifths
Param | Type | Description |
---|---|---|
the | Integer | first step from tonic |
the | Integer | last step from tonic (can be negative) |
the | String | Pitch | tonic |
Example
var range = require('tonal-ranges')
range.cycleOfFifths(0, 6, 'C') // => [ 'C', 'G', 'D', 'A', 'E', 'B', 'F#' ])
Array
Create a scale range. Given a pitch set (a collection of pitch classes), and a start and end it returns a note range.
Kind: global function
Returns: Array
- the scale range, an empty array if not valid source or
null if not valid start or end
Param | Type | Description |
---|---|---|
notes | String | Array | the collection of pitch sets |
start | String | the first note of the range |
end | String | the last note of the range |
Example
var range = require('tonal-ranges')
range.scale('C D E F G A B', 'C3', 'C2')
// => [ 'C3', 'B2', 'A2', 'G2', 'F2', 'E2', 'D2', 'C2' ]
FAQs
Create ranges of notes
The npm package tonal-range receives a total of 18 weekly downloads. As such, tonal-range popularity was classified as not popular.
We found that tonal-range demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.