note-parser

WebJar for note-parser

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

note-parser
Последняя версия

Последняя версия

2.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

note-parser
WebJar for note-parser
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/danigb/note-parser

Скачать note-parser

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/note-parser/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>note-parser</artifactId>
    <version>2.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/note-parser/
implementation 'org.webjars.npm:note-parser:2.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/note-parser/
implementation ("org.webjars.npm:note-parser:2.0.1")
'org.webjars.npm:note-parser:jar:2.0.1'
<dependency org="org.webjars.npm" name="note-parser" rev="2.0.1">
  <artifact name="note-parser" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='note-parser', version='2.0.1')
)
libraryDependencies += "org.webjars.npm" % "note-parser" % "2.0.1"
[org.webjars.npm/note-parser "2.0.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

note-parser npm

Build Status Code Climate js-standard-style

Parse note names (in scientific notation) with javascript. Given a string, obtain a hash with note properties (including midi number and frequency)

If you need parse interval names take a look to interval-notation

Usage

Install via npm: npm i --save note-parser and require it:

var parser = require('note-parser')
parser.parse('c#4') // => { letter: 'C', acc: '#', ... midi: 61, freq: 277.1826309768721 }

The returned object will contain:

  • letter: the uppercase letter of the note
  • acc: the accidentals of the note (only sharps or flats)
  • pc: the pitch class (letter + acc)
  • step: s a numeric representation of the letter. It's an integer from 0 to 6 where 0 = C, 1 = D ... 6 = B
  • alt: a numeric representation of the accidentals. 0 means no alteration, positive numbers are for sharps and negative for flats
  • chroma: a numeric representation of the pitch class. It's like midi for pitch classes. 0 = C, 1 = C#, 2 = D ... It can have negative values: -1 = Cb.

If the note name has octave, the returned object will additionally have:

  • oct: the octave number (as integer)
  • midi: the midi number
  • freq: the frequency (using tuning parameter as base)

If the parameter isTonic is set to true another property is included:

  • tonicOf: the rest of the string that follows note name (left and right trimmed)

Midi note number and frequency

If you are interested only in midi numbers or frequencies, you can use midi function:

parser.midi('A4') // => 69
parser.midi('blah') // => null
parser.midi(60) // => 60
parser.midi('60') // => 60

or the freq function:

parser.freq('A4') // => 440
parser.freq('A3', 444) // => 222
parser.freq(69) // => 440

Build the string back

With the build function you can convert back to string:

parser.build(parser.parse('cb2')) // => 'Cb2'

Alternatively the build function accepts step, alteration, octave parameters:

parser.build(3, -2, 4) // => 'Fbb4'

## Tests and documentation

You can read the generated API documentation here

To run the test clone this repo and:

npm install
npm test

License

MIT License

Версии библиотеки

Версия
2.0.1