Tonic

2.0.0

Swift library for music theory
AudioKit/Tonic

What's New

V2.0 - Massive Chord Library Updates

2024-12-18T21:34:29Z

Also includes a change- we are standardizing on the Yamaha version of middle C as C3 and octave numbering -2 to 7, so there may be breaking changes, but this should be an overall upgrade to 1.4.

Tonic

Demo

Swift library for music theory, currently focused on chords/harmony.

Tonic answers musical questions, such as:

  • What's the note for this pitch in this key?

    Note(pitch: Pitch(midiNoteNumber), key: .Bb)

  • What's the name of a chord?

    Chord(notes: notes).description

  • What chords are in this key?

    Key.Cm.chords

  • What chords in this key contain this note?

    Key.C.chords.filter { $0.noteClasses.contains(.C) }

  • What notes do these keys have in common?

    Key.C.noteSet.intersection(Key.Cm.noteSet)

  • What notes don't these keys have in common?

    Key.C.noteSet.symmetricDifference(Key.Cm.noteSet)

These questions are all tested in our unit tests explicitly.

Goals

  • Correctness. Try to be as correct with respect to music theory as possible.
  • Strong typing. Use types to prevent errors (e.g. Pitch instead of UInt8).
  • Good performance. Tonic uses bit sets to represent pitch sets and note sets.

Documentation

The documentation is host on the AudioKit.io Website. The package includes a demo project as well.

Install

Install using Swift Package Manager.

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri May 30 2025 11:38:39 GMT-0900 (Hawaii-Aleutian Daylight Time)