motion-music 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/motion-music/version.rb +1 -1
- data/lib/rb-music/version.rb +1 -1
- metadata +2 -70
- data/.gitignore +0 -6
- data/Gemfile +0 -8
- data/Guardfile +0 -6
- data/doc/Gemfile.html +0 -111
- data/doc/Gemfile_lock.html +0 -168
- data/doc/Guardfile.html +0 -111
- data/doc/LICENSE.html +0 -124
- data/doc/Object.html +0 -116
- data/doc/RBMusic.html +0 -164
- data/doc/RBMusic/Interval.html +0 -440
- data/doc/RBMusic/Note.html +0 -620
- data/doc/RBMusic/NoteSet.html +0 -277
- data/doc/RBMusic/Scale.html +0 -274
- data/doc/README_md.html +0 -163
- data/doc/created.rid +0 -8
- data/doc/fonts.css +0 -167
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -93
- data/doc/js/darkfish.js +0 -140
- data/doc/js/jquery.js +0 -18
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/projections_json.html +0 -115
- data/doc/rb-music_gemspec.html +0 -132
- data/doc/rdoc.css +0 -580
- data/doc/table_of_contents.html +0 -192
- data/lib/rb-music.rb +0 -8
- data/motion-music.gemspec +0 -20
- data/projections.json +0 -12
- data/rb-music.gemspec +0 -29
- data/spec/rb-music/constants_spec.rb +0 -27
- data/spec/rb-music/interval_spec.rb +0 -90
- data/spec/rb-music/note_set_spec.rb +0 -191
- data/spec/rb-music/note_spec.rb +0 -318
- data/spec/rb-music/scale_spec.rb +0 -88
- data/spec/spec_helper.rb +0 -14
data/doc/RBMusic/Note.html
DELETED
@@ -1,620 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class RBMusic::Note - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<link href="../fonts.css" rel="stylesheet">
|
10
|
-
<link href="../rdoc.css" rel="stylesheet">
|
11
|
-
|
12
|
-
<script type="text/javascript">
|
13
|
-
var rdoc_rel_prefix = "../";
|
14
|
-
</script>
|
15
|
-
|
16
|
-
<script src="../js/jquery.js"></script>
|
17
|
-
<script src="../js/navigation.js"></script>
|
18
|
-
<script src="../js/search_index.js"></script>
|
19
|
-
<script src="../js/search.js"></script>
|
20
|
-
<script src="../js/searcher.js"></script>
|
21
|
-
<script src="../js/darkfish.js"></script>
|
22
|
-
|
23
|
-
|
24
|
-
<body id="top" role="document" class="class">
|
25
|
-
<nav role="navigation">
|
26
|
-
<div id="project-navigation">
|
27
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
-
<h2>
|
29
|
-
<a href="../index.html" rel="home">Home</a>
|
30
|
-
</h2>
|
31
|
-
|
32
|
-
<div id="table-of-contents-navigation">
|
33
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
-
</div>
|
37
|
-
</div>
|
38
|
-
|
39
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
-
<form action="#" method="get" accept-charset="utf-8">
|
41
|
-
<div id="search-field-wrapper">
|
42
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
-
aria-autocomplete="list" aria-controls="search-results"
|
44
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
-
</div>
|
47
|
-
|
48
|
-
<ul id="search-results" aria-label="Search Results"
|
49
|
-
aria-busy="false" aria-expanded="false"
|
50
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
-
</form>
|
52
|
-
</div>
|
53
|
-
|
54
|
-
</div>
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
<div id="class-metadata">
|
59
|
-
|
60
|
-
<div id="parent-class-section" class="nav-section">
|
61
|
-
<h3>Parent</h3>
|
62
|
-
|
63
|
-
|
64
|
-
<p class="link"><a href="../Object.html">Object</a>
|
65
|
-
|
66
|
-
</div>
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
<!-- Method Quickref -->
|
71
|
-
<div id="method-list-section" class="nav-section">
|
72
|
-
<h3>Methods</h3>
|
73
|
-
|
74
|
-
<ul class="link-list" role="directory">
|
75
|
-
|
76
|
-
<li ><a href="#method-c-from_latin">::from_latin</a>
|
77
|
-
|
78
|
-
<li ><a href="#method-c-new">::new</a>
|
79
|
-
|
80
|
-
<li ><a href="#method-i-3D-3D">#==</a>
|
81
|
-
|
82
|
-
<li ><a href="#method-i-accidental">#accidental</a>
|
83
|
-
|
84
|
-
<li ><a href="#method-i-add">#add</a>
|
85
|
-
|
86
|
-
<li ><a href="#method-i-enharmonic-3F">#enharmonic?</a>
|
87
|
-
|
88
|
-
<li ><a href="#method-i-enharmonically_equivalent_to-3F">#enharmonically_equivalent_to?</a>
|
89
|
-
|
90
|
-
<li ><a href="#method-i-frequency">#frequency</a>
|
91
|
-
|
92
|
-
<li ><a href="#method-i-latin">#latin</a>
|
93
|
-
|
94
|
-
<li ><a href="#method-i-octave">#octave</a>
|
95
|
-
|
96
|
-
<li ><a href="#method-i-scale">#scale</a>
|
97
|
-
|
98
|
-
<li ><a href="#method-i-subtract">#subtract</a>
|
99
|
-
|
100
|
-
</ul>
|
101
|
-
</div>
|
102
|
-
|
103
|
-
</div>
|
104
|
-
</nav>
|
105
|
-
|
106
|
-
<main role="main" aria-labelledby="class-RBMusic::Note">
|
107
|
-
<h1 id="class-RBMusic::Note" class="class">
|
108
|
-
class RBMusic::Note
|
109
|
-
</h1>
|
110
|
-
|
111
|
-
<section class="description">
|
112
|
-
|
113
|
-
</section>
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
<section class="attribute-method-details" class="method-section">
|
127
|
-
<header>
|
128
|
-
<h3>Attributes</h3>
|
129
|
-
</header>
|
130
|
-
|
131
|
-
|
132
|
-
<div id="attribute-i-coord" class="method-detail">
|
133
|
-
<div class="method-heading attribute-method-heading">
|
134
|
-
<span class="method-name">coord</span><span
|
135
|
-
class="attribute-access-type">[RW]</span>
|
136
|
-
</div>
|
137
|
-
|
138
|
-
<div class="method-description">
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
</div>
|
143
|
-
</div>
|
144
|
-
|
145
|
-
</section>
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
150
|
-
<header>
|
151
|
-
<h3>Public Class Methods</h3>
|
152
|
-
</header>
|
153
|
-
|
154
|
-
|
155
|
-
<div id="method-c-from_latin" class="method-detail ">
|
156
|
-
|
157
|
-
<div class="method-heading">
|
158
|
-
<span class="method-name">from_latin</span><span
|
159
|
-
class="method-args">(name)</span>
|
160
|
-
|
161
|
-
<span class="method-click-advice">click to toggle source</span>
|
162
|
-
|
163
|
-
</div>
|
164
|
-
|
165
|
-
|
166
|
-
<div class="method-description">
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
<div class="method-source-code" id="from_latin-source">
|
174
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 10</span>
|
175
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_latin</span>(<span class="ruby-identifier">name</span>)
|
176
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
|
177
|
-
|
178
|
-
<span class="ruby-identifier">note_parts</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/(\d+)/</span>)
|
179
|
-
<span class="ruby-identifier">note_name</span> = <span class="ruby-identifier">note_parts</span>.<span class="ruby-identifier">first</span>
|
180
|
-
<span class="ruby-identifier">octave</span> = <span class="ruby-identifier">note_parts</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">to_i</span>
|
181
|
-
|
182
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-constant">NOTES</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">note_name</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">note_parts</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">3</span>
|
183
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>
|
184
|
-
<span class="ruby-keyword">end</span>
|
185
|
-
|
186
|
-
<span class="ruby-identifier">coordinate</span> = [<span class="ruby-constant">NOTES</span>[<span class="ruby-identifier">note_name</span>][<span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">octave</span>, <span class="ruby-constant">NOTES</span>[<span class="ruby-identifier">note_name</span>][<span class="ruby-value">1</span>]]
|
187
|
-
|
188
|
-
<span class="ruby-identifier">coordinate</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-=</span> <span class="ruby-constant">BASE_OFFSET</span>[<span class="ruby-value">0</span>]
|
189
|
-
<span class="ruby-identifier">coordinate</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-=</span> <span class="ruby-constant">BASE_OFFSET</span>[<span class="ruby-value">1</span>]
|
190
|
-
|
191
|
-
<span class="ruby-constant">Note</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">coordinate</span>)
|
192
|
-
<span class="ruby-keyword">end</span></pre>
|
193
|
-
</div>
|
194
|
-
|
195
|
-
</div>
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
</div>
|
201
|
-
|
202
|
-
|
203
|
-
<div id="method-c-new" class="method-detail ">
|
204
|
-
|
205
|
-
<div class="method-heading">
|
206
|
-
<span class="method-name">new</span><span
|
207
|
-
class="method-args">(coord)</span>
|
208
|
-
|
209
|
-
<span class="method-click-advice">click to toggle source</span>
|
210
|
-
|
211
|
-
</div>
|
212
|
-
|
213
|
-
|
214
|
-
<div class="method-description">
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
<div class="method-source-code" id="new-source">
|
222
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 6</span>
|
223
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">coord</span>)
|
224
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">coord</span> = <span class="ruby-identifier">coord</span>
|
225
|
-
<span class="ruby-keyword">end</span></pre>
|
226
|
-
</div>
|
227
|
-
|
228
|
-
</div>
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
</div>
|
234
|
-
|
235
|
-
|
236
|
-
</section>
|
237
|
-
|
238
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
239
|
-
<header>
|
240
|
-
<h3>Public Instance Methods</h3>
|
241
|
-
</header>
|
242
|
-
|
243
|
-
|
244
|
-
<div id="method-i-3D-3D" class="method-detail ">
|
245
|
-
|
246
|
-
<div class="method-heading">
|
247
|
-
<span class="method-name">==</span><span
|
248
|
-
class="method-args">(other)</span>
|
249
|
-
|
250
|
-
<span class="method-click-advice">click to toggle source</span>
|
251
|
-
|
252
|
-
</div>
|
253
|
-
|
254
|
-
|
255
|
-
<div class="method-description">
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
<div class="method-source-code" id="3D-3D-source">
|
263
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 49</span>
|
264
|
-
<span class="ruby-keyword">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">other</span>)
|
265
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Note</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">latin</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">latin</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">octave</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">octave</span>
|
266
|
-
<span class="ruby-keyword">end</span></pre>
|
267
|
-
</div>
|
268
|
-
|
269
|
-
</div>
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
</div>
|
275
|
-
|
276
|
-
|
277
|
-
<div id="method-i-accidental" class="method-detail ">
|
278
|
-
|
279
|
-
<div class="method-heading">
|
280
|
-
<span class="method-name">accidental</span><span
|
281
|
-
class="method-args">()</span>
|
282
|
-
|
283
|
-
<span class="method-click-advice">click to toggle source</span>
|
284
|
-
|
285
|
-
</div>
|
286
|
-
|
287
|
-
|
288
|
-
<div class="method-description">
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
<div class="method-source-code" id="accidental-source">
|
296
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 33</span>
|
297
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">accidental</span>
|
298
|
-
<span class="ruby-ivar">@accidental</span> <span class="ruby-operator">||=</span> ((<span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">+</span> <span class="ruby-constant">BASE_OFFSET</span>[<span class="ruby-value">1</span>]) <span class="ruby-operator">/</span> <span class="ruby-value">7.0</span>).<span class="ruby-identifier">round</span>
|
299
|
-
<span class="ruby-keyword">end</span></pre>
|
300
|
-
</div>
|
301
|
-
|
302
|
-
</div>
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
</div>
|
308
|
-
|
309
|
-
|
310
|
-
<div id="method-i-add" class="method-detail ">
|
311
|
-
|
312
|
-
<div class="method-heading">
|
313
|
-
<span class="method-name">add</span><span
|
314
|
-
class="method-args">(that)</span>
|
315
|
-
|
316
|
-
<span class="method-click-advice">click to toggle source</span>
|
317
|
-
|
318
|
-
</div>
|
319
|
-
|
320
|
-
|
321
|
-
<div class="method-description">
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
<div class="method-source-code" id="add-source">
|
329
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 70</span>
|
330
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">that</span>)
|
331
|
-
<span class="ruby-comment"># if input is an array return an array</span>
|
332
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
333
|
-
<span class="ruby-identifier">notes</span> = <span class="ruby-identifier">that</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">thing</span><span class="ruby-operator">|</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">thing</span>) }
|
334
|
-
<span class="ruby-keyword">return</span> <span class="ruby-constant">NoteSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">notes</span>)
|
335
|
-
<span class="ruby-keyword">end</span>
|
336
|
-
|
337
|
-
<span class="ruby-comment"># if input is string/symbol try to parse it as interval</span>
|
338
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
|
339
|
-
<span class="ruby-identifier">that</span> = <span class="ruby-constant">Interval</span>.<span class="ruby-identifier">from_name</span>(<span class="ruby-identifier">that</span>)
|
340
|
-
<span class="ruby-keyword">end</span>
|
341
|
-
|
342
|
-
<span class="ruby-constant">Note</span>.<span class="ruby-identifier">new</span>([<span class="ruby-identifier">coord</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">coord</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>]])
|
343
|
-
<span class="ruby-keyword">end</span></pre>
|
344
|
-
</div>
|
345
|
-
|
346
|
-
</div>
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
</div>
|
352
|
-
|
353
|
-
|
354
|
-
<div id="method-i-enharmonic-3F" class="method-detail ">
|
355
|
-
|
356
|
-
<div class="method-heading">
|
357
|
-
<span class="method-name">enharmonic?</span><span
|
358
|
-
class="method-args">(other)</span>
|
359
|
-
|
360
|
-
<span class="method-click-advice">click to toggle source</span>
|
361
|
-
|
362
|
-
</div>
|
363
|
-
|
364
|
-
|
365
|
-
<div class="method-description">
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
<div class="method-source-code" id="enharmonic-3F-source">
|
373
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 53</span>
|
374
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">enharmonic?</span>(<span class="ruby-identifier">other</span>)
|
375
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Note</span>)
|
376
|
-
|
377
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">frequency</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">frequency</span>
|
378
|
-
<span class="ruby-keyword">end</span></pre>
|
379
|
-
</div>
|
380
|
-
|
381
|
-
</div>
|
382
|
-
|
383
|
-
|
384
|
-
<div class="aliases">
|
385
|
-
Also aliased as: <a href="Note.html#method-i-enharmonically_equivalent_to-3F">enharmonically_equivalent_to?</a>
|
386
|
-
</div>
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
</div>
|
391
|
-
|
392
|
-
|
393
|
-
<div id="method-i-enharmonically_equivalent_to-3F" class="method-detail method-alias">
|
394
|
-
|
395
|
-
<div class="method-heading">
|
396
|
-
<span class="method-name">enharmonically_equivalent_to?</span><span
|
397
|
-
class="method-args">(other)</span>
|
398
|
-
|
399
|
-
</div>
|
400
|
-
|
401
|
-
|
402
|
-
<div class="method-description">
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
</div>
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
<div class="aliases">
|
415
|
-
Alias for: <a href="Note.html#method-i-enharmonic-3F">enharmonic?</a>
|
416
|
-
</div>
|
417
|
-
|
418
|
-
</div>
|
419
|
-
|
420
|
-
|
421
|
-
<div id="method-i-frequency" class="method-detail ">
|
422
|
-
|
423
|
-
<div class="method-heading">
|
424
|
-
<span class="method-name">frequency</span><span
|
425
|
-
class="method-args">()</span>
|
426
|
-
|
427
|
-
<span class="method-click-advice">click to toggle source</span>
|
428
|
-
|
429
|
-
</div>
|
430
|
-
|
431
|
-
|
432
|
-
<div class="method-description">
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
<div class="method-source-code" id="frequency-source">
|
440
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 29</span>
|
441
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">frequency</span>
|
442
|
-
<span class="ruby-constant">BASE_FREQ</span> <span class="ruby-operator">*</span> (<span class="ruby-value">2.0</span> <span class="ruby-operator">**</span> ((<span class="ruby-identifier">coord</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">*</span> <span class="ruby-value">1200</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">*</span> <span class="ruby-value">700.0</span>) <span class="ruby-operator">/</span> <span class="ruby-value">1200.0</span>))
|
443
|
-
<span class="ruby-keyword">end</span></pre>
|
444
|
-
</div>
|
445
|
-
|
446
|
-
</div>
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
</div>
|
452
|
-
|
453
|
-
|
454
|
-
<div id="method-i-latin" class="method-detail ">
|
455
|
-
|
456
|
-
<div class="method-heading">
|
457
|
-
<span class="method-name">latin</span><span
|
458
|
-
class="method-args">()</span>
|
459
|
-
|
460
|
-
<span class="method-click-advice">click to toggle source</span>
|
461
|
-
|
462
|
-
</div>
|
463
|
-
|
464
|
-
|
465
|
-
<div class="method-description">
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
<div class="method-source-code" id="latin-source">
|
473
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 42</span>
|
474
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">latin</span>
|
475
|
-
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@latin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@latin</span>
|
476
|
-
<span class="ruby-identifier">noteName</span> = <span class="ruby-constant">NOTE_NAMES</span>[<span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">+</span> <span class="ruby-constant">BASE_OFFSET</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">accidental</span> <span class="ruby-operator">*</span> <span class="ruby-value">7</span> <span class="ruby-operator">+</span> <span class="ruby-value">3</span>]
|
477
|
-
<span class="ruby-identifier">accidentalName</span> = <span class="ruby-constant">ACCIDENTALS</span>[<span class="ruby-identifier">accidental</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>]
|
478
|
-
<span class="ruby-ivar">@latin</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">noteName</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">accidentalName</span>
|
479
|
-
<span class="ruby-keyword">end</span></pre>
|
480
|
-
</div>
|
481
|
-
|
482
|
-
</div>
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
</div>
|
488
|
-
|
489
|
-
|
490
|
-
<div id="method-i-octave" class="method-detail ">
|
491
|
-
|
492
|
-
<div class="method-heading">
|
493
|
-
<span class="method-name">octave</span><span
|
494
|
-
class="method-args">()</span>
|
495
|
-
|
496
|
-
<span class="method-click-advice">click to toggle source</span>
|
497
|
-
|
498
|
-
</div>
|
499
|
-
|
500
|
-
|
501
|
-
<div class="method-description">
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
<div class="method-source-code" id="octave-source">
|
509
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 37</span>
|
510
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">octave</span>
|
511
|
-
<span class="ruby-comment"># calculate octave of base note without accidentals</span>
|
512
|
-
<span class="ruby-ivar">@octave</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">coord</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-constant">BASE_OFFSET</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">accidental</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">+</span> <span class="ruby-constant">BASE_OFFSET</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-</span> <span class="ruby-value">7</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">accidental</span>) <span class="ruby-operator">/</span> <span class="ruby-value">2</span>).<span class="ruby-identifier">floor</span>
|
513
|
-
<span class="ruby-keyword">end</span></pre>
|
514
|
-
</div>
|
515
|
-
|
516
|
-
</div>
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
</div>
|
522
|
-
|
523
|
-
|
524
|
-
<div id="method-i-scale" class="method-detail ">
|
525
|
-
|
526
|
-
<div class="method-heading">
|
527
|
-
<span class="method-name">scale</span><span
|
528
|
-
class="method-args">(name)</span>
|
529
|
-
|
530
|
-
<span class="method-click-advice">click to toggle source</span>
|
531
|
-
|
532
|
-
</div>
|
533
|
-
|
534
|
-
|
535
|
-
<div class="method-description">
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
<div class="method-source-code" id="scale-source">
|
543
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 60</span>
|
544
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">scale</span>(<span class="ruby-identifier">name</span>)
|
545
|
-
<span class="ruby-identifier">notes</span> = [<span class="ruby-identifier">add</span>(<span class="ruby-value">:unison</span>)]
|
546
|
-
|
547
|
-
<span class="ruby-constant">SCALES</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">interval_name</span><span class="ruby-operator">|</span>
|
548
|
-
<span class="ruby-identifier">notes</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">add</span>(<span class="ruby-constant">Interval</span>.<span class="ruby-identifier">from_name</span>(<span class="ruby-identifier">interval_name</span>))
|
549
|
-
<span class="ruby-keyword">end</span>
|
550
|
-
|
551
|
-
<span class="ruby-identifier">notes</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">add</span>(<span class="ruby-value">:octave</span>)
|
552
|
-
<span class="ruby-keyword">end</span></pre>
|
553
|
-
</div>
|
554
|
-
|
555
|
-
</div>
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
</div>
|
561
|
-
|
562
|
-
|
563
|
-
<div id="method-i-subtract" class="method-detail ">
|
564
|
-
|
565
|
-
<div class="method-heading">
|
566
|
-
<span class="method-name">subtract</span><span
|
567
|
-
class="method-args">(that)</span>
|
568
|
-
|
569
|
-
<span class="method-click-advice">click to toggle source</span>
|
570
|
-
|
571
|
-
</div>
|
572
|
-
|
573
|
-
|
574
|
-
<div class="method-description">
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
<div class="method-source-code" id="subtract-source">
|
582
|
-
<pre><span class="ruby-comment"># File lib/rb-music/note.rb, line 85</span>
|
583
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">subtract</span>(<span class="ruby-identifier">that</span>)
|
584
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
585
|
-
<span class="ruby-identifier">notes</span> = <span class="ruby-identifier">that</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">thing</span><span class="ruby-operator">|</span> <span class="ruby-identifier">subtract</span>(<span class="ruby-identifier">thing</span>) }
|
586
|
-
<span class="ruby-keyword">return</span> <span class="ruby-constant">NoteSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">notes</span>)
|
587
|
-
<span class="ruby-keyword">end</span>
|
588
|
-
|
589
|
-
<span class="ruby-comment"># if input is string try to parse it as interval</span>
|
590
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
|
591
|
-
<span class="ruby-identifier">that</span> = <span class="ruby-constant">Interval</span>.<span class="ruby-identifier">from_name</span>(<span class="ruby-identifier">that</span>)
|
592
|
-
<span class="ruby-keyword">end</span>
|
593
|
-
|
594
|
-
<span class="ruby-identifier">coordinate</span> = [<span class="ruby-identifier">coord</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">coord</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">that</span>.<span class="ruby-identifier">coord</span>[<span class="ruby-value">1</span>]]
|
595
|
-
|
596
|
-
<span class="ruby-comment"># if input is another note return the difference as an Interval</span>
|
597
|
-
<span class="ruby-identifier">that</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Note</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">Interval</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">coordinate</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">Note</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">coordinate</span>)
|
598
|
-
<span class="ruby-keyword">end</span></pre>
|
599
|
-
</div>
|
600
|
-
|
601
|
-
</div>
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
</div>
|
607
|
-
|
608
|
-
|
609
|
-
</section>
|
610
|
-
|
611
|
-
</section>
|
612
|
-
</main>
|
613
|
-
|
614
|
-
|
615
|
-
<footer id="validator-badges" role="contentinfo">
|
616
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
617
|
-
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
618
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
619
|
-
</footer>
|
620
|
-
|