Skip to content

fferri/musictheory.lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

musictheory.lua

A Lua library for working with music theory concepts such as notes, intervals, chords, scales, etc.

Installing

Install via luarocks.

For development, you can install locally with e.g.:

luarocks --lua-version 5.4 make musictheory-*.rockspec

Example Usage

mt = require 'musictheory'

-- create a note:
c4 = mt.Note'C4'

-- add intervals:
c4 + mt.Interval'P5' == Note'G4'
c4 + mt.Interval'm3' == Note'E♭4'

-- work out intervals between notes:
mt.Note'B4' - c4 == mt.Interval'M7'

-- pitch class:
c4.pitch_class == mt.PitchClass'C'

-- chords:
Cm = mt.Chord('C', 'min')
Cm.pitches == {mt.PitchClass'C', mt.PitchClass'E♭', mt.PitchClass'G'}

-- inversions (a.k.a. slash chords):
Cm:invert(1) == mt.Chord'Cmin/E♭'
Cm:invert(1).bass == mt.PitchClass'E♭'
Cm:invert(1).root == mt.PitchClass'C'

There are more classes and methods. Have a look at the source code.

Contributing

musictheory.lua is open-source and contributions in the form of issues, documentation, pull requests, unit tests, etc are welcome.

License

See LICENSE

About

Music Theory library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages