midilib 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +9 -4
- data/Rakefile +2 -6
- data/examples/from_scratch.rb +3 -5
- data/examples/measures_mbt.rb +4 -4
- data/examples/print_program_changes.rb +9 -9
- data/examples/reader2text.rb +188 -188
- data/examples/seq2text.rb +17 -17
- data/examples/split.rb +19 -19
- data/examples/strings.rb +14 -14
- data/examples/transpose.rb +31 -31
- data/html/IO.html +65 -169
- data/html/MIDI.html +138 -256
- data/html/MIDI/ActiveSense.html +89 -178
- data/html/MIDI/ChannelEvent.html +95 -183
- data/html/MIDI/ChannelPressure.html +105 -190
- data/html/MIDI/Clock.html +89 -178
- data/html/MIDI/Continue.html +89 -178
- data/html/MIDI/Controller.html +107 -192
- data/html/MIDI/Event.html +138 -222
- data/html/MIDI/IO.html +45 -157
- data/html/MIDI/IO/MIDIFile.html +596 -568
- data/html/MIDI/IO/SeqReader.html +272 -314
- data/html/MIDI/IO/SeqWriter.html +229 -305
- data/html/MIDI/KeySig.html +129 -211
- data/html/MIDI/MIDI.html +45 -154
- data/html/MIDI/MIDI/MIDI.html +45 -154
- data/html/MIDI/MIDI/MIDI/Array.html +87 -185
- data/html/MIDI/Marker.html +71 -170
- data/html/MIDI/Measure.html +95 -190
- data/html/MIDI/Measures.html +103 -193
- data/html/MIDI/MetaEvent.html +180 -253
- data/html/MIDI/NoteEvent.html +118 -204
- data/html/MIDI/NoteOff.html +95 -183
- data/html/MIDI/NoteOn.html +95 -183
- data/html/MIDI/PitchBend.html +106 -191
- data/html/MIDI/PolyPressure.html +106 -189
- data/html/MIDI/ProgramChange.html +105 -190
- data/html/MIDI/Realtime.html +98 -184
- data/html/MIDI/Sequence.html +246 -311
- data/html/MIDI/SongPointer.html +106 -191
- data/html/MIDI/SongSelect.html +105 -190
- data/html/MIDI/Start.html +89 -178
- data/html/MIDI/Stop.html +89 -178
- data/html/MIDI/SystemCommon.html +71 -170
- data/html/MIDI/SystemExclusive.html +108 -193
- data/html/MIDI/SystemReset.html +89 -178
- data/html/MIDI/Tempo.html +135 -213
- data/html/MIDI/TimeSig.html +135 -214
- data/html/MIDI/Track.html +217 -291
- data/html/MIDI/TuneRequest.html +98 -184
- data/html/MIDI/Utils.html +89 -189
- data/html/README_rdoc.html +237 -257
- data/html/TODO_rdoc.html +64 -139
- data/html/created.rid +14 -14
- data/html/css/fonts.css +167 -0
- data/html/{rdoc.css → css/rdoc.css} +265 -218
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/index.html +187 -169
- data/html/js/darkfish.js +41 -33
- data/html/js/jquery.js +4 -18
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +20 -5
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +1111 -498
- data/install.rb +43 -32
- data/lib/midilib/consts.rb +407 -407
- data/lib/midilib/event.rb +295 -294
- data/lib/midilib/info.rb +5 -5
- data/lib/midilib/io/midifile.rb +266 -267
- data/lib/midilib/io/seqreader.rb +106 -106
- data/lib/midilib/io/seqwriter.rb +59 -60
- data/lib/midilib/measure.rb +69 -69
- data/lib/midilib/sequence.rb +68 -70
- data/lib/midilib/track.rb +96 -102
- data/lib/midilib/utils.rb +15 -15
- data/test/event_equality.rb +50 -50
- data/test/test_event.rb +120 -122
- data/test/test_io.rb +35 -48
- data/test/test_sequence.rb +60 -60
- data/test/test_track.rb +154 -154
- data/test/test_varlen.rb +23 -25
- metadata +65 -57
data/html/MIDI/Sequence.html
CHANGED
@@ -2,70 +2,68 @@
|
|
2
2
|
|
3
3
|
<html>
|
4
4
|
<head>
|
5
|
-
<meta
|
5
|
+
<meta charset="UTF-8">
|
6
6
|
|
7
7
|
<title>class MIDI::Sequence - midilib</title>
|
8
8
|
|
9
|
-
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
10
|
-
|
11
9
|
<script type="text/javascript">
|
12
10
|
var rdoc_rel_prefix = "../";
|
13
11
|
</script>
|
14
12
|
|
15
|
-
<script
|
16
|
-
<script
|
17
|
-
|
18
|
-
<
|
19
|
-
<
|
20
|
-
|
13
|
+
<script src="../js/jquery.js"></script>
|
14
|
+
<script src="../js/darkfish.js"></script>
|
15
|
+
|
16
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
18
|
+
|
21
19
|
|
22
20
|
|
23
|
-
<body id="top" class="class">
|
24
|
-
<nav
|
25
|
-
<
|
26
|
-
|
27
|
-
|
21
|
+
<body id="top" role="document" class="class">
|
22
|
+
<nav role="navigation">
|
23
|
+
<div id="project-navigation">
|
24
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
25
|
+
<h2>
|
26
|
+
<a href="../index.html" rel="home">Home</a>
|
27
|
+
</h2>
|
28
|
+
|
29
|
+
<div id="table-of-contents-navigation">
|
30
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
28
31
|
<a href="../table_of_contents.html#classes">Classes</a>
|
29
32
|
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
-
</
|
31
|
-
</
|
32
|
-
|
33
|
+
</div>
|
34
|
+
</div>
|
33
35
|
|
34
|
-
|
36
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
35
37
|
<form action="#" method="get" accept-charset="utf-8">
|
36
|
-
<
|
37
|
-
<input
|
38
|
+
<div id="search-field-wrapper">
|
39
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
40
|
+
aria-autocomplete="list" aria-controls="search-results"
|
41
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
38
42
|
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
-
</
|
40
|
-
</form>
|
41
|
-
|
42
|
-
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
-
</nav>
|
43
|
+
</div>
|
44
44
|
|
45
|
+
<ul id="search-results" aria-label="Search Results"
|
46
|
+
aria-busy="false" aria-expanded="false"
|
47
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
48
|
+
</form>
|
49
|
+
</div>
|
45
50
|
|
46
|
-
<div id="file-metadata">
|
47
|
-
<nav id="file-list-section" class="section">
|
48
|
-
<h3 class="section-header">Defined In</h3>
|
49
|
-
<ul>
|
50
|
-
<li>lib/midilib/sequence.rb
|
51
|
-
</ul>
|
52
|
-
</nav>
|
53
|
-
|
54
|
-
|
55
51
|
</div>
|
56
52
|
|
53
|
+
|
54
|
+
|
57
55
|
<div id="class-metadata">
|
58
56
|
|
59
|
-
<
|
60
|
-
<h3
|
57
|
+
<div id="parent-class-section" class="nav-section">
|
58
|
+
<h3>Parent</h3>
|
59
|
+
|
61
60
|
|
62
61
|
<p class="link">Object
|
63
62
|
|
64
|
-
</
|
63
|
+
</div>
|
65
64
|
|
66
|
-
|
67
|
-
<
|
68
|
-
<h3 class="section-header">Included Modules</h3>
|
65
|
+
<div id="includes-section" class="nav-section">
|
66
|
+
<h3>Included Modules</h3>
|
69
67
|
|
70
68
|
<ul class="link-list">
|
71
69
|
|
@@ -74,168 +72,62 @@
|
|
74
72
|
|
75
73
|
|
76
74
|
</ul>
|
77
|
-
</
|
75
|
+
</div>
|
78
76
|
|
77
|
+
|
79
78
|
<!-- Method Quickref -->
|
80
|
-
<
|
81
|
-
<h3
|
79
|
+
<div id="method-list-section" class="nav-section">
|
80
|
+
<h3>Methods</h3>
|
82
81
|
|
83
|
-
<ul class="link-list">
|
82
|
+
<ul class="link-list" role="directory">
|
84
83
|
|
85
|
-
<li><a href="#method-c-new">::new</a>
|
84
|
+
<li ><a href="#method-c-new">::new</a>
|
86
85
|
|
87
|
-
<li><a href="#method-i-beats_per_minute">#beats_per_minute</a>
|
86
|
+
<li ><a href="#method-i-beats_per_minute">#beats_per_minute</a>
|
88
87
|
|
89
|
-
<li><a href="#method-i-bpm">#bpm</a>
|
88
|
+
<li ><a href="#method-i-bpm">#bpm</a>
|
90
89
|
|
91
|
-
<li><a href="#method-i-each">#each</a>
|
90
|
+
<li ><a href="#method-i-each">#each</a>
|
92
91
|
|
93
|
-
<li><a href="#method-i-get_measures">#get_measures</a>
|
92
|
+
<li ><a href="#method-i-get_measures">#get_measures</a>
|
94
93
|
|
95
|
-
<li><a href="#method-i-length_to_delta">#length_to_delta</a>
|
94
|
+
<li ><a href="#method-i-length_to_delta">#length_to_delta</a>
|
96
95
|
|
97
|
-
<li><a href="#method-i-name">#name</a>
|
96
|
+
<li ><a href="#method-i-name">#name</a>
|
98
97
|
|
99
|
-
<li><a href="#method-i-name-3D">#name=</a>
|
98
|
+
<li ><a href="#method-i-name-3D">#name=</a>
|
100
99
|
|
101
|
-
<li><a href="#method-i-note_to_delta">#note_to_delta</a>
|
100
|
+
<li ><a href="#method-i-note_to_delta">#note_to_delta</a>
|
102
101
|
|
103
|
-
<li><a href="#method-i-note_to_length">#note_to_length</a>
|
102
|
+
<li ><a href="#method-i-note_to_length">#note_to_length</a>
|
104
103
|
|
105
|
-
<li><a href="#method-i-pulses_to_seconds">#pulses_to_seconds</a>
|
104
|
+
<li ><a href="#method-i-pulses_to_seconds">#pulses_to_seconds</a>
|
106
105
|
|
107
|
-
<li><a href="#method-i-read">#read</a>
|
106
|
+
<li ><a href="#method-i-read">#read</a>
|
108
107
|
|
109
|
-
<li><a href="#method-i-tempo">#tempo</a>
|
108
|
+
<li ><a href="#method-i-tempo">#tempo</a>
|
110
109
|
|
111
|
-
<li><a href="#method-i-time_signature">#time_signature</a>
|
110
|
+
<li ><a href="#method-i-time_signature">#time_signature</a>
|
112
111
|
|
113
|
-
<li><a href="#method-i-write">#write</a>
|
112
|
+
<li ><a href="#method-i-write">#write</a>
|
114
113
|
|
115
114
|
</ul>
|
116
|
-
</
|
117
|
-
|
118
|
-
</div>
|
119
|
-
|
120
|
-
<div id="project-metadata">
|
121
|
-
<nav id="fileindex-section" class="section project-section">
|
122
|
-
<h3 class="section-header">Pages</h3>
|
123
|
-
|
124
|
-
<ul>
|
125
|
-
|
126
|
-
<li class="file"><a href="../README_rdoc.html">README</a>
|
127
|
-
|
128
|
-
<li class="file"><a href="../TODO_rdoc.html">TODO</a>
|
129
|
-
|
130
|
-
</ul>
|
131
|
-
</nav>
|
132
|
-
|
133
|
-
<nav id="classindex-section" class="section project-section">
|
134
|
-
<h3 class="section-header">Class and Module Index</h3>
|
135
|
-
|
136
|
-
<ul class="link-list">
|
137
|
-
|
138
|
-
<li><a href="../MIDI.html">MIDI</a>
|
139
|
-
|
140
|
-
<li><a href="../MIDI/ActiveSense.html">MIDI::ActiveSense</a>
|
141
|
-
|
142
|
-
<li><a href="../MIDI/ChannelEvent.html">MIDI::ChannelEvent</a>
|
143
|
-
|
144
|
-
<li><a href="../MIDI/ChannelPressure.html">MIDI::ChannelPressure</a>
|
145
|
-
|
146
|
-
<li><a href="../MIDI/Clock.html">MIDI::Clock</a>
|
147
|
-
|
148
|
-
<li><a href="../MIDI/Continue.html">MIDI::Continue</a>
|
149
|
-
|
150
|
-
<li><a href="../MIDI/Controller.html">MIDI::Controller</a>
|
151
|
-
|
152
|
-
<li><a href="../MIDI/Event.html">MIDI::Event</a>
|
153
|
-
|
154
|
-
<li><a href="../MIDI/IO.html">MIDI::IO</a>
|
155
|
-
|
156
|
-
<li><a href="../MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a>
|
157
|
-
|
158
|
-
<li><a href="../MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a>
|
159
|
-
|
160
|
-
<li><a href="../MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a>
|
161
|
-
|
162
|
-
<li><a href="../MIDI/KeySig.html">MIDI::KeySig</a>
|
163
|
-
|
164
|
-
<li><a href="../MIDI/MIDI.html">MIDI::MIDI</a>
|
165
|
-
|
166
|
-
<li><a href="../MIDI/MIDI/MIDI.html">MIDI::MIDI::MIDI</a>
|
167
|
-
|
168
|
-
<li><a href="../MIDI/MIDI/MIDI/Array.html">MIDI::MIDI::MIDI::Array</a>
|
169
|
-
|
170
|
-
<li><a href="../MIDI/Marker.html">MIDI::Marker</a>
|
171
|
-
|
172
|
-
<li><a href="../MIDI/Measure.html">MIDI::Measure</a>
|
173
|
-
|
174
|
-
<li><a href="../MIDI/Measures.html">MIDI::Measures</a>
|
175
|
-
|
176
|
-
<li><a href="../MIDI/MetaEvent.html">MIDI::MetaEvent</a>
|
177
|
-
|
178
|
-
<li><a href="../MIDI/NoteEvent.html">MIDI::NoteEvent</a>
|
179
|
-
|
180
|
-
<li><a href="../MIDI/NoteOff.html">MIDI::NoteOff</a>
|
181
|
-
|
182
|
-
<li><a href="../MIDI/NoteOff.html">MIDI::NoteOffEvent</a>
|
183
|
-
|
184
|
-
<li><a href="../MIDI/NoteOn.html">MIDI::NoteOn</a>
|
185
|
-
|
186
|
-
<li><a href="../MIDI/NoteOn.html">MIDI::NoteOnEvent</a>
|
187
|
-
|
188
|
-
<li><a href="../MIDI/PitchBend.html">MIDI::PitchBend</a>
|
189
|
-
|
190
|
-
<li><a href="../MIDI/PolyPressure.html">MIDI::PolyPressure</a>
|
191
|
-
|
192
|
-
<li><a href="../MIDI/ProgramChange.html">MIDI::ProgramChange</a>
|
193
|
-
|
194
|
-
<li><a href="../MIDI/Realtime.html">MIDI::Realtime</a>
|
195
|
-
|
196
|
-
<li><a href="../MIDI/Sequence.html">MIDI::Sequence</a>
|
197
|
-
|
198
|
-
<li><a href="../MIDI/SongPointer.html">MIDI::SongPointer</a>
|
199
|
-
|
200
|
-
<li><a href="../MIDI/SongSelect.html">MIDI::SongSelect</a>
|
201
|
-
|
202
|
-
<li><a href="../MIDI/Start.html">MIDI::Start</a>
|
203
|
-
|
204
|
-
<li><a href="../MIDI/Stop.html">MIDI::Stop</a>
|
205
|
-
|
206
|
-
<li><a href="../MIDI/SystemCommon.html">MIDI::SystemCommon</a>
|
207
|
-
|
208
|
-
<li><a href="../MIDI/SystemExclusive.html">MIDI::SystemExclusive</a>
|
209
|
-
|
210
|
-
<li><a href="../MIDI/SystemReset.html">MIDI::SystemReset</a>
|
211
|
-
|
212
|
-
<li><a href="../MIDI/Tempo.html">MIDI::Tempo</a>
|
213
|
-
|
214
|
-
<li><a href="../MIDI/TimeSig.html">MIDI::TimeSig</a>
|
215
|
-
|
216
|
-
<li><a href="../MIDI/Track.html">MIDI::Track</a>
|
217
|
-
|
218
|
-
<li><a href="../MIDI/TuneRequest.html">MIDI::TuneRequest</a>
|
219
|
-
|
220
|
-
<li><a href="../MIDI/Utils.html">MIDI::Utils</a>
|
221
|
-
|
222
|
-
<li><a href="../IO.html">IO</a>
|
223
|
-
|
224
|
-
</ul>
|
225
|
-
</nav>
|
115
|
+
</div>
|
226
116
|
|
227
117
|
</div>
|
228
118
|
</nav>
|
229
119
|
|
230
|
-
<
|
231
|
-
<h1
|
120
|
+
<main role="main" aria-labelledby="class-MIDI::Sequence">
|
121
|
+
<h1 id="class-MIDI::Sequence" class="class">
|
122
|
+
class MIDI::Sequence
|
123
|
+
</h1>
|
232
124
|
|
233
|
-
<
|
125
|
+
<section class="description">
|
234
126
|
|
235
127
|
<p>A <a href="Sequence.html">MIDI::Sequence</a> contains <a
|
236
128
|
href="Track.html">MIDI::Track</a> objects.</p>
|
237
129
|
|
238
|
-
</
|
130
|
+
</section>
|
239
131
|
|
240
132
|
|
241
133
|
|
@@ -246,24 +138,25 @@ href="Track.html">MIDI::Track</a> objects.</p>
|
|
246
138
|
|
247
139
|
|
248
140
|
|
249
|
-
|
250
|
-
|
251
|
-
|
141
|
+
<section class="constants-list">
|
142
|
+
<header>
|
143
|
+
<h3>Constants</h3>
|
144
|
+
</header>
|
252
145
|
<dl>
|
253
146
|
|
254
147
|
<dt id="DEFAULT_TEMPO">DEFAULT_TEMPO
|
255
148
|
|
256
|
-
<dd
|
149
|
+
<dd>
|
257
150
|
|
258
151
|
|
259
152
|
<dt id="NOTE_TO_LENGTH">NOTE_TO_LENGTH
|
260
153
|
|
261
|
-
<dd
|
154
|
+
<dd>
|
262
155
|
|
263
156
|
|
264
157
|
<dt id="UNNAMED">UNNAMED
|
265
158
|
|
266
|
-
<dd
|
159
|
+
<dd>
|
267
160
|
|
268
161
|
|
269
162
|
</dl>
|
@@ -271,9 +164,10 @@ href="Track.html">MIDI::Track</a> objects.</p>
|
|
271
164
|
|
272
165
|
|
273
166
|
|
274
|
-
|
275
|
-
|
276
|
-
|
167
|
+
<section class="attribute-method-details" class="method-section">
|
168
|
+
<header>
|
169
|
+
<h3>Attributes</h3>
|
170
|
+
</header>
|
277
171
|
|
278
172
|
|
279
173
|
<div id="attribute-i-clocks" class="method-detail">
|
@@ -397,13 +291,14 @@ change this at any time.</p>
|
|
397
291
|
</div>
|
398
292
|
</div>
|
399
293
|
|
400
|
-
</section
|
294
|
+
</section>
|
401
295
|
|
402
296
|
|
403
|
-
<!-- Methods -->
|
404
297
|
|
405
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section
|
406
|
-
|
298
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
299
|
+
<header>
|
300
|
+
<h3>Public Class Methods</h3>
|
301
|
+
</header>
|
407
302
|
|
408
303
|
|
409
304
|
<div id="method-c-new" class="method-detail ">
|
@@ -411,7 +306,9 @@ change this at any time.</p>
|
|
411
306
|
<div class="method-heading">
|
412
307
|
<span class="method-name">new</span><span
|
413
308
|
class="method-args">()</span>
|
309
|
+
|
414
310
|
<span class="method-click-advice">click to toggle source</span>
|
311
|
+
|
415
312
|
</div>
|
416
313
|
|
417
314
|
|
@@ -419,37 +316,40 @@ change this at any time.</p>
|
|
419
316
|
|
420
317
|
|
421
318
|
|
319
|
+
|
422
320
|
|
423
321
|
|
424
322
|
<div class="method-source-code" id="new-source">
|
425
323
|
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 45</span>
|
426
324
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
|
427
|
-
|
428
|
-
|
325
|
+
<span class="ruby-ivar">@tracks</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>()
|
326
|
+
<span class="ruby-ivar">@ppqn</span> = <span class="ruby-value">480</span>
|
429
327
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
328
|
+
<span class="ruby-comment"># Time signature</span>
|
329
|
+
<span class="ruby-ivar">@numer</span> = <span class="ruby-value">4</span> <span class="ruby-comment"># Numer + denom = 4/4 time default</span>
|
330
|
+
<span class="ruby-ivar">@denom</span> = <span class="ruby-value">2</span>
|
331
|
+
<span class="ruby-ivar">@clocks</span> = <span class="ruby-value">24</span> <span class="ruby-comment"># Bug fix Nov 11, 2007 - this is not the same as ppqn!</span>
|
332
|
+
<span class="ruby-ivar">@qnotes</span> = <span class="ruby-value">8</span>
|
435
333
|
|
436
|
-
|
437
|
-
|
334
|
+
<span class="ruby-ivar">@reader_class</span> = <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">SeqReader</span>
|
335
|
+
<span class="ruby-ivar">@writer_class</span> = <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">SeqWriter</span>
|
438
336
|
<span class="ruby-keyword">end</span></pre>
|
439
|
-
</div
|
337
|
+
</div>
|
440
338
|
|
441
339
|
</div>
|
442
340
|
|
443
341
|
|
444
342
|
|
445
343
|
|
446
|
-
</div
|
344
|
+
</div>
|
447
345
|
|
448
346
|
|
449
|
-
</section
|
347
|
+
</section>
|
450
348
|
|
451
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section
|
452
|
-
|
349
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
350
|
+
<header>
|
351
|
+
<h3>Public Instance Methods</h3>
|
352
|
+
</header>
|
453
353
|
|
454
354
|
|
455
355
|
<div id="method-i-beats_per_minute" class="method-detail ">
|
@@ -457,7 +357,9 @@ change this at any time.</p>
|
|
457
357
|
<div class="method-heading">
|
458
358
|
<span class="method-name">beats_per_minute</span><span
|
459
359
|
class="method-args">()</span>
|
360
|
+
|
460
361
|
<span class="method-click-advice">click to toggle source</span>
|
362
|
+
|
461
363
|
</div>
|
462
364
|
|
463
365
|
|
@@ -465,18 +367,17 @@ change this at any time.</p>
|
|
465
367
|
|
466
368
|
<p>Returns the song tempo in beats per minute.</p>
|
467
369
|
|
370
|
+
|
468
371
|
|
469
372
|
|
470
373
|
<div class="method-source-code" id="beats_per_minute-source">
|
471
374
|
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 68</span>
|
472
375
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">beats_per_minute</span>
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
}
|
477
|
-
<span class="ruby-keyword">return</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">?</span> (<span class="ruby-constant">Tempo</span>.<span class="ruby-identifier">mpq_to_bpm</span>(<span class="ruby-identifier">event</span>.<span class="ruby-identifier">tempo</span>)) <span class="ruby-operator">:</span> <span class="ruby-constant">DEFAULT_TEMPO</span>
|
376
|
+
<span class="ruby-keyword">return</span> <span class="ruby-constant">DEFAULT_TEMPO</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">empty?</span>
|
377
|
+
<span class="ruby-identifier">event</span> = <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">events</span>.<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Tempo</span>) }
|
378
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">event</span> <span class="ruby-operator">?</span> (<span class="ruby-constant">Tempo</span>.<span class="ruby-identifier">mpq_to_bpm</span>(<span class="ruby-identifier">event</span>.<span class="ruby-identifier">tempo</span>)) <span class="ruby-operator">:</span> <span class="ruby-constant">DEFAULT_TEMPO</span>
|
478
379
|
<span class="ruby-keyword">end</span></pre>
|
479
|
-
</div
|
380
|
+
</div>
|
480
381
|
|
481
382
|
</div>
|
482
383
|
|
@@ -487,7 +388,7 @@ change this at any time.</p>
|
|
487
388
|
|
488
389
|
|
489
390
|
|
490
|
-
</div
|
391
|
+
</div>
|
491
392
|
|
492
393
|
|
493
394
|
<div id="method-i-bpm" class="method-detail method-alias">
|
@@ -495,7 +396,7 @@ change this at any time.</p>
|
|
495
396
|
<div class="method-heading">
|
496
397
|
<span class="method-name">bpm</span><span
|
497
398
|
class="method-args">()</span>
|
498
|
-
|
399
|
+
|
499
400
|
</div>
|
500
401
|
|
501
402
|
|
@@ -503,6 +404,7 @@ change this at any time.</p>
|
|
503
404
|
|
504
405
|
|
505
406
|
|
407
|
+
|
506
408
|
|
507
409
|
|
508
410
|
</div>
|
@@ -514,7 +416,7 @@ change this at any time.</p>
|
|
514
416
|
Alias for: <a href="Sequence.html#method-i-beats_per_minute">beats_per_minute</a>
|
515
417
|
</div>
|
516
418
|
|
517
|
-
</div
|
419
|
+
</div>
|
518
420
|
|
519
421
|
|
520
422
|
<div id="method-i-each" class="method-detail ">
|
@@ -522,7 +424,9 @@ change this at any time.</p>
|
|
522
424
|
<div class="method-heading">
|
523
425
|
<span class="method-name">each</span><span
|
524
426
|
class="method-args">() { |track| ... }</span>
|
427
|
+
|
525
428
|
<span class="method-click-advice">click to toggle source</span>
|
429
|
+
|
526
430
|
</div>
|
527
431
|
|
528
432
|
|
@@ -530,21 +434,22 @@ change this at any time.</p>
|
|
530
434
|
|
531
435
|
<p>Iterates over the tracks.</p>
|
532
436
|
|
437
|
+
|
533
438
|
|
534
439
|
|
535
440
|
<div class="method-source-code" id="each-source">
|
536
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
441
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 149</span>
|
537
442
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">each</span> <span class="ruby-comment"># :yields: track</span>
|
538
|
-
|
443
|
+
<span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">track</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">track</span> }
|
539
444
|
<span class="ruby-keyword">end</span></pre>
|
540
|
-
</div
|
445
|
+
</div>
|
541
446
|
|
542
447
|
</div>
|
543
448
|
|
544
449
|
|
545
450
|
|
546
451
|
|
547
|
-
</div
|
452
|
+
</div>
|
548
453
|
|
549
454
|
|
550
455
|
<div id="method-i-get_measures" class="method-detail ">
|
@@ -552,7 +457,9 @@ change this at any time.</p>
|
|
552
457
|
<div class="method-heading">
|
553
458
|
<span class="method-name">get_measures</span><span
|
554
459
|
class="method-args">()</span>
|
460
|
+
|
555
461
|
<span class="method-click-advice">click to toggle source</span>
|
462
|
+
|
556
463
|
</div>
|
557
464
|
|
558
465
|
|
@@ -561,57 +468,58 @@ change this at any time.</p>
|
|
561
468
|
<p>Returns a <a href="Measures.html">Measures</a> object, which is an array
|
562
469
|
container for all measures in the sequence</p>
|
563
470
|
|
471
|
+
|
564
472
|
|
565
473
|
|
566
474
|
<div class="method-source-code" id="get_measures-source">
|
567
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
568
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_measures</span>
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
475
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 155</span>
|
476
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_measures</span>
|
477
|
+
<span class="ruby-comment"># Collect time sig events and scan for last event time</span>
|
478
|
+
<span class="ruby-identifier">time_sigs</span> = []
|
479
|
+
<span class="ruby-identifier">max_pos</span> = <span class="ruby-value">0</span>
|
480
|
+
<span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
|
481
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
482
|
+
<span class="ruby-identifier">time_sigs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeSig</span>)
|
483
|
+
<span class="ruby-identifier">max_pos</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-operator">></span> <span class="ruby-identifier">max_pos</span>
|
484
|
+
<span class="ruby-keyword">end</span>
|
485
|
+
<span class="ruby-keyword">end</span>
|
486
|
+
<span class="ruby-identifier">time_sigs</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">y</span>.<span class="ruby-identifier">time_from_start</span> }
|
487
|
+
|
488
|
+
<span class="ruby-comment"># Add a "fake" time sig event at the very last position of the sequence,</span>
|
489
|
+
<span class="ruby-comment"># just to make sure the whole sequence is calculated.</span>
|
490
|
+
<span class="ruby-identifier">t</span> = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeSig</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">4</span>, <span class="ruby-value">2</span>, <span class="ruby-value">24</span>, <span class="ruby-value">8</span>, <span class="ruby-value">0</span>)
|
491
|
+
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">time_from_start</span> = <span class="ruby-identifier">max_pos</span>
|
492
|
+
<span class="ruby-identifier">time_sigs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">t</span>
|
493
|
+
|
494
|
+
<span class="ruby-comment"># Default to 4/4</span>
|
495
|
+
<span class="ruby-identifier">measure_length</span> = <span class="ruby-ivar">@ppqn</span> <span class="ruby-operator">*</span> <span class="ruby-value">4</span>
|
496
|
+
<span class="ruby-identifier">oldnumer</span>, <span class="ruby-identifier">olddenom</span>, <span class="ruby-identifier">oldbeats</span> = <span class="ruby-value">4</span>, <span class="ruby-value">2</span>, <span class="ruby-value">24</span>
|
497
|
+
|
498
|
+
<span class="ruby-identifier">measures</span> = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Measures</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">max_pos</span>, <span class="ruby-ivar">@ppqn</span>)
|
499
|
+
<span class="ruby-identifier">curr_pos</span> = <span class="ruby-value">0</span>
|
500
|
+
<span class="ruby-identifier">curr_meas_no</span> = <span class="ruby-value">1</span>
|
501
|
+
<span class="ruby-identifier">time_sigs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">te</span><span class="ruby-operator">|</span>
|
502
|
+
<span class="ruby-identifier">meas_count</span> = (<span class="ruby-identifier">te</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">curr_pos</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">measure_length</span>
|
503
|
+
<span class="ruby-identifier">meas_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> (<span class="ruby-identifier">te</span>.<span class="ruby-identifier">time_from_start</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">curr_pos</span>) <span class="ruby-operator">%</span> <span class="ruby-identifier">measure_length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
504
|
+
<span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-identifier">meas_count</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
505
|
+
<span class="ruby-identifier">measures</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Measure</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">curr_meas_no</span>, <span class="ruby-identifier">curr_pos</span>, <span class="ruby-identifier">measure_length</span>,
|
506
|
+
<span class="ruby-identifier">oldnumer</span>, <span class="ruby-identifier">olddenom</span>, <span class="ruby-identifier">oldbeats</span>)
|
507
|
+
<span class="ruby-identifier">curr_meas_no</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
508
|
+
<span class="ruby-identifier">curr_pos</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">measure_length</span>
|
509
|
+
<span class="ruby-keyword">end</span>
|
510
|
+
<span class="ruby-identifier">oldnumer</span>, <span class="ruby-identifier">olddenom</span>, <span class="ruby-identifier">oldbeats</span> = <span class="ruby-identifier">te</span>.<span class="ruby-identifier">numerator</span>, <span class="ruby-identifier">te</span>.<span class="ruby-identifier">denominator</span>, <span class="ruby-identifier">te</span>.<span class="ruby-identifier">metronome_ticks</span>
|
511
|
+
<span class="ruby-identifier">measure_length</span> = <span class="ruby-identifier">te</span>.<span class="ruby-identifier">measure_duration</span>(<span class="ruby-ivar">@ppqn</span>)
|
512
|
+
<span class="ruby-keyword">end</span>
|
513
|
+
<span class="ruby-identifier">measures</span>
|
606
514
|
<span class="ruby-keyword">end</span></pre>
|
607
|
-
</div
|
515
|
+
</div>
|
608
516
|
|
609
517
|
</div>
|
610
518
|
|
611
519
|
|
612
520
|
|
613
521
|
|
614
|
-
</div
|
522
|
+
</div>
|
615
523
|
|
616
524
|
|
617
525
|
<div id="method-i-length_to_delta" class="method-detail ">
|
@@ -619,7 +527,9 @@ container for all measures in the sequence</p>
|
|
619
527
|
<div class="method-heading">
|
620
528
|
<span class="method-name">length_to_delta</span><span
|
621
529
|
class="method-args">(length)</span>
|
530
|
+
|
622
531
|
<span class="method-click-advice">click to toggle source</span>
|
532
|
+
|
623
533
|
</div>
|
624
534
|
|
625
535
|
|
@@ -634,21 +544,22 @@ integer mathematics and rounding. Use floating-point numbers like 1.0 and
|
|
634
544
|
<p>See also <a href="Sequence.html#method-i-note_to_delta">#note_to_delta</a>
|
635
545
|
and note_to_length.</p>
|
636
546
|
|
547
|
+
|
637
548
|
|
638
549
|
|
639
550
|
<div class="method-source-code" id="length_to_delta-source">
|
640
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
551
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 119</span>
|
641
552
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">length_to_delta</span>(<span class="ruby-identifier">length</span>)
|
642
|
-
<span class="ruby-keyword">return</span> (<span class="ruby-ivar">@ppqn</span>
|
553
|
+
<span class="ruby-keyword">return</span> (<span class="ruby-ivar">@ppqn</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">length</span>).<span class="ruby-identifier">to_i</span>
|
643
554
|
<span class="ruby-keyword">end</span></pre>
|
644
|
-
</div
|
555
|
+
</div>
|
645
556
|
|
646
557
|
</div>
|
647
558
|
|
648
559
|
|
649
560
|
|
650
561
|
|
651
|
-
</div
|
562
|
+
</div>
|
652
563
|
|
653
564
|
|
654
565
|
<div id="method-i-name" class="method-detail ">
|
@@ -656,7 +567,9 @@ and note_to_length.</p>
|
|
656
567
|
<div class="method-heading">
|
657
568
|
<span class="method-name">name</span><span
|
658
569
|
class="method-args">()</span>
|
570
|
+
|
659
571
|
<span class="method-click-advice">click to toggle source</span>
|
572
|
+
|
660
573
|
</div>
|
661
574
|
|
662
575
|
|
@@ -665,22 +578,23 @@ and note_to_length.</p>
|
|
665
578
|
<p>Returns the name of the first track (track zero). If there are no tracks,
|
666
579
|
returns <a href="Sequence.html#UNNAMED">UNNAMED</a>.</p>
|
667
580
|
|
581
|
+
|
668
582
|
|
669
583
|
|
670
584
|
<div class="method-source-code" id="name-source">
|
671
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
585
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 125</span>
|
672
586
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">name</span>
|
673
|
-
|
674
|
-
|
587
|
+
<span class="ruby-keyword">return</span> <span class="ruby-constant">UNNAMED</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">empty?</span>
|
588
|
+
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">name</span>()
|
675
589
|
<span class="ruby-keyword">end</span></pre>
|
676
|
-
</div
|
590
|
+
</div>
|
677
591
|
|
678
592
|
</div>
|
679
593
|
|
680
594
|
|
681
595
|
|
682
596
|
|
683
|
-
</div
|
597
|
+
</div>
|
684
598
|
|
685
599
|
|
686
600
|
<div id="method-i-name-3D" class="method-detail ">
|
@@ -688,7 +602,9 @@ returns <a href="Sequence.html#UNNAMED">UNNAMED</a>.</p>
|
|
688
602
|
<div class="method-heading">
|
689
603
|
<span class="method-name">name=</span><span
|
690
604
|
class="method-args">(name)</span>
|
605
|
+
|
691
606
|
<span class="method-click-advice">click to toggle source</span>
|
607
|
+
|
692
608
|
</div>
|
693
609
|
|
694
610
|
|
@@ -696,22 +612,23 @@ returns <a href="Sequence.html#UNNAMED">UNNAMED</a>.</p>
|
|
696
612
|
|
697
613
|
<p>Hands the name to the first track. Does nothing if there are no tracks.</p>
|
698
614
|
|
615
|
+
|
699
616
|
|
700
617
|
|
701
618
|
<div class="method-source-code" id="name-3D-source">
|
702
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
619
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 131</span>
|
703
620
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">name=</span>(<span class="ruby-identifier">name</span>)
|
704
|
-
|
705
|
-
|
621
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">empty?</span>
|
622
|
+
<span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>
|
706
623
|
<span class="ruby-keyword">end</span></pre>
|
707
|
-
</div
|
624
|
+
</div>
|
708
625
|
|
709
626
|
</div>
|
710
627
|
|
711
628
|
|
712
629
|
|
713
630
|
|
714
|
-
</div
|
631
|
+
</div>
|
715
632
|
|
716
633
|
|
717
634
|
<div id="method-i-note_to_delta" class="method-detail ">
|
@@ -719,30 +636,33 @@ returns <a href="Sequence.html#UNNAMED">UNNAMED</a>.</p>
|
|
719
636
|
<div class="method-heading">
|
720
637
|
<span class="method-name">note_to_delta</span><span
|
721
638
|
class="method-args">(name)</span>
|
639
|
+
|
722
640
|
<span class="method-click-advice">click to toggle source</span>
|
641
|
+
|
723
642
|
</div>
|
724
643
|
|
725
644
|
|
726
645
|
<div class="method-description">
|
727
646
|
|
728
|
-
<p>Given a note length name like
|
647
|
+
<p>Given a note length name like “whole”, “dotted quarter”, or “8th triplet”,
|
729
648
|
return the length of that note in quarter notes as a delta time.</p>
|
730
649
|
|
650
|
+
|
731
651
|
|
732
652
|
|
733
653
|
<div class="method-source-code" id="note_to_delta-source">
|
734
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
654
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 86</span>
|
735
655
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">note_to_delta</span>(<span class="ruby-identifier">name</span>)
|
736
656
|
<span class="ruby-keyword">return</span> <span class="ruby-identifier">length_to_delta</span>(<span class="ruby-identifier">note_to_length</span>(<span class="ruby-identifier">name</span>))
|
737
657
|
<span class="ruby-keyword">end</span></pre>
|
738
|
-
</div
|
658
|
+
</div>
|
739
659
|
|
740
660
|
</div>
|
741
661
|
|
742
662
|
|
743
663
|
|
744
664
|
|
745
|
-
</div
|
665
|
+
</div>
|
746
666
|
|
747
667
|
|
748
668
|
<div id="method-i-note_to_length" class="method-detail ">
|
@@ -750,29 +670,32 @@ return the length of that note in quarter notes as a delta time.</p>
|
|
750
670
|
<div class="method-heading">
|
751
671
|
<span class="method-name">note_to_length</span><span
|
752
672
|
class="method-args">(name)</span>
|
673
|
+
|
753
674
|
<span class="method-click-advice">click to toggle source</span>
|
675
|
+
|
754
676
|
</div>
|
755
677
|
|
756
678
|
|
757
679
|
<div class="method-description">
|
758
680
|
|
759
|
-
<p>Given a note length name like
|
681
|
+
<p>Given a note length name like “whole”, “dotted quarter”, or “8th triplet”,
|
760
682
|
return the length of that note in quarter notes as a floating-point number,
|
761
683
|
suitable for use as an argument to length_to_delta.</p>
|
762
684
|
|
763
685
|
<p>Legal names are any value in <a
|
764
686
|
href="Sequence.html#NOTE_TO_LENGTH">NOTE_TO_LENGTH</a>, optionally prefixed
|
765
|
-
by
|
766
|
-
|
767
|
-
triplet and
|
687
|
+
by “dotted_” and/or suffixed by “_triplet”. So, for example,
|
688
|
+
“dotted_quarter_triplet” returns the length of a dotted quarter-note
|
689
|
+
triplet and “32nd” returns 1/32.</p>
|
690
|
+
|
768
691
|
|
769
692
|
|
770
693
|
|
771
694
|
<div class="method-source-code" id="note_to_length-source">
|
772
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
695
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 99</span>
|
773
696
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">note_to_length</span>(<span class="ruby-identifier">name</span>)
|
774
697
|
<span class="ruby-identifier">name</span>.<span class="ruby-identifier">strip!</span>
|
775
|
-
<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp"
|
698
|
+
<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(dotted)?(.*?)(triplet)?$/</span>
|
776
699
|
<span class="ruby-identifier">dotted</span>, <span class="ruby-identifier">note_name</span>, <span class="ruby-identifier">triplet</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>, <span class="ruby-node">$3</span>
|
777
700
|
<span class="ruby-identifier">note_name</span>.<span class="ruby-identifier">strip!</span>
|
778
701
|
<span class="ruby-identifier">mult</span> = <span class="ruby-value">1.0</span>
|
@@ -780,16 +703,16 @@ triplet and "32nd" returns 1/32.</p>
|
|
780
703
|
<span class="ruby-identifier">mult</span> <span class="ruby-operator">/=</span> <span class="ruby-value">3.0</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">triplet</span>
|
781
704
|
<span class="ruby-identifier">len</span> = <span class="ruby-constant">NOTE_TO_LENGTH</span>[<span class="ruby-identifier">note_name</span>]
|
782
705
|
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Sequence.note_to_length: \"#{note_name}\" not understood in \"#{name}\""</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">len</span>
|
783
|
-
<span class="ruby-keyword">return</span> <span class="ruby-identifier">len</span>
|
706
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">len</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">mult</span>
|
784
707
|
<span class="ruby-keyword">end</span></pre>
|
785
|
-
</div
|
708
|
+
</div>
|
786
709
|
|
787
710
|
</div>
|
788
711
|
|
789
712
|
|
790
713
|
|
791
714
|
|
792
|
-
</div
|
715
|
+
</div>
|
793
716
|
|
794
717
|
|
795
718
|
<div id="method-i-pulses_to_seconds" class="method-detail ">
|
@@ -797,7 +720,9 @@ triplet and "32nd" returns 1/32.</p>
|
|
797
720
|
<div class="method-heading">
|
798
721
|
<span class="method-name">pulses_to_seconds</span><span
|
799
722
|
class="method-args">(pulses)</span>
|
723
|
+
|
800
724
|
<span class="method-click-advice">click to toggle source</span>
|
725
|
+
|
801
726
|
</div>
|
802
727
|
|
803
728
|
|
@@ -807,21 +732,22 @@ triplet and "32nd" returns 1/32.</p>
|
|
807
732
|
time_from_start values. This method converts a number of pulses to a float
|
808
733
|
value that is a time in seconds.</p>
|
809
734
|
|
735
|
+
|
810
736
|
|
811
737
|
|
812
738
|
<div class="method-source-code" id="pulses_to_seconds-source">
|
813
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
739
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 79</span>
|
814
740
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">pulses_to_seconds</span>(<span class="ruby-identifier">pulses</span>)
|
815
|
-
(<span class="ruby-identifier">pulses</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@ppqn</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">beats_per_minute</span>())
|
741
|
+
(<span class="ruby-identifier">pulses</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@ppqn</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">beats_per_minute</span>()) <span class="ruby-operator">*</span> <span class="ruby-value">60.0</span>
|
816
742
|
<span class="ruby-keyword">end</span></pre>
|
817
|
-
</div
|
743
|
+
</div>
|
818
744
|
|
819
745
|
</div>
|
820
746
|
|
821
747
|
|
822
748
|
|
823
749
|
|
824
|
-
</div
|
750
|
+
</div>
|
825
751
|
|
826
752
|
|
827
753
|
<div id="method-i-read" class="method-detail ">
|
@@ -829,7 +755,9 @@ value that is a time in seconds.</p>
|
|
829
755
|
<div class="method-heading">
|
830
756
|
<span class="method-name">read</span><span
|
831
757
|
class="method-args">(io, proc = nil) { |track, num_tracks, index| ... }</span>
|
758
|
+
|
832
759
|
<span class="method-click-advice">click to toggle source</span>
|
760
|
+
|
833
761
|
</div>
|
834
762
|
|
835
763
|
|
@@ -837,22 +765,23 @@ value that is a time in seconds.</p>
|
|
837
765
|
|
838
766
|
<p>Reads a <a href="MIDI.html">MIDI</a> stream.</p>
|
839
767
|
|
768
|
+
|
840
769
|
|
841
770
|
|
842
771
|
<div class="method-source-code" id="read-source">
|
843
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
772
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 137</span>
|
844
773
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">io</span>, <span class="ruby-identifier">proc</span> = <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># :yields: track, num_tracks, index</span>
|
845
|
-
|
846
|
-
|
774
|
+
<span class="ruby-identifier">reader</span> = <span class="ruby-ivar">@reader_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">block_given?</span>() <span class="ruby-operator">?</span> <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span>() <span class="ruby-operator">:</span> <span class="ruby-identifier">proc</span>)
|
775
|
+
<span class="ruby-identifier">reader</span>.<span class="ruby-identifier">read_from</span>(<span class="ruby-identifier">io</span>)
|
847
776
|
<span class="ruby-keyword">end</span></pre>
|
848
|
-
</div
|
777
|
+
</div>
|
849
778
|
|
850
779
|
</div>
|
851
780
|
|
852
781
|
|
853
782
|
|
854
783
|
|
855
|
-
</div
|
784
|
+
</div>
|
856
785
|
|
857
786
|
|
858
787
|
<div id="method-i-tempo" class="method-detail method-alias">
|
@@ -860,7 +789,7 @@ value that is a time in seconds.</p>
|
|
860
789
|
<div class="method-heading">
|
861
790
|
<span class="method-name">tempo</span><span
|
862
791
|
class="method-args">()</span>
|
863
|
-
|
792
|
+
|
864
793
|
</div>
|
865
794
|
|
866
795
|
|
@@ -868,6 +797,7 @@ value that is a time in seconds.</p>
|
|
868
797
|
|
869
798
|
|
870
799
|
|
800
|
+
|
871
801
|
|
872
802
|
|
873
803
|
</div>
|
@@ -879,7 +809,7 @@ value that is a time in seconds.</p>
|
|
879
809
|
Alias for: <a href="Sequence.html#method-i-beats_per_minute">beats_per_minute</a>
|
880
810
|
</div>
|
881
811
|
|
882
|
-
</div
|
812
|
+
</div>
|
883
813
|
|
884
814
|
|
885
815
|
<div id="method-i-time_signature" class="method-detail ">
|
@@ -887,7 +817,9 @@ value that is a time in seconds.</p>
|
|
887
817
|
<div class="method-heading">
|
888
818
|
<span class="method-name">time_signature</span><span
|
889
819
|
class="method-args">(numer, denom, clocks, qnotes)</span>
|
820
|
+
|
890
821
|
<span class="method-click-advice">click to toggle source</span>
|
822
|
+
|
891
823
|
</div>
|
892
824
|
|
893
825
|
|
@@ -895,24 +827,25 @@ value that is a time in seconds.</p>
|
|
895
827
|
|
896
828
|
<p>Sets the time signature.</p>
|
897
829
|
|
830
|
+
|
898
831
|
|
899
832
|
|
900
833
|
<div class="method-source-code" id="time_signature-source">
|
901
834
|
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 60</span>
|
902
835
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">time_signature</span>(<span class="ruby-identifier">numer</span>, <span class="ruby-identifier">denom</span>, <span class="ruby-identifier">clocks</span>, <span class="ruby-identifier">qnotes</span>)
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
836
|
+
<span class="ruby-ivar">@numer</span> = <span class="ruby-identifier">numer</span>
|
837
|
+
<span class="ruby-ivar">@denom</span> = <span class="ruby-identifier">denom</span>
|
838
|
+
<span class="ruby-ivar">@clocks</span> = <span class="ruby-identifier">clocks</span>
|
839
|
+
<span class="ruby-ivar">@qnotes</span> = <span class="ruby-identifier">qnotes</span>
|
907
840
|
<span class="ruby-keyword">end</span></pre>
|
908
|
-
</div
|
841
|
+
</div>
|
909
842
|
|
910
843
|
</div>
|
911
844
|
|
912
845
|
|
913
846
|
|
914
847
|
|
915
|
-
</div
|
848
|
+
</div>
|
916
849
|
|
917
850
|
|
918
851
|
<div id="method-i-write" class="method-detail ">
|
@@ -920,7 +853,9 @@ value that is a time in seconds.</p>
|
|
920
853
|
<div class="method-heading">
|
921
854
|
<span class="method-name">write</span><span
|
922
855
|
class="method-args">(io, proc = nil) { |track, num_tracks, index| ... }</span>
|
856
|
+
|
923
857
|
<span class="method-click-advice">click to toggle source</span>
|
858
|
+
|
924
859
|
</div>
|
925
860
|
|
926
861
|
|
@@ -928,34 +863,34 @@ value that is a time in seconds.</p>
|
|
928
863
|
|
929
864
|
<p>Writes to a <a href="MIDI.html">MIDI</a> stream.</p>
|
930
865
|
|
866
|
+
|
931
867
|
|
932
868
|
|
933
869
|
<div class="method-source-code" id="write-source">
|
934
|
-
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line
|
870
|
+
<pre><span class="ruby-comment"># File lib/midilib/sequence.rb, line 143</span>
|
935
871
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">io</span>, <span class="ruby-identifier">proc</span> = <span class="ruby-keyword">nil</span>) <span class="ruby-comment"># :yields: track, num_tracks, index</span>
|
936
|
-
|
937
|
-
|
872
|
+
<span class="ruby-identifier">writer</span> = <span class="ruby-ivar">@writer_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">block_given?</span>() <span class="ruby-operator">?</span> <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span>() <span class="ruby-operator">:</span> <span class="ruby-identifier">proc</span>)
|
873
|
+
<span class="ruby-identifier">writer</span>.<span class="ruby-identifier">write_to</span>(<span class="ruby-identifier">io</span>)
|
938
874
|
<span class="ruby-keyword">end</span></pre>
|
939
|
-
</div
|
875
|
+
</div>
|
940
876
|
|
941
877
|
</div>
|
942
878
|
|
943
879
|
|
944
880
|
|
945
881
|
|
946
|
-
</div
|
882
|
+
</div>
|
947
883
|
|
948
884
|
|
949
|
-
</section
|
885
|
+
</section>
|
950
886
|
|
951
|
-
</section
|
952
|
-
|
953
|
-
</div><!-- documentation -->
|
887
|
+
</section>
|
888
|
+
</main>
|
954
889
|
|
955
890
|
|
956
|
-
<footer id="validator-badges">
|
957
|
-
<p><a href="http://validator.w3.org/check/referer">
|
958
|
-
<p>Generated by <a href="
|
959
|
-
<p>
|
891
|
+
<footer id="validator-badges" role="contentinfo">
|
892
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
893
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
894
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
960
895
|
</footer>
|
961
896
|
|