-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
233 lines (185 loc) · 7.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>dn-m | Music</title>
<link rel="stylesheet" type="text/css" href="../../../assets/css/jazzy.css">
<link rel="stylesheet" type="text/css" href="../../../assets/css/highlight.css">
<meta charset="utf-8">
<script src="../../../assets/js/jquery.min.js" defer></script>
<script src="../../../assets/js/jazzy.js" defer></script>
</head>
<body>
<a title="dn-m | Music"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
dn-m Docs
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/dn-m/">
<img class="header-icon" src="../../../assets/img/gh.png">
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="https://dn-m.github.io">dn-m Reference</a>
<img class="carat" src="../../../assets/img/carat.png">
Music Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name" id="Modules">
<span class="nav-group-name-link">Modules</span>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Modules/Articulations/index.html">Articulations</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Modules/Dynamics/index.html">Dynamics</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Modules/Pitch/index.html">Pitch</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Modules/Duration/index.html">Duration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Modules/MusicModel/index.html">MusicModel</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>Music</h1>
<p><img src="https://img.shields.io/badge/Swift-5.x-orange.svg" alt="Swift Version">
<img src="https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20iOS%20%7C%20watchOS%20%7C%20tvOS-lightgrey.svg" alt="Platforms">
<a href="https://travis-ci.org/dn-m/Music"><img src="https://travis-ci.org/dn-m/Music.svg?branch=latest" alt="Build Status"></a></p>
<p>Structures for the creation, analysis, and performance of music in Swift. Check out the <a href="https://dn-m.github.io/Packages/Music">documentation</a>.</p>
<h2>Overview</h2>
<p><code>Music</code> is a package for anyone who wants to create, analyze, and perform music in pure Swift.</p>
<h2>Usage</h2>
<h3>🎶 Pitch</h3>
<p>The <a href="https://github.com/dn-m/Music/tree/latest/Sources/Pitch"><code>Pitch</code></a> module provides types for structuring and transforming the frequency domain.</p>
<h4>Basic Types</h4>
<p><code>swift
let a440: Frequency = 440 // Hz
let middleC: Pitch = 60 // MIDI note number
let e = middleC + 4 // e above middle c
let microtone = e - 0.25 // eighth-tone below the e above middle c
let anyE = Pitch.Class(e) // pitch class 4
let anyGSharp = anyE.inverse // pitch class 8
</code></p>
<h4>Set Operations</h4>
<p><code>swift
let set: Pitch.Class.Collection = [8,0,4,6]
set.normalForm // => [4,6,8,0]
set.primeForm // => [0,2,4,8]
</code></p>
<h4>Row Transformations</h4>
<p><code>swift
let pcs: Pitch.Class.Collection = [0,11,3,4,8,7,9,5,6,1,2,10]
pcs.retrograde // => [10,2,1,6,5,9,7,8,4,3,11,0]
pcs.inversion // => [0,1,9,8,4,5,3,7,6,11,10,2]
</code></p>
<h4>Diatonic Intervals</h4>
<p><code>swift
let majorThird: DiatonicInterval = .M3
let minorSixth = majorThird.inverse
let AAA3 = DiatonicInterval(.triple, .augmented, .third)
let noSuchThing = DiatonicInterval(.major, .fifth) ❌ will not compile!
</code></p>
<hr>
<h3>♬ Duration</h3>
<p>The <a href="https://github.com/dn-m/Music/tree/latest/Sources/Duration"><code>Duration</code></a> module provides types for structuring and transforming the time domain.</p>
<h4>Basic Types</h4>
<p><code>swift
let crotchet = Duration(1,4)
let waltz = Meter(3,4)
let stayinAlive = Tempo(100, subdivision: 4)
</code></p>
<hr>
<h3>🎚️ Dynamics</h3>
<p>The <code>Dynamic</code> module provides ways to describe musical loudness in a highly subjective way.</p>
<p><code>Swift
let loud: Dynamic = .ff
let quiet: Dynamic = .p
let interp = Dynamic.Interpolation(from: .p, to: .ff)
</code></p>
<hr>
<h3>🥁 Articulations</h3>
<p>The <code>Articulation</code> type provides an interface to describe the way in which a given musical entity is performed.</p>
<p><code>Swift
let short: Articulation = .staccato
let sweet: Articulation = .tenuto
let hard: Articulation = .marcato
let hereIAm: Articulation = .accent
</code></p>
<hr>
<h3>💾 MusicModel</h3>
<p>The <code>Model</code> brings all of elements together from the modules contained in this package.</p>
<p><code>Swift
let builder = Model.Builder()
let performer = Performer(name: "Pat")
let instrument = Instrument(name: "Euphonium")
let voiceID = builder.createVoice(performer: performer, instrument: instrument)
let pitch: Pitch = 60
let articulation: Articulation = .tenuto
let dynamic: Dynamic = .fff
let note = Rhythm<Event>(1/>1, [event([pitch, dynamic, articulation])])
let rhythmID = builder.createRhythm(note, voiceID: voiceID, offset: .zero)
let model = builder.build()
</code></p>
<hr>
<h2>Requirements</h2>
<p>In order to use the <code>Music</code> package, you'll need a few things:</p>
<ul>
<li>Swift 5.x Toolchain (Xcode 10.2–11, or <a href="https://swift.org/download/">here</a>)</li>
<li><a href="https://swift.org/package-manager/">Swift Package Manager</a></li>
</ul>
<h2>Installation</h2>
<p>In order to use the <code>Music</code> modules in your own projects, add it to the <code>dependencies</code> section of your <code>Package.swift</code> file:</p>
<p><code>Swift
let package = Package(
name: ...,
products: [ ... ],
dependencies: [
...,
.package(url: "https://github.com/dn-m/Music", from: "0.17.1")
],
targets: [ ... ]
)
</code></p>
<h2>Development</h2>
<p>To contribute to the <code>Music</code> package, clone the <code>git</code> repository:</p>
<p><code>
git clone https://github.com/dn-m/Music && cd Music
</code></p>
<p>If you use the Xcode IDE on macOS, you can use SwiftPM to generate an <code>.xcodeproj</code> file:</p>
<p><code>
swift package generate-xcodeproj
</code></p>
<h2>Inspiration</h2>
<p>Here are some libraries in other languages that have been influential to the design of the <code>Music</code> package:</p>
<ul>
<li><a href="http://abjad.mbrsi.org">Abjad</a> (Python)</li>
<li><a href="http://web.mit.edu/music21/">Music21</a> (Python)</li>
<li><a href="https://wiki.haskell.org/Haskore">Haskore</a> (Haskell)</li>
<li><a href="http://hackage.haskell.org/package/mezzo">Mezzo</a> (Haskell)</li>
<li><a href="http://science.jkilian.de/salieri/GUIDO/index.html">GUIDO</a> (C++)</li>
</ul>
</div>
</section>
</article>
</div>
<section class="footer">
<p>© 2019<a class="link" href="https://github.com/dn-m" target="_blank" rel="external">dn-m</a>. All rights reserved.</p>
</section>
</body>
</html>