{"id":14006729,"url":"https://github.com/dn-m/Music","last_synced_at":"2025-07-24T00:31:55.948Z","repository":{"id":63920296,"uuid":"99036807","full_name":"dn-m/Music","owner":"dn-m","description":"Structures for the creation, analysis, and performance of music in Swift","archived":false,"fork":false,"pushed_at":"2019-09-13T21:27:30.000Z","size":937,"stargazers_count":16,"open_issues_count":13,"forks_count":5,"subscribers_count":3,"default_branch":"latest","last_synced_at":"2025-07-17T17:30:27.636Z","etag":null,"topics":["music","music-analysis","music-composition","music-theory","type-safe"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dn-m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-01T19:39:58.000Z","updated_at":"2025-06-03T20:38:52.000Z","dependencies_parsed_at":"2023-01-14T14:00:21.618Z","dependency_job_id":null,"html_url":"https://github.com/dn-m/Music","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/dn-m/Music","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dn-m%2FMusic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dn-m%2FMusic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dn-m%2FMusic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dn-m%2FMusic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dn-m","download_url":"https://codeload.github.com/dn-m/Music/tar.gz/refs/heads/latest","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dn-m%2FMusic/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266774744,"owners_count":23982246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["music","music-analysis","music-composition","music-theory","type-safe"],"created_at":"2024-08-10T10:01:36.421Z","updated_at":"2025-07-24T00:31:55.439Z","avatar_url":"https://github.com/dn-m.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Music\n\n![Swift Version](https://img.shields.io/badge/Swift-5.x-orange.svg)\n![Platforms](https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20iOS%20%7C%20watchOS%20%7C%20tvOS-lightgrey.svg)\n[![Build Status](https://travis-ci.org/dn-m/Music.svg?branch=latest)](https://travis-ci.org/dn-m/Music)\n\nStructures for the creation, analysis, and performance of music in Swift. Check out the [documentation](https://dn-m.github.io/Packages/Music).\n\n## Overview\n\n`Music` is a package for anyone who wants to create, analyze, and perform music in pure Swift.\n\n## Usage\n\n### 🎶 Pitch\n\nThe [`Pitch`](https://github.com/dn-m/Music/tree/latest/Sources/Pitch) module provides types for structuring and transforming the frequency domain.\n\n#### Basic Types\n\n```swift\nlet a440: Frequency = 440    // Hz\nlet middleC: Pitch = 60      // MIDI note number\nlet e = middleC + 4          // e above middle c\nlet microtone = e - 0.25     // eighth-tone below the e above middle c\nlet anyE = Pitch.Class(e)    // pitch class 4\nlet anyGSharp = anyE.inverse // pitch class 8\n```\n\n#### Set Operations\n\n```swift\nlet set: Pitch.Class.Collection = [8,0,4,6]\nset.normalForm // =\u003e [4,6,8,0]\nset.primeForm  // =\u003e [0,2,4,8]\n```\n\n#### Row Transformations\n```swift\nlet pcs: Pitch.Class.Collection = [0,11,3,4,8,7,9,5,6,1,2,10]\npcs.retrograde // =\u003e [10,2,1,6,5,9,7,8,4,3,11,0]\npcs.inversion  // =\u003e [0,1,9,8,4,5,3,7,6,11,10,2]\n```\n\n#### Diatonic Intervals\n\n```swift\nlet majorThird: DiatonicInterval = .M3\nlet minorSixth = majorThird.inverse\nlet AAA3 = DiatonicInterval(.triple, .augmented, .third)\nlet noSuchThing = DiatonicInterval(.major, .fifth) ❌ will not compile!\n```\n\n---\n\n### ♬ Duration\n\nThe [`Duration`](https://github.com/dn-m/Music/tree/latest/Sources/Duration) module provides types for structuring and transforming the time domain.\n\n#### Basic Types\n\n```swift\nlet crotchet = Duration(1,4)\nlet waltz = Meter(3,4)\nlet stayinAlive = Tempo(100, subdivision: 4)\n```\n\n---\n\n### 🎚️ Dynamics\n\nThe `Dynamic` module provides ways to describe musical loudness in a highly subjective way.\n\n```Swift\nlet loud: Dynamic = .ff\nlet quiet: Dynamic = .p\nlet interp = Dynamic.Interpolation(from: .p, to: .ff)\n```\n\n---\n\n### 🥁 Articulations\n\nThe `Articulation` type provides an interface to describe the way in which a given musical entity is performed.\n\n```Swift\nlet short: Articulation = .staccato\nlet sweet: Articulation = .tenuto\nlet hard: Articulation = .marcato\nlet hereIAm: Articulation = .accent\n```\n\n---\n\n### 💾 MusicModel\n\nThe `Model` brings all of elements together from the modules contained in this package.\n\n```Swift\nlet builder = Model.Builder()\nlet performer = Performer(name: \"Pat\")\nlet instrument = Instrument(name: \"Euphonium\")\nlet voiceID = builder.createVoice(performer: performer, instrument: instrument)\nlet pitch: Pitch = 60\nlet articulation: Articulation = .tenuto\nlet dynamic: Dynamic = .fff\nlet note = Rhythm\u003cEvent\u003e(1/\u003e1, [event([pitch, dynamic, articulation])])\nlet rhythmID = builder.createRhythm(note, voiceID: voiceID, offset: .zero)\nlet model = builder.build()\n```\n\n---\n\n## Requirements\n\nIn order to use the `Music` package, you'll need a few things:\n\n- Swift 5.x Toolchain (Xcode 10.2–11, or [here](https://swift.org/download/))\n- [Swift Package Manager](https://swift.org/package-manager/)\n\n## Installation\n\nIn order to use the `Music` modules in your own projects, add it to the `dependencies` section of your `Package.swift` file:\n\n```Swift\nlet package = Package(\n    name: ...,\n    products: [ ... ],\n    dependencies: [\n        ...,\n        .package(url: \"https://github.com/dn-m/Music\", from: \"0.17.1\")\n    ],\n    targets: [ ... ]\n)\n```\n\n## Development\n\n\nTo contribute to the `Music` package, clone the `git` repository:\n\n```\ngit clone https://github.com/dn-m/Music \u0026\u0026 cd Music\n```\n\nIf you use the Xcode IDE on macOS, you can use SwiftPM to generate an `.xcodeproj` file:\n\n```\nswift package generate-xcodeproj\n```\n\n## Inspiration\n\nHere are some libraries in other languages that have been influential to the design of the `Music` package:\n\n- [Abjad](http://abjad.mbrsi.org) (Python)\n- [Music21](http://web.mit.edu/music21/) (Python)\n- [Haskore](https://wiki.haskell.org/Haskore) (Haskell)\n- [Mezzo](http://hackage.haskell.org/package/mezzo) (Haskell)\n- [GUIDO](http://science.jkilian.de/salieri/GUIDO/index.html) (C++)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdn-m%2FMusic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdn-m%2FMusic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdn-m%2FMusic/lists"}