harmony-ts
TypeScript icon, indicating that this package has built-in type declarations

0.14.4 • Public • Published

harmony-ts

Documentation Github CI npm version GitHub Last Commit Typescript

This project is an engine for generating and analyzing four-part textures (and eventually other forms) in the style of Bach and the classical era. Currently, it allows one to pass a series of constraints, such as chord/type/inversion and voice parts, and it will produce the complete texture using the settings provided. It also gives many useful basic music theory functions like intervals and chords.

Getting Started

Installing

npm install harmony-ts

Using the Library

To use the harmonizer, first set up the constraints you wish to use. This might consist of particular notes or a roman numeral in a scale. The incomplete chord struct is meant to represent a vertical slice and single chord that is to be harmonized.

const sopranoNotes = ['E5', 'E5', 'D5', 'D5', 'C5', 'C5', 'B4', 'C5'];
const constraints = sopranoNotes.map(soprano => new IncompleteChord({voices: [soprano, undefined, undefined, undefined]}));

Then initialize the part-writer with your choice of parameters (see documentation for options)

const partWriter = new PartWriter();

Then select the scale to harmonize within and pass the constraints to the part-writer.

const scale = Scale.Major.notes;
const results = flattenResults(partWriter.voiceAll(constraints, scale));
const bestResult = results.next().value;

It is also possible to just generate the chords that could go with a melody or bass-line, or perform voice-leading checks on a provided set of chords.

Demo

Part Writing Demo

Code Examples

Library Demo Source

Unit Tests

Package Import Tests

Documentation

Typedoc

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

Readme

Keywords

none

Package Sidebar

Install

npm i harmony-ts

Weekly Downloads

0

Version

0.14.4

License

Apache-2.0

Unpacked Size

432 kB

Total Files

150

Last publish

Collaborators

  • johnameyer