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/README_rdoc.html
CHANGED
@@ -2,160 +2,132 @@
|
|
2
2
|
|
3
3
|
<html>
|
4
4
|
<head>
|
5
|
-
<meta
|
5
|
+
<meta charset="UTF-8">
|
6
6
|
|
7
7
|
<title>README - 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 class="file">
|
24
|
-
<nav
|
25
|
-
<
|
26
|
-
|
27
|
-
|
21
|
+
<body id="top" role="document" class="file">
|
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
|
-
|
47
|
-
<nav id="fileindex-section" class="section project-section">
|
48
|
-
<h3 class="section-header">Pages</h3>
|
51
|
+
</div>
|
49
52
|
|
50
|
-
<ul>
|
51
|
-
|
52
|
-
<li class="file"><a href="./README_rdoc.html">README</a>
|
53
|
-
|
54
|
-
<li class="file"><a href="./TODO_rdoc.html">TODO</a>
|
55
53
|
|
54
|
+
<div class="nav-section">
|
55
|
+
<h3>Table of Contents</h3>
|
56
|
+
|
57
|
+
<ul class="link-list" role="directory">
|
58
|
+
<li><a href="#label-midilib">midilib</a>
|
59
|
+
<li><a href="#label-Dependencies">Dependencies</a>
|
60
|
+
<li><a href="#label-Installation">Installation</a>
|
61
|
+
<li><a href="#label-RubyGems+Installation">RubyGems Installation</a>
|
62
|
+
<li><a href="#label-Manual+Installation">Manual Installation</a>
|
63
|
+
<li><a href="#label-Testing">Testing</a>
|
64
|
+
<li><a href="#label-Overview">Overview</a>
|
65
|
+
<li><a href="#label-MIDI-3A-3ASequence">MIDI::Sequence</a>
|
66
|
+
<li><a href="#label-MIDI-3A-3ATrack">MIDI::Track</a>
|
67
|
+
<li><a href="#label-MIDI-3A-3AMeasure">MIDI::Measure</a>
|
68
|
+
<li><a href="#label-MIDI-3A-3AMeasures">MIDI::Measures</a>
|
69
|
+
<li><a href="#label-MIDI-3A-3AEvent">MIDI::Event</a>
|
70
|
+
<li><a href="#label-How+To+Use">How To Use</a>
|
71
|
+
<li><a href="#label-Reading+a+MIDI+File">Reading a MIDI File</a>
|
72
|
+
<li><a href="#label-Writing+a+MIDI+File">Writing a MIDI File</a>
|
73
|
+
<li><a href="#label-Editing+a+MIDI+File">Editing a MIDI File</a>
|
74
|
+
<li><a href="#label-Transposing+One+Channel">Transposing One Channel</a>
|
75
|
+
<li><a href="#label-Manipulating+tracks">Manipulating tracks</a>
|
76
|
+
<li><a href="#label-Calculating+delta+times">Calculating delta times</a>
|
77
|
+
<li><a href="#label-Example+Scripts">Example Scripts</a>
|
78
|
+
<li><a href="#label-Resources">Resources</a>
|
79
|
+
<li><a href="#label-To+Do">To Do</a>
|
80
|
+
<li><a href="#label-Bugs">Bugs</a>
|
81
|
+
<li><a href="#label-Features">Features</a>
|
82
|
+
<li><a href="#label-Documentation">Documentation</a>
|
83
|
+
<li><a href="#label-Tests">Tests</a>
|
84
|
+
<li><a href="#label-Support">Support</a>
|
85
|
+
<li><a href="#label-Administrivia">Administrivia</a>
|
86
|
+
<li><a href="#label-Copying">Copying</a>
|
87
|
+
<li><a href="#label-Recent+Changes">Recent Changes</a>
|
88
|
+
<li><a href="#label-Changes+for+2.0.5-3A">Changes for 2.0.5:</a>
|
89
|
+
<li><a href="#label-Changes+for+2.0.3-3A">Changes for 2.0.3:</a>
|
90
|
+
<li><a href="#label-Changes+for+2.0.2-3A">Changes for 2.0.2:</a>
|
91
|
+
<li><a href="#label-Changes+for+2.0.0-3A">Changes for 2.0.0:</a>
|
92
|
+
<li><a href="#label-Changes+for+1.2.0-3A">Changes for 1.2.0:</a>
|
93
|
+
<li><a href="#label-New+code+repository">New code repository</a>
|
94
|
+
<li><a href="#label-Changes+for+1.1.4-3A">Changes for 1.1.4:</a>
|
95
|
+
<li><a href="#label-Changes+for+1.1.3-3A">Changes for 1.1.3:</a>
|
96
|
+
<li><a href="#label-Changes+for+1.1.2-3A">Changes for 1.1.2:</a>
|
97
|
+
<li><a href="#label-Changes+for+1.1.1-3A">Changes for 1.1.1:</a>
|
98
|
+
<li><a href="#label-Changes+for+1.1.0-3A">Changes for 1.1.0:</a>
|
99
|
+
<li><a href="#label-Changes+for+1.0.0-3A">Changes for 1.0.0:</a>
|
100
|
+
<li><a href="#label-Changes+for+0.8.7-3A">Changes for 0.8.7:</a>
|
101
|
+
<li><a href="#label-Changes+for+0.8.6-3A">Changes for 0.8.6:</a>
|
102
|
+
<li><a href="#label-Changes+for+0.8.5-3A">Changes for 0.8.5:</a>
|
103
|
+
<li><a href="#label-Changes+for+0.8.4-3A">Changes for 0.8.4:</a>
|
104
|
+
<li><a href="#label-Changes+for+0.8.3-3A">Changes for 0.8.3:</a>
|
105
|
+
<li><a href="#label-Changes+for+0.8.2-3A">Changes for 0.8.2:</a>
|
106
|
+
<li><a href="#label-Changes+for+0.8.1-3A">Changes for 0.8.1:</a>
|
107
|
+
<li><a href="#label-Warranty">Warranty</a>
|
56
108
|
</ul>
|
57
|
-
</
|
109
|
+
</div>
|
58
110
|
|
59
|
-
|
60
|
-
<
|
111
|
+
|
112
|
+
<div id="project-metadata">
|
113
|
+
<div id="fileindex-section" class="nav-section">
|
114
|
+
<h3>Pages</h3>
|
61
115
|
|
62
116
|
<ul class="link-list">
|
63
117
|
|
64
|
-
<li><a href="./
|
65
|
-
|
66
|
-
<li><a href="./MIDI/ActiveSense.html">MIDI::ActiveSense</a>
|
67
|
-
|
68
|
-
<li><a href="./MIDI/ChannelEvent.html">MIDI::ChannelEvent</a>
|
69
|
-
|
70
|
-
<li><a href="./MIDI/ChannelPressure.html">MIDI::ChannelPressure</a>
|
71
|
-
|
72
|
-
<li><a href="./MIDI/Clock.html">MIDI::Clock</a>
|
73
|
-
|
74
|
-
<li><a href="./MIDI/Continue.html">MIDI::Continue</a>
|
75
|
-
|
76
|
-
<li><a href="./MIDI/Controller.html">MIDI::Controller</a>
|
77
|
-
|
78
|
-
<li><a href="./MIDI/Event.html">MIDI::Event</a>
|
79
|
-
|
80
|
-
<li><a href="./MIDI/IO.html">MIDI::IO</a>
|
81
|
-
|
82
|
-
<li><a href="./MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a>
|
83
|
-
|
84
|
-
<li><a href="./MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a>
|
85
|
-
|
86
|
-
<li><a href="./MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a>
|
87
|
-
|
88
|
-
<li><a href="./MIDI/KeySig.html">MIDI::KeySig</a>
|
89
|
-
|
90
|
-
<li><a href="./MIDI/MIDI.html">MIDI::MIDI</a>
|
91
|
-
|
92
|
-
<li><a href="./MIDI/MIDI/MIDI.html">MIDI::MIDI::MIDI</a>
|
93
|
-
|
94
|
-
<li><a href="./MIDI/MIDI/MIDI/Array.html">MIDI::MIDI::MIDI::Array</a>
|
95
|
-
|
96
|
-
<li><a href="./MIDI/Marker.html">MIDI::Marker</a>
|
118
|
+
<li><a href="./README_rdoc.html">README</a>
|
97
119
|
|
98
|
-
<li><a href="./
|
99
|
-
|
100
|
-
<li><a href="./MIDI/Measures.html">MIDI::Measures</a>
|
101
|
-
|
102
|
-
<li><a href="./MIDI/MetaEvent.html">MIDI::MetaEvent</a>
|
103
|
-
|
104
|
-
<li><a href="./MIDI/NoteEvent.html">MIDI::NoteEvent</a>
|
105
|
-
|
106
|
-
<li><a href="./MIDI/NoteOff.html">MIDI::NoteOff</a>
|
107
|
-
|
108
|
-
<li><a href="./MIDI/NoteOff.html">MIDI::NoteOffEvent</a>
|
109
|
-
|
110
|
-
<li><a href="./MIDI/NoteOn.html">MIDI::NoteOn</a>
|
111
|
-
|
112
|
-
<li><a href="./MIDI/NoteOn.html">MIDI::NoteOnEvent</a>
|
113
|
-
|
114
|
-
<li><a href="./MIDI/PitchBend.html">MIDI::PitchBend</a>
|
115
|
-
|
116
|
-
<li><a href="./MIDI/PolyPressure.html">MIDI::PolyPressure</a>
|
117
|
-
|
118
|
-
<li><a href="./MIDI/ProgramChange.html">MIDI::ProgramChange</a>
|
119
|
-
|
120
|
-
<li><a href="./MIDI/Realtime.html">MIDI::Realtime</a>
|
121
|
-
|
122
|
-
<li><a href="./MIDI/Sequence.html">MIDI::Sequence</a>
|
123
|
-
|
124
|
-
<li><a href="./MIDI/SongPointer.html">MIDI::SongPointer</a>
|
125
|
-
|
126
|
-
<li><a href="./MIDI/SongSelect.html">MIDI::SongSelect</a>
|
127
|
-
|
128
|
-
<li><a href="./MIDI/Start.html">MIDI::Start</a>
|
129
|
-
|
130
|
-
<li><a href="./MIDI/Stop.html">MIDI::Stop</a>
|
131
|
-
|
132
|
-
<li><a href="./MIDI/SystemCommon.html">MIDI::SystemCommon</a>
|
133
|
-
|
134
|
-
<li><a href="./MIDI/SystemExclusive.html">MIDI::SystemExclusive</a>
|
135
|
-
|
136
|
-
<li><a href="./MIDI/SystemReset.html">MIDI::SystemReset</a>
|
137
|
-
|
138
|
-
<li><a href="./MIDI/Tempo.html">MIDI::Tempo</a>
|
139
|
-
|
140
|
-
<li><a href="./MIDI/TimeSig.html">MIDI::TimeSig</a>
|
141
|
-
|
142
|
-
<li><a href="./MIDI/Track.html">MIDI::Track</a>
|
143
|
-
|
144
|
-
<li><a href="./MIDI/TuneRequest.html">MIDI::TuneRequest</a>
|
145
|
-
|
146
|
-
<li><a href="./MIDI/Utils.html">MIDI::Utils</a>
|
147
|
-
|
148
|
-
<li><a href="./IO.html">IO</a>
|
120
|
+
<li><a href="./TODO_rdoc.html">TODO</a>
|
149
121
|
|
150
122
|
</ul>
|
151
|
-
</
|
123
|
+
</div>
|
152
124
|
|
153
125
|
</div>
|
154
126
|
</nav>
|
155
127
|
|
156
|
-
<
|
157
|
-
|
158
|
-
<h1 id="label-midilib">midilib
|
128
|
+
<main role="main" aria-label="Page README.rdoc">
|
129
|
+
|
130
|
+
<h1 id="label-midilib">midilib<span><a href="#label-midilib">¶</a> <a href="#top">↑</a></span></h1>
|
159
131
|
|
160
132
|
<p>midilib is a pure Ruby <a href="MIDI.html">MIDI</a> library useful for
|
161
133
|
reading and writing standard <a href="MIDI.html">MIDI</a> files and
|
@@ -167,9 +139,9 @@ RubyGems.org page is <a
|
|
167
139
|
href="http://rubygems.org/gems/midilib">rubygems.org/gems/midilib</a>,
|
168
140
|
where you can also find all the RDoc documentation.</p>
|
169
141
|
|
170
|
-
<p>midilib is compatible with
|
142
|
+
<p>midilib is compatible with Ruby 1.8.x 1.9.x, and 2.x.</p>
|
171
143
|
|
172
|
-
<h2 id="label-Dependencies">Dependencies
|
144
|
+
<h2 id="label-Dependencies">Dependencies<span><a href="#label-Dependencies">¶</a> <a href="#top">↑</a></span></h2>
|
173
145
|
|
174
146
|
<p>midilib does not require any other packages. The test suite in the tests
|
175
147
|
directory requires the testing framework TestUnit, which comes with Ruby
|
@@ -180,9 +152,9 @@ href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>).</p>
|
|
180
152
|
Rakefile which requires Rake (<a
|
181
153
|
href="http://rake.rubyforge.org">rake.rubyforge.org</a>).</p>
|
182
154
|
|
183
|
-
<h2 id="label-Installation">Installation
|
155
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
184
156
|
|
185
|
-
<h3 id="label-RubyGems+Installation">RubyGems Installation
|
157
|
+
<h3 id="label-RubyGems+Installation">RubyGems Installation<span><a href="#label-RubyGems+Installation">¶</a> <a href="#top">↑</a></span></h3>
|
186
158
|
|
187
159
|
<p>To install midilib as a gem, type</p>
|
188
160
|
|
@@ -194,7 +166,7 @@ href="http://rake.rubyforge.org">rake.rubyforge.org</a>).</p>
|
|
194
166
|
|
195
167
|
<p>You may need root privileges to install or update the gem.</p>
|
196
168
|
|
197
|
-
<h3 id="label-Manual+Installation">Manual Installation
|
169
|
+
<h3 id="label-Manual+Installation">Manual Installation<span><a href="#label-Manual+Installation">¶</a> <a href="#top">↑</a></span></h3>
|
198
170
|
|
199
171
|
<p>After downloading and expanding the archive, you can install midilib with
|
200
172
|
the command</p>
|
@@ -207,49 +179,49 @@ the command</p>
|
|
207
179
|
|
208
180
|
<p>You may need root privileges to install.</p>
|
209
181
|
|
210
|
-
<h2 id="label-Testing">Testing
|
182
|
+
<h2 id="label-Testing">Testing<span><a href="#label-Testing">¶</a> <a href="#top">↑</a></span></h2>
|
211
183
|
|
212
184
|
<pre>% rake test</pre>
|
213
185
|
|
214
186
|
<p>runs all of the tests in the test directory.</p>
|
215
187
|
|
216
|
-
<h2 id="label-Overview">Overview
|
188
|
+
<h2 id="label-Overview">Overview<span><a href="#label-Overview">¶</a> <a href="#top">↑</a></span></h2>
|
217
189
|
|
218
190
|
<p>The midilib <a href="MIDI.html">MIDI</a> file reader only understands <a
|
219
191
|
href="MIDI.html">MIDI</a> file format 1, where a sequence is made up of
|
220
|
-
multiple tracks. It doesn
|
192
|
+
multiple tracks. It doesn't yet understand format 0 (a single track
|
221
193
|
containing all events) or format 2 (a collection of format 0 files in one
|
222
194
|
file).</p>
|
223
195
|
|
224
|
-
<
|
196
|
+
<h3 id="label-MIDI-3A-3ASequence"><a href="MIDI/Sequence.html">MIDI::Sequence</a><span><a href="#label-MIDI-3A-3ASequence">¶</a> <a href="#top">↑</a></span></h3>
|
225
197
|
|
226
198
|
<p>A sequence contains a collection of tracks and global information like the
|
227
|
-
sequence
|
199
|
+
sequence's pulses per quarter note (ppqn) and time signature.</p>
|
228
200
|
|
229
201
|
<p>The first track in a sequence is special; it holds meta-events like tempo
|
230
|
-
and sequence name. Don
|
202
|
+
and sequence name. Don't put any notes in this track.</p>
|
231
203
|
|
232
204
|
<p><a href="MIDI/Sequence.html">MIDI::Sequence</a> also contains some
|
233
|
-
convenience methods that let you set and retrieve the sequence
|
234
|
-
time signature, and to retrieve the first tempo event
|
235
|
-
value.</p>
|
205
|
+
convenience methods that let you set and retrieve the sequence's name,
|
206
|
+
the time signature, and to retrieve the first tempo event's
|
207
|
+
beats-per-minute value.</p>
|
236
208
|
|
237
209
|
<p>Normally instances of <a
|
238
210
|
href="MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a> and <a
|
239
211
|
href="MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a> are used when a
|
240
212
|
sequence reads itself from or writes itself to a <a
|
241
|
-
href="MIDI.html">MIDI</a> file. You can change that by setting a
|
242
|
-
reader_class or writer_class attributes. Instances of the
|
243
|
-
in those attributes are created and used whenever the
|
244
|
-
writes itself.</p>
|
213
|
+
href="MIDI.html">MIDI</a> file. You can change that by setting a
|
214
|
+
sequence's reader_class or writer_class attributes. Instances of the
|
215
|
+
classes contained in those attributes are created and used whenever the
|
216
|
+
sequence reads or writes itself.</p>
|
245
217
|
|
246
|
-
<h3 id="label-MIDI
|
218
|
+
<h3 id="label-MIDI-3A-3ATrack"><a href="MIDI/Track.html">MIDI::Track</a><span><a href="#label-MIDI-3A-3ATrack">¶</a> <a href="#top">↑</a></span></h3>
|
247
219
|
|
248
220
|
<p>A track contains an array of events.</p>
|
249
221
|
|
250
222
|
<p>When you modify the <code>events</code> array, make sure to call
|
251
223
|
recalc_times so each event gets its <code>time_from_start</code>
|
252
|
-
recalculated. You don
|
224
|
+
recalculated. You don't have to do that after every event you add; just
|
253
225
|
remember to do so before using the track in a way that expects the list of
|
254
226
|
events to be ordered correctly.</p>
|
255
227
|
|
@@ -259,13 +231,13 @@ href="MIDI.html">MIDI</a> file by a SeqReader but is <em>not</em> kept up
|
|
259
231
|
to date by any other methods. Specifically, if you add events to a track at
|
260
232
|
any other time, the bit mask will not be updated.</p>
|
261
233
|
|
262
|
-
<h3 id="label-MIDI
|
234
|
+
<h3 id="label-MIDI-3A-3AMeasure"><a href="MIDI/Measure.html">MIDI::Measure</a><span><a href="#label-MIDI-3A-3AMeasure">¶</a> <a href="#top">↑</a></span></h3>
|
263
235
|
|
264
236
|
<p>This class contains information about a measure from the sequence. Measure
|
265
237
|
data is based on the time signature information from the sequence and is
|
266
238
|
not stored in the sequence itself.</p>
|
267
239
|
|
268
|
-
<h3 id="label-MIDI
|
240
|
+
<h3 id="label-MIDI-3A-3AMeasures"><a href="MIDI/Measures.html">MIDI::Measures</a><span><a href="#label-MIDI-3A-3AMeasures">¶</a> <a href="#top">↑</a></span></h3>
|
269
241
|
|
270
242
|
<p>The class <a href="MIDI/Sequence.html">MIDI::Sequence</a> method
|
271
243
|
get_measures returns a <a href="MIDI/Measures.html">MIDI::Measures</a>
|
@@ -277,16 +249,16 @@ remade when events are deleted/added in the sequence.</p>
|
|
277
249
|
|
278
250
|
<p><a href="MIDI/Measure.html">MIDI::Measure</a> and <a
|
279
251
|
href="MIDI/Measures.html">MIDI::Measures</a> are brought to us by Jari
|
280
|
-
Williamsson <
|
252
|
+
Williamsson <jari.williamsson@mailbox.swipnet.se>, who also
|
281
253
|
contributed some improvements to the <a
|
282
254
|
href="MIDI/Event.html">MIDI::Event</a> and <a
|
283
255
|
href="MIDI/Track.html">MIDI::Track</a> classes.</p>
|
284
256
|
|
285
|
-
<h3 id="label-MIDI
|
257
|
+
<h3 id="label-MIDI-3A-3AEvent"><a href="MIDI/Event.html">MIDI::Event</a><span><a href="#label-MIDI-3A-3AEvent">¶</a> <a href="#top">↑</a></span></h3>
|
286
258
|
|
287
259
|
<p>Each event holds not only its delta time but also its time from the start
|
288
|
-
of the track. The track is responsible for recalculating its events
|
289
|
-
times. You can call <a
|
260
|
+
of the track. The track is responsible for recalculating its events'
|
261
|
+
start times. You can call <a
|
290
262
|
href="MIDI/Track.html#method-i-recalc_times">MIDI::Track#recalc_times</a>
|
291
263
|
to do so.</p>
|
292
264
|
|
@@ -295,30 +267,31 @@ various <a href="MIDI.html">MIDI</a> messages such as note on and off,
|
|
295
267
|
controller values, system exclusive data, and realtime bytes.</p>
|
296
268
|
|
297
269
|
<p><a href="MIDI/Realtime.html">MIDI::Realtime</a> events have delta values
|
298
|
-
and start times, just like all the other midilib event types do. (
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
href="MIDI
|
304
|
-
|
270
|
+
and start times, just like all the other midilib event types do. (MIDI real
|
271
|
+
time status bytes don't have delta times, but this way we can record
|
272
|
+
when in a track the realtime byte was received and should be sent. This is
|
273
|
+
useful for start/continue/stop events that control other devices, for
|
274
|
+
example.) Note that when a <a href="MIDI/Realtime.html">MIDI::Realtime</a>
|
275
|
+
event is written out to a <a href="MIDI.html">MIDI</a> file, the delta time
|
276
|
+
is not written.</p>
|
305
277
|
|
306
278
|
<p><a href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> events hold an array of
|
307
|
-
bytes named
|
308
|
-
marker, etc.) Though the
|
309
|
-
href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> helps with saving
|
310
|
-
accessing string. The <a
|
279
|
+
bytes named 'data'. Many meta events are string holders (text,
|
280
|
+
lyric, marker, etc.) Though the 'data' value is always an array of
|
281
|
+
bytes, <a href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> helps with saving
|
282
|
+
and accessing string. The <a
|
311
283
|
href="MIDI/MetaEvent.html#method-i-data_as_str">MIDI::MetaEvent#data_as_str</a>
|
312
|
-
method returns the data bytes as a string. When assigning to a meta
|
313
|
-
data, if you pass in a string it will get converted to an array
|
284
|
+
method returns the data bytes as a string. When assigning to a meta
|
285
|
+
event's data, if you pass in a string it will get converted to an array
|
286
|
+
of bytes.</p>
|
314
287
|
|
315
|
-
<h2 id="label-How+To+Use">How To Use
|
288
|
+
<h2 id="label-How+To+Use">How To Use<span><a href="#label-How+To+Use">¶</a> <a href="#top">↑</a></span></h2>
|
316
289
|
|
317
290
|
<p>The following examples show you how to use midilib to read, write, and
|
318
291
|
manipulate <a href="MIDI.html">MIDI</a> files and modify track events. See
|
319
292
|
also the files in the examples directory, which are described below.</p>
|
320
293
|
|
321
|
-
<h3 id="label-Reading+a+MIDI+File">Reading a <a href="MIDI.html">MIDI</a> File
|
294
|
+
<h3 id="label-Reading+a+MIDI+File">Reading a <a href="MIDI.html">MIDI</a> File<span><a href="#label-Reading+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
322
295
|
|
323
296
|
<p>To read a <a href="MIDI.html">MIDI</a> file, create a <a
|
324
297
|
href="MIDI/Sequence.html">MIDI::Sequence</a> object and call its read
|
@@ -330,13 +303,13 @@ track object, the total number of tracks and the number of the current
|
|
330
303
|
track that has just been read. This is useful for notifying the user of
|
331
304
|
progress, for example by updating a GUI progress bar.</p>
|
332
305
|
|
333
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
306
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqreader'</span>
|
334
307
|
|
335
308
|
<span class="ruby-comment"># Create a new, empty sequence.</span>
|
336
309
|
<span class="ruby-identifier">seq</span> = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>.<span class="ruby-identifier">new</span>()
|
337
310
|
|
338
311
|
<span class="ruby-comment"># Read the contents of a MIDI file into the sequence.</span>
|
339
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string"
|
312
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_midi_file.mid'</span>, <span class="ruby-string">'rb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
340
313
|
<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">track</span>, <span class="ruby-identifier">num_tracks</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">|</span>
|
341
314
|
<span class="ruby-comment"># Print something when each track is read.</span>
|
342
315
|
<span class="ruby-identifier">puts</span> <span class="ruby-node">"read track #{i} of #{num_tracks}"</span>
|
@@ -344,21 +317,21 @@ progress, for example by updating a GUI progress bar.</p>
|
|
344
317
|
}
|
345
318
|
</pre>
|
346
319
|
|
347
|
-
<h3 id="label-Writing+a+MIDI+File">Writing a <a href="MIDI.html">MIDI</a> File
|
320
|
+
<h3 id="label-Writing+a+MIDI+File">Writing a <a href="MIDI.html">MIDI</a> File<span><a href="#label-Writing+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
348
321
|
|
349
322
|
<p>To write a <a href="MIDI.html">MIDI</a> file, call the write method,
|
350
323
|
passing in an <a href="IO.html">IO</a> object.</p>
|
351
324
|
|
352
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
325
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqwriter'</span>
|
353
326
|
|
354
327
|
<span class="ruby-comment"># Start with a sequence that has something worth saving.</span>
|
355
328
|
<span class="ruby-identifier">seq</span> = <span class="ruby-identifier">read_or_create_seq_we_care_not_how</span>()
|
356
329
|
|
357
330
|
<span class="ruby-comment"># Write the sequence to a MIDI file.</span>
|
358
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string"
|
331
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_output_file.mid'</span>, <span class="ruby-string">'wb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">file</span>) }
|
359
332
|
</pre>
|
360
333
|
|
361
|
-
<h3 id="label-Editing+a+MIDI+File">Editing a <a href="MIDI.html">MIDI</a> File
|
334
|
+
<h3 id="label-Editing+a+MIDI+File">Editing a <a href="MIDI.html">MIDI</a> File<span><a href="#label-Editing+a+MIDI+File">¶</a> <a href="#top">↑</a></span></h3>
|
362
335
|
|
363
336
|
<p>Combining the last two examples, here is a script that reads a <a
|
364
337
|
href="MIDI.html">MIDI</a> file, transposes some events, and writes the
|
@@ -368,16 +341,16 @@ programatically manipulating <a href="MIDI.html">MIDI</a> data.</p>
|
|
368
341
|
<p>This code transposes all of the note events (note on, note off, and poly
|
369
342
|
pressure) on channel 5 down one octave.</p>
|
370
343
|
|
371
|
-
<h4 id="label-Transposing+One+Channel">Transposing One Channel
|
344
|
+
<h4 id="label-Transposing+One+Channel">Transposing One Channel<span><a href="#label-Transposing+One+Channel">¶</a> <a href="#top">↑</a></span></h4>
|
372
345
|
|
373
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string"
|
374
|
-
<span class="ruby-identifier">require</span> <span class="ruby-string"
|
346
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqreader'</span>
|
347
|
+
<span class="ruby-identifier">require</span> <span class="ruby-string">'midilib/io/seqwriter'</span>
|
375
348
|
|
376
349
|
<span class="ruby-comment"># Create a new, empty sequence.</span>
|
377
350
|
<span class="ruby-identifier">seq</span> = <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span>.<span class="ruby-identifier">new</span>()
|
378
351
|
|
379
352
|
<span class="ruby-comment"># Read the contents of a MIDI file into the sequence.</span>
|
380
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string"
|
353
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_input_file.mid'</span>, <span class="ruby-string">'rb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
381
354
|
<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">track</span>, <span class="ruby-identifier">num_tracks</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">|</span>
|
382
355
|
<span class="ruby-comment"># Print something when each track is read.</span>
|
383
356
|
<span class="ruby-identifier">puts</span> <span class="ruby-node">"read track #{i} of #{num_tracks}"</span>
|
@@ -397,52 +370,54 @@ pressure) on channel 5 down one octave.</p>
|
|
397
370
|
}
|
398
371
|
|
399
372
|
<span class="ruby-comment"># Write the sequence to a MIDI file.</span>
|
400
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string"
|
373
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">'my_output_file.mid'</span>, <span class="ruby-string">'wb'</span>) { <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">seq</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">file</span>) }
|
401
374
|
</pre>
|
402
375
|
|
403
|
-
<h3 id="label-Manipulating+tracks">Manipulating tracks
|
376
|
+
<h3 id="label-Manipulating+tracks">Manipulating tracks<span><a href="#label-Manipulating+tracks">¶</a> <a href="#top">↑</a></span></h3>
|
404
377
|
|
405
|
-
<p>If you modify a track
|
378
|
+
<p>If you modify a track's list of events directly, don't forget to
|
379
|
+
call <a
|
406
380
|
href="MIDI/Track.html#method-i-recalc_times">MIDI::Track#recalc_times</a>
|
407
381
|
when you are done.</p>
|
408
382
|
|
409
|
-
<pre>track
|
410
|
-
track
|
411
|
-
track
|
412
|
-
track
|
383
|
+
<pre class="ruby"><span class="ruby-identifier">track</span>.<span class="ruby-identifier">events</span>[<span class="ruby-value">42</span>, <span class="ruby-value">1</span>] = <span class="ruby-identifier">array_of_events</span>
|
384
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">events</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">an_event</span>
|
385
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">array_of_events</span>)
|
386
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">recalc_times</span>
|
387
|
+
</pre>
|
413
388
|
|
414
|
-
<h3 id="label-Calculating+delta+times">Calculating delta times
|
389
|
+
<h3 id="label-Calculating+delta+times">Calculating delta times<span><a href="#label-Calculating+delta+times">¶</a> <a href="#top">↑</a></span></h3>
|
415
390
|
|
416
391
|
<p>A few methods in <a href="MIDI/Sequence.html">MIDI::Sequence</a> make it
|
417
392
|
easier to calculate the delta times that represent note lengths. <a
|
418
393
|
href="MIDI/Sequence.html#method-i-length_to_delta">MIDI::Sequence#length_to_delta</a>
|
419
394
|
takes a note length (a multiple of a quarter note) and returns the delta
|
420
|
-
time given the sequence
|
421
|
-
is a quarter note, 1.0/32.0 is a 32nd note (use floating-point
|
422
|
-
avoid integer rounding), 1.5 is a dotted quarter, etc. See the
|
395
|
+
time given the sequence's current ppqn (pulses per quarter note)
|
396
|
+
setting. 1 is a quarter note, 1.0/32.0 is a 32nd note (use floating-point
|
397
|
+
numbers to avoid integer rounding), 1.5 is a dotted quarter, etc. See the
|
423
398
|
documentation for that method for more information.</p>
|
424
399
|
|
425
400
|
<p><a
|
426
401
|
href="MIDI/Sequence.html#method-i-note_to_length">MIDI::Sequence#note_to_length</a>
|
427
402
|
takes a note name and returns a length value (again, as a multiple of a
|
428
403
|
quarter note). Legal note names are those found in
|
429
|
-
MIDI::Sequence::NOTE_TO_LENGTH, and may begin with
|
430
|
-
|
431
|
-
|
404
|
+
MIDI::Sequence::NOTE_TO_LENGTH, and may begin with “dotted” and/or end with
|
405
|
+
“triplet”. For example, “whole”, “sixteenth”, “32nd”, “quarter triplet”,
|
406
|
+
“dotted 16th”, and “dotted 8th triplet” are all legal note names.</p>
|
432
407
|
|
433
408
|
<p>Finally, <a
|
434
409
|
href="MIDI/Sequence.html#method-i-note_to_delta">MIDI::Sequence#note_to_delta</a>
|
435
410
|
takes a note name and returns a delta time. It does this by calling
|
436
411
|
note_to_length, then passing the result to length_to_delta.</p>
|
437
412
|
|
438
|
-
<h3 id="label-Example+Scripts">Example Scripts
|
413
|
+
<h3 id="label-Example+Scripts">Example Scripts<span><a href="#label-Example+Scripts">¶</a> <a href="#top">↑</a></span></h3>
|
439
414
|
|
440
415
|
<p>Here are short descriptions of each of the examples found in the examples
|
441
416
|
directory.</p>
|
442
417
|
<ul><li>
|
443
418
|
<p>examples/from_scratch.rb shows you how to create a new sequence from
|
444
419
|
scratch and save it to a <a href="MIDI.html">MIDI</a> file. It creates a
|
445
|
-
file called
|
420
|
+
file called 'from_scratch.mid'.</p>
|
446
421
|
</li><li>
|
447
422
|
<p>examples/seq2text.rb dumps a <a href="MIDI.html">MIDI</a> file as text. It
|
448
423
|
reads in a sequence and uses the to_s method of each event.</p>
|
@@ -457,11 +432,11 @@ pressure) on a specified channel by a specified amount.</p>
|
|
457
432
|
<p>There is also one <a href="MIDI.html">MIDI</a> file, examples/NoFences.mid.
|
458
433
|
It is a little pop ditty I wrote. The instruments in this file use General
|
459
434
|
<a href="MIDI.html">MIDI</a> patch numbers and drum note assignments. Since
|
460
|
-
I don
|
435
|
+
I don't normally use GM patches, the sounds used here are at best
|
461
436
|
approximations of the sounds I use.</p>
|
462
437
|
</li></ul>
|
463
438
|
|
464
|
-
<h2 id="label-Resources">Resources
|
439
|
+
<h2 id="label-Resources">Resources<span><a href="#label-Resources">¶</a> <a href="#top">↑</a></span></h2>
|
465
440
|
|
466
441
|
<p>The Ruby Web site (<a
|
467
442
|
href="http://www.ruby-lang.org/en/index.html">www.ruby-lang.org/en/index.html</a>)
|
@@ -469,7 +444,7 @@ contains an introduction to Ruby, the Ruby Application Archive (RAA) at <a
|
|
469
444
|
href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>, and pointers to more
|
470
445
|
information.</p>
|
471
446
|
|
472
|
-
<p><cite>Programming Ruby, The Pragmatic Programmer
|
447
|
+
<p><cite>Programming Ruby, The Pragmatic Programmer's
|
473
448
|
Guide</cite>, by David Thomas and Andrew Hunt, is a well-written and
|
474
449
|
practical introduction to Ruby. Its Web page at <a
|
475
450
|
href="http://www.rubycentral.com/book">www.rubycentral.com/book</a> also
|
@@ -478,29 +453,29 @@ available online, I encourage you to purchase a copy of the latest edition.</p>
|
|
478
453
|
|
479
454
|
<p>A description of the <a href="MIDI.html">MIDI</a> file format can be found
|
480
455
|
in a few places such as <a
|
481
|
-
href="http://www.borg.com/~jglatt/tech/midifile.htm
|
456
|
+
href="http://www.borg.com/~jglatt/tech/midifile.htm">www.borg.com/~jglatt/tech/midifile.htm</a>.</p>
|
482
457
|
|
483
458
|
<p>The <a href="MIDI.html">MIDI</a> message reference at <a
|
484
459
|
href="http://www.jimmenard.com/midi_ref.html">www.jimmenard.com/midi_ref.html</a>
|
485
460
|
describes the format of <a href="MIDI.html">MIDI</a> commands.</p>
|
486
461
|
|
487
|
-
<h1 id="label-To+Do">To Do
|
462
|
+
<h1 id="label-To+Do">To Do<span><a href="#label-To+Do">¶</a> <a href="#top">↑</a></span></h1>
|
488
463
|
|
489
|
-
<h2 id="label-Bugs">Bugs
|
464
|
+
<h2 id="label-Bugs">Bugs<span><a href="#label-Bugs">¶</a> <a href="#top">↑</a></span></h2>
|
490
465
|
|
491
|
-
<p>No known bugs. (If that
|
466
|
+
<p>No known bugs. (If that's not a challenge, I don't know what is.)</p>
|
492
467
|
|
493
|
-
<h2 id="label-Features">Features
|
468
|
+
<h2 id="label-Features">Features<span><a href="#label-Features">¶</a> <a href="#top">↑</a></span></h2>
|
494
469
|
<ul><li>
|
495
470
|
<p><code>print_decimal_numbers</code> and
|
496
471
|
<code>print_channel_numbers_from_one</code> should be associated with
|
497
472
|
sequence, or perhaps track, not event.</p>
|
498
473
|
</li><li>
|
499
|
-
<p>Method to translate event
|
500
|
-
start.</p>
|
474
|
+
<p>Method to translate event's time_from_start to number of milliseconds
|
475
|
+
from start.</p>
|
501
476
|
</li><li>
|
502
|
-
<p>Swing quantizing. (Implied by list email from Carl Youngblood
|
503
|
-
carl.youngblood.com>)</p>
|
477
|
+
<p>Swing quantizing. (Implied by list email from Carl Youngblood
|
478
|
+
<carl.youngblood@gmail.com>)</p>
|
504
479
|
</li><li>
|
505
480
|
<p>Implement key signature in SeqReader.</p>
|
506
481
|
</li><li>
|
@@ -509,17 +484,17 @@ carl.youngblood.com>)</p>
|
|
509
484
|
<p>Format 2 files(?).</p>
|
510
485
|
</li></ul>
|
511
486
|
|
512
|
-
<h2 id="label-Documentation">Documentation
|
487
|
+
<h2 id="label-Documentation">Documentation<span><a href="#label-Documentation">¶</a> <a href="#top">↑</a></span></h2>
|
513
488
|
<ul><li>
|
514
489
|
<p>Write better docs.</p>
|
515
490
|
</li></ul>
|
516
491
|
|
517
|
-
<h2 id="label-Tests">Tests
|
492
|
+
<h2 id="label-Tests">Tests<span><a href="#label-Tests">¶</a> <a href="#top">↑</a></span></h2>
|
518
493
|
<ul><li>
|
519
|
-
<p>Tests for Noah Thorp
|
494
|
+
<p>Tests for Noah Thorp's midilib bug fixes.</p>
|
520
495
|
</li></ul>
|
521
496
|
|
522
|
-
<h1 id="label-Support">Support
|
497
|
+
<h1 id="label-Support">Support<span><a href="#label-Support">¶</a> <a href="#top">↑</a></span></h1>
|
523
498
|
<ul><li>
|
524
499
|
<p>Visit the forums, bug list, and mailing list pages at <a
|
525
500
|
href="http://rubyforge.org/projects/midilib">rubyforge.org/projects/midilib</a></p>
|
@@ -530,47 +505,52 @@ href="mailto:jim@jimmenard.com">jim@jimmenard.com</a></p>
|
|
530
505
|
<p>Ask on the ruby-talk mailing list</p>
|
531
506
|
</li></ul>
|
532
507
|
|
533
|
-
<h1 id="label-Administrivia">Administrivia
|
508
|
+
<h1 id="label-Administrivia">Administrivia<span><a href="#label-Administrivia">¶</a> <a href="#top">↑</a></span></h1>
|
534
509
|
<dl class="rdoc-list note-list"><dt>Author
|
535
510
|
<dd>
|
536
511
|
<p>Jim Menard (<a href="mailto:jim@jimmenard.com">jim@jimmenard.com</a>)</p>
|
537
512
|
</dd><dt>Copyright
|
538
513
|
<dd>
|
539
|
-
<p>Copyright
|
514
|
+
<p>Copyright © 2003-2013 Jim Menard</p>
|
540
515
|
</dd><dt>License
|
541
516
|
<dd>
|
542
517
|
<p>Distributed under the same license as Ruby.</p>
|
543
518
|
</dd></dl>
|
544
519
|
|
545
|
-
<h2 id="label-Copying">Copying
|
520
|
+
<h2 id="label-Copying">Copying<span><a href="#label-Copying">¶</a> <a href="#top">↑</a></span></h2>
|
546
521
|
|
547
522
|
<p>midilib is copyrighted free software by Jim Menard and is released under
|
548
523
|
the same license as Ruby. See the Ruby license at <a
|
549
|
-
href="http://www.ruby-lang.org/en/LICENSE.txt
|
524
|
+
href="http://www.ruby-lang.org/en/LICENSE.txt">www.ruby-lang.org/en/LICENSE.txt</a>.</p>
|
550
525
|
|
551
526
|
<p>midilib may be freely copied in its entirety providing this notice, all
|
552
527
|
source code, all documentation, and all other files are included.</p>
|
553
528
|
|
554
|
-
<p>midilib is Copyright
|
529
|
+
<p>midilib is Copyright © 2003-2013 by Jim Menard.</p>
|
555
530
|
|
556
|
-
<p>The song
|
557
|
-
examples/NoFences.mid is Copyright
|
531
|
+
<p>The song “No Fences” contained in the <a href="MIDI.html">MIDI</a> file
|
532
|
+
examples/NoFences.mid is Copyright © 1992 by Jim Menard
|
558
533
|
(jim@jimmenard.com). It may be freely used for non-commercial purposes as
|
559
534
|
long as the author is given credit.</p>
|
560
535
|
|
561
|
-
<h2 id="label-Recent+Changes">Recent Changes
|
536
|
+
<h2 id="label-Recent+Changes">Recent Changes<span><a href="#label-Recent+Changes">¶</a> <a href="#top">↑</a></span></h2>
|
537
|
+
|
538
|
+
<h3 id="label-Changes+for+2.0.5-3A">Changes for 2.0.5:<span><a href="#label-Changes+for+2.0.5-3A">¶</a> <a href="#top">↑</a></span></h3>
|
539
|
+
|
540
|
+
<p>Updated <code>install.rb</code> to work with newer versions of Ruby by
|
541
|
+
using <code>fileutils</code> instead of <code>ftools</code>.</p>
|
562
542
|
|
563
|
-
<h3 id="label-Changes+for+2.0.3
|
543
|
+
<h3 id="label-Changes+for+2.0.3-3A">Changes for 2.0.3:<span><a href="#label-Changes+for+2.0.3-3A">¶</a> <a href="#top">↑</a></span></h3>
|
564
544
|
|
565
545
|
<p>New <a
|
566
546
|
href="MIDI/Sequence.html#method-i-pulses_to_seconds">MIDI::Sequence#pulses_to_seconds</a>
|
567
547
|
method.</p>
|
568
548
|
|
569
|
-
<h3 id="label-Changes+for+2.0.2
|
549
|
+
<h3 id="label-Changes+for+2.0.2-3A">Changes for 2.0.2:<span><a href="#label-Changes+for+2.0.2-3A">¶</a> <a href="#top">↑</a></span></h3>
|
570
550
|
|
571
551
|
<p>Stop monkeypatching Array in <a href="MIDI/Track.html">MIDI::Track</a>.</p>
|
572
552
|
|
573
|
-
<h3 id="label-Changes+for+2.0.0
|
553
|
+
<h3 id="label-Changes+for+2.0.0-3A">Changes for 2.0.0:<span><a href="#label-Changes+for+2.0.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
574
554
|
|
575
555
|
<p><a href="MIDI/NoteOn.html">MIDI::NoteOnEvent</a> and <a
|
576
556
|
href="MIDI/NoteOff.html">MIDI::NoteOffEvent</a> renamed to <a
|
@@ -581,17 +561,18 @@ for a while.</p>
|
|
581
561
|
<p>The <a href="MIDI/Event.html">MIDI::Event</a> boolean methods like meta?
|
582
562
|
and note? have been removed. Use the event classes themselves (for example,
|
583
563
|
<a href="MIDI/MetaEvent.html">MIDI::MetaEvent</a> === my_event or
|
584
|
-
my_event.kind_of?(
|
585
|
-
|
586
|
-
|
587
|
-
<pre>case my_event
|
588
|
-
when MIDI
|
589
|
-
do_this()
|
590
|
-
when MIDI
|
591
|
-
do_that()
|
592
|
-
end</
|
564
|
+
my_event.kind_of?(MIDI::MetaEvent)). Case statements that use classes work,
|
565
|
+
too:</p>
|
566
|
+
|
567
|
+
<pre class="ruby"><span class="ruby-keyword">case</span> <span class="ruby-identifier">my_event</span>
|
568
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">NoteEvent</span> <span class="ruby-comment"># superclass of note on, note off, poly press</span>
|
569
|
+
<span class="ruby-identifier">do_this</span>()
|
570
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">MIDI</span><span class="ruby-operator">::</span><span class="ruby-constant">Controller</span>
|
571
|
+
<span class="ruby-identifier">do_that</span>()
|
572
|
+
<span class="ruby-keyword">end</span>
|
573
|
+
</pre>
|
593
574
|
|
594
|
-
<p>Introduced Adam Murray
|
575
|
+
<p>Introduced Adam Murray's stable sorting code for <a
|
595
576
|
href="MIDI/Track.html#method-i-recalc_delta_from_times">MIDI::Track#recalc_delta_from_times</a>.
|
596
577
|
See <a
|
597
578
|
href="http://wiki.github.com/adamjmurray/cosy/midilib-notes">wiki.github.com/adamjmurray/cosy/midilib-notes</a>
|
@@ -606,28 +587,28 @@ and recalc_delta_from_times sorts the events before doing anything else.</p>
|
|
606
587
|
|
607
588
|
<p>MIDI::Tempo#mpq_to_bpm now returns a float.</p>
|
608
589
|
|
609
|
-
<h3 id="label-Changes+for+1.2.0
|
590
|
+
<h3 id="label-Changes+for+1.2.0-3A">Changes for 1.2.0:<span><a href="#label-Changes+for+1.2.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
610
591
|
|
611
592
|
<p>Use byte arrays instead of strings for passing around data. All tests now
|
612
593
|
pass for both Ruby 1.8.X and 1.9.X.</p>
|
613
594
|
|
614
|
-
<h3 id="label-New+code+repository">New code repository
|
595
|
+
<h3 id="label-New+code+repository">New code repository<span><a href="#label-New+code+repository">¶</a> <a href="#top">↑</a></span></h3>
|
615
596
|
|
616
597
|
<p>The midilib code is now hosted at Github (<a
|
617
598
|
href="http://github.com/jimm/midilib">github.com/jimm/midilib</a>).</p>
|
618
599
|
|
619
|
-
<h3 id="label-Changes+for+1.1.4
|
600
|
+
<h3 id="label-Changes+for+1.1.4-3A">Changes for 1.1.4:<span><a href="#label-Changes+for+1.1.4-3A">¶</a> <a href="#top">↑</a></span></h3>
|
620
601
|
<ul><li>
|
621
602
|
<p>Fixed a bug in KeySig.data_as_bytes. Thanks to Noah Thorp for finding this
|
622
603
|
and the bug fixed in 1.1.3.</p>
|
623
604
|
</li></ul>
|
624
605
|
|
625
|
-
<h3 id="label-Changes+for+1.1.3
|
606
|
+
<h3 id="label-Changes+for+1.1.3-3A">Changes for 1.1.3:<span><a href="#label-Changes+for+1.1.3-3A">¶</a> <a href="#top">↑</a></span></h3>
|
626
607
|
<ul><li>
|
627
608
|
<p>Fixed the way midilib detects the behavior of IO.getc.</p>
|
628
609
|
</li></ul>
|
629
610
|
|
630
|
-
<h3 id="label-Changes+for+1.1.2
|
611
|
+
<h3 id="label-Changes+for+1.1.2-3A">Changes for 1.1.2:<span><a href="#label-Changes+for+1.1.2-3A">¶</a> <a href="#top">↑</a></span></h3>
|
631
612
|
<ul><li>
|
632
613
|
<p>Define <a
|
633
614
|
href="MIDI/IO/MIDIFile.html#method-i-getc">MIDI::IO::MIDIFile#getc</a>
|
@@ -635,35 +616,35 @@ differently for different Ruby versions, instead of checking for
|
|
635
616
|
String.bytes every time we read a byte.</p>
|
636
617
|
</li></ul>
|
637
618
|
|
638
|
-
<h3 id="label-Changes+for+1.1.1
|
619
|
+
<h3 id="label-Changes+for+1.1.1-3A">Changes for 1.1.1:<span><a href="#label-Changes+for+1.1.1-3A">¶</a> <a href="#top">↑</a></span></h3>
|
639
620
|
<ul><li>
|
640
621
|
<p>Make <a
|
641
622
|
href="MIDI/IO/MIDIFile.html#method-i-getc">MIDI::IO::MIDIFile#getc</a> do
|
642
623
|
the right thing for both Ruby 1.8 and 1.9.</p>
|
643
624
|
</li></ul>
|
644
625
|
|
645
|
-
<h3 id="label-Changes+for+1.1.0
|
626
|
+
<h3 id="label-Changes+for+1.1.0-3A">Changes for 1.1.0:<span><a href="#label-Changes+for+1.1.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
646
627
|
<ul><li>
|
647
628
|
<p>Added test/test.mid to list of files to be included when packaging midifile
|
648
629
|
for distribution.</p>
|
649
630
|
</li></ul>
|
650
631
|
|
651
|
-
<h3 id="label-Changes+for+1.0.0
|
632
|
+
<h3 id="label-Changes+for+1.0.0-3A">Changes for 1.0.0:<span><a href="#label-Changes+for+1.0.0-3A">¶</a> <a href="#top">↑</a></span></h3>
|
652
633
|
<ul><li>
|
653
634
|
<p>Fixed the bug in Track#recalc_delta_from_times found by Christopher Rose.</p>
|
654
635
|
</li></ul>
|
655
636
|
|
656
|
-
<h3 id="label-Changes+for+0.8.7
|
637
|
+
<h3 id="label-Changes+for+0.8.7-3A">Changes for 0.8.7:<span><a href="#label-Changes+for+0.8.7-3A">¶</a> <a href="#top">↑</a></span></h3>
|
657
638
|
<ul><li>
|
658
639
|
<p>Fixed the misspelled POLY_PRESSURE constant, thanks to Mario Pehle.</p>
|
659
640
|
</li></ul>
|
660
641
|
|
661
|
-
<h3 id="label-Changes+for+0.8.6
|
642
|
+
<h3 id="label-Changes+for+0.8.6-3A">Changes for 0.8.6:<span><a href="#label-Changes+for+0.8.6-3A">¶</a> <a href="#top">↑</a></span></h3>
|
662
643
|
<ul><li>
|
663
644
|
<p>Added missing test/test.mid.</p>
|
664
645
|
</li></ul>
|
665
646
|
|
666
|
-
<h3 id="label-Changes+for+0.8.5
|
647
|
+
<h3 id="label-Changes+for+0.8.5-3A">Changes for 0.8.5:<span><a href="#label-Changes+for+0.8.5-3A">¶</a> <a href="#top">↑</a></span></h3>
|
667
648
|
<ul><li>
|
668
649
|
<p>Fixed bugs in <a href="MIDI/PitchBend.html">MIDI::PitchBend</a> reading and
|
669
650
|
writing, thanks to Emanuel Borsboom.</p>
|
@@ -673,14 +654,14 @@ href="MIDI/Track.html#method-i-quantize">MIDI::Track#quantize</a>.</p>
|
|
673
654
|
</li><li>
|
674
655
|
<p>The argument to <a
|
675
656
|
href="MIDI/Track.html#method-i-quantize">MIDI::Track#quantize</a> has
|
676
|
-
changed: it is now either a note name (
|
657
|
+
changed: it is now either a note name (“sixteenth”, “32nd”, “8th triplet”)
|
677
658
|
or a length (1 = quarter, 0.25 = sixteenth). This is a drastic change that
|
678
659
|
will break all previous calls to quantize. However, since that method was
|
679
|
-
broken already, I don
|
660
|
+
broken already, I don't feel it's a burden to anybody to change the
|
680
661
|
arguments.</p>
|
681
662
|
</li></ul>
|
682
663
|
|
683
|
-
<h3 id="label-Changes+for+0.8.4
|
664
|
+
<h3 id="label-Changes+for+0.8.4-3A">Changes for 0.8.4:<span><a href="#label-Changes+for+0.8.4-3A">¶</a> <a href="#top">↑</a></span></h3>
|
684
665
|
<ul><li>
|
685
666
|
<p>Realtime status bytes now set @is_realtime to true and return true when
|
686
667
|
realtime? is called.</p>
|
@@ -692,28 +673,28 @@ system? is called, not just system exclusive events.</p>
|
|
692
673
|
manually.</p>
|
693
674
|
</li><li>
|
694
675
|
<p>New <a href="MIDI/Sequence.html">MIDI::Sequence</a> methods that turn note
|
695
|
-
length names like
|
676
|
+
length names like “32nd”, “dotted quarter”, and “16th triplet” into delta
|
696
677
|
times. See the docs below and MIDI::Sequence::length_to_delta,
|
697
678
|
MIDI::Sequence::note_to_length, and MIDI::Sequence::note_to_delta.</p>
|
698
679
|
</li></ul>
|
699
680
|
|
700
|
-
<h3 id="label-Changes+for+0.8.3
|
681
|
+
<h3 id="label-Changes+for+0.8.3-3A">Changes for 0.8.3:<span><a href="#label-Changes+for+0.8.3-3A">¶</a> <a href="#top">↑</a></span></h3>
|
701
682
|
<ul><li>
|
702
683
|
<p>Added <a
|
703
684
|
href="MIDI/NoteEvent.html#method-i-note_to_s">MIDI::NoteEvent#note_to_s</a>,
|
704
|
-
which returns note name as a string like
|
685
|
+
which returns note name as a string like “C4” or “F#6”.</p>
|
705
686
|
</li><li>
|
706
687
|
<p>Added new boolean attributes to MIDI::Event: @print_decimal_numbers and
|
707
688
|
@print_note_names. These are used by all Event to_s methods. See
|
708
689
|
examples/seq2text.rb for an example.</p>
|
709
690
|
</li></ul>
|
710
691
|
|
711
|
-
<h3 id="label-Changes+for+0.8.2
|
692
|
+
<h3 id="label-Changes+for+0.8.2-3A">Changes for 0.8.2:<span><a href="#label-Changes+for+0.8.2-3A">¶</a> <a href="#top">↑</a></span></h3>
|
712
693
|
<ul><li>
|
713
694
|
<p>Changed MIDI::MetaEvent.type to MIDI::MetaEvent.event_type to avoid runtime
|
714
695
|
complaints about Object#type calls.</p>
|
715
696
|
</li><li>
|
716
|
-
<p>Added
|
697
|
+
<p>Added 'b' binary flag to file open modes for Windows.</p>
|
717
698
|
</li><li>
|
718
699
|
<p>Fixed $LOAD_PATH in example files.</p>
|
719
700
|
</li><li>
|
@@ -722,30 +703,29 @@ complaints about Object#type calls.</p>
|
|
722
703
|
<p>Fixed other example script bugs.</p>
|
723
704
|
</li></ul>
|
724
705
|
|
725
|
-
<h3 id="label-Changes+for+0.8.1
|
706
|
+
<h3 id="label-Changes+for+0.8.1-3A">Changes for 0.8.1:<span><a href="#label-Changes+for+0.8.1-3A">¶</a> <a href="#top">↑</a></span></h3>
|
726
707
|
<ul><li>
|
727
708
|
<p>Fixed track sorting.</p>
|
728
709
|
</li><li>
|
729
|
-
<p>Fixed track
|
710
|
+
<p>Fixed track's recalc_delta_from_times method.</p>
|
730
711
|
</li><li>
|
731
712
|
<p>Fixed event quantization.</p>
|
732
713
|
</li><li>
|
733
714
|
<p>More tests and documentation.</p>
|
734
715
|
</li></ul>
|
735
716
|
|
736
|
-
<h2 id="label-Warranty">Warranty
|
717
|
+
<h2 id="label-Warranty">Warranty<span><a href="#label-Warranty">¶</a> <a href="#top">↑</a></span></h2>
|
737
718
|
|
738
|
-
<p>This software is provided
|
719
|
+
<p>This software is provided “as is” and without any express or implied
|
739
720
|
warranties, including, without limitation, the implied warranties of
|
740
721
|
merchantability and fitness for a particular purpose.</p>
|
741
|
-
|
742
|
-
</div>
|
722
|
+
</main>
|
743
723
|
|
744
724
|
|
745
725
|
|
746
|
-
<footer id="validator-badges">
|
747
|
-
<p><a href="http://validator.w3.org/check/referer">
|
748
|
-
<p>Generated by <a href="
|
749
|
-
<p>
|
726
|
+
<footer id="validator-badges" role="contentinfo">
|
727
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
728
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
729
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
750
730
|
</footer>
|
751
731
|
|