Swiftpack.co - sh3l6orrr/swift-music as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by sh3l6orrr.
sh3l6orrr/swift-music 2.0.0
A swift package that provides an easy-to-use API for music related developments.
⭐️ 4
🕓 32 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/sh3l6orrr/swift-music.git", from: "2.0.0")

🎼 swift-music

CI Chords DocMusicTheory


swift-music is a swift package that provides an easy-to-use API for music related developments.

Currently available module:

  • MusicTheory: Notes, chords, scales.


import MusicTheory

Interval Arithmetic

Note.D - Note.E  // Interval.m7

Create a Chord

// Create with notes contained.
let Esus4 = Chord(.E, notes: [.E, .A, .B]) 

// Create with root and quality.
let Abm = Chord(.A_flat, .minorTriad)

// Create with name need to be marked with the try! keyword.
let A7 = try! Chord("A7") 

Get summary of a chord

// This is a chord named A7, with root note A, and component notes C#, E, G, which are 
// respectively major third, perfect fifth, minor seventh above the root. 

Is this chord in my scale?

try! Chord("Dbm").isIn(scale: .init(.B, .major)) // true

Get triad in a scale

Scale(.B, .major).triad(degree: 6) // G#m

Other API

  • Consonance and dissonance of interval, notes, or chord
  • Checking if a note in a chord
  • Create chord with both sharps and flats
  • Create slash chords
  • Support for 20+ chord qualities
  • Support for both major and minor mode


Xcode Project

File - Add Packages - https://github.com/sh3l6orrr/swift-music.git

Swift Package Manager

Inside Package.swift, add the followings:

dependencies: [
    .package(url: "https://github.com/sh3l6orrr/swift-music.git", .upToNextMajor(from: "1.0.0"))
targets: [
        name: "YourTarget",
        dependencies: [.product(name: "MusicTheory", package: "swift-music")]


Click on the badge in the front of this README, or build in Xcode:

Product - Build Documentation


Stars: 4
Last commit: 29 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Related Packages

Release Notes

32 weeks ago

Contains API changes to initializer of chord.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics