harmony-ts
v0.14.5
Published
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
Downloads
21
Readme
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
Code Examples
Documentation
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- John Meyer - Initial work - johnameyer
See also the list of contributors who participated in this project.