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