kord
A music theory binary and library for Rust / JS (via WASM) (capability playground).
Binary Usage
Install
Windows:
$ iwr https://github.com/twitchax/kord/releases/latest/download/kord_x86_64-pc-windows-gnu.zip
$ Expand-Archive kord_x86_64-pc-windows-gnu.zip -DestinationPath C:\Users\%USERNAME%\AppData\Local\Programs\kord
Mac OS (Apple Silicon):
Linux:
Cargo:
NPM:
Wasmer
This has a reduced capability set (no audio input / output), but works well for some of the core use cases.
Alternatively, you can use wasmer run.
Help Docs
)
)
Describe A Chord
Play A Chord
)()
Loop Through Chord Changes
Guess A Chord
)
)()
)()
)()
)()
Guess Notes / Chord From Audio
Using the deterministic algorithm only:
Using the ML algorithm:
Library Usage
Add this to your Cargo.toml:
[]
= "*" #choose a version
Examples
use KnownChord;
use Degree;
use *;
use *;
// Check to see what _kind_ of chord this is.
assert_eq!;
use crateParsable;
use *;
use *;
// Parse a chord from a string, and inspect the scale.
assert_eq!;
use *;
use *;
// From a note, create a chord, and look at the chord tones.
assert_eq!;
JS Usage
The npm package is available here.
First, load the module as you would any other ES module.
import init from 'kordweb/klib.js';
// Run `init` once.
await ;
Then, you can use the library similarly as you would in Rust.
// Create a note.
const note = ;
note.; // C4
note.; // 4
// Create a chord.
const chord = ;
chord.; // C7(♯9)
chord.; // C4 E4 G4 Bb5 D#5
// Easy chaining.
...; // [ 'C2', 'D♭2', 'E2', 'G2', 'B♭2' ]
// Build chords.
....; // [ 'C4', 'Eb4', 'G4', 'Bb4' ]
Feature Flags
The library and binary both support various feature flags. Of most important note are:
default = ["cli", "analyze", "audio"]cli: enables the CLI features, and can be removed if only compiling the library.analyze = ["analyze_mic", "analyze_file"]: enables theanalyzesubcommand, which allows for analyzing audio data (and the underlying library features).analyze_mic: enables theanalyze micsubcommand, which allows for analyzing audio from a microphone (and the underlying library features).analyze_file: enables theanalyze filesubcommand, which allows for analyzing audio from a file (and the underlying library features).analyze_file_mp3: enables the features to analyze mp3 files.analyze_file_aac: enables the features to analyze aac files.analyze_file_alac: enables the features to analyze alac files.
ml = ["ml_train", "ml_infer"]: enables themlsubcommand, which allows for training and inferring with ML (and the underlying library features).ml_train: enables theml trainsubcommand, which allows for training ML models (and the underlying library features).ml_infer: enables theml infersubcommand, which allows for inferring with ML models (and the underlying library features).-
NOTE: Adding the
analyze_micfeature flag will enable theml infer micsubcommand, which allows for inferring with ML models from a microphone. -
NOTE: Adding the
analyze_filefeature flag will enable theml infer filesubcommand, which allows for inferring with ML models from a file.
-
ml_gpu: enables the features to use a GPU for ML training.
wasm: enables the features to compile to wasm.plot: enables the features to plot data.
Test
License
MIT