midilib 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7ad7b3f46a7550efe7a5f33bebc63280704ad12
|
4
|
+
data.tar.gz: 7b03d6a94f4e8de161e54f650bfaa07c325df930
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 626f1286f221899c310571c26f60c1d57abbf51694a5f13b3b2e56d038763388db63e799ecda03bf0d874c84ea85390ea122e3ecab2b6762bff0c5aaa4faf79c
|
7
|
+
data.tar.gz: 088f6fba5f281fd024089f7f919995cd4653abc1f0ee3361fbd0cc3ccb43ebb7120efe4b38e5cf76449fe65072cff8f18376368e7507216a94c3714d386728dd
|
data/README.rdoc
CHANGED
@@ -8,7 +8,7 @@ http://github.com/jimm/midilib and the RubyGems.org page is
|
|
8
8
|
http://rubygems.org/gems/midilib, where you can also find all the RDoc
|
9
9
|
documentation.
|
10
10
|
|
11
|
-
midilib is compatible with
|
11
|
+
midilib is compatible with Ruby 1.8.x 1.9.x, and 2.x.
|
12
12
|
|
13
13
|
|
14
14
|
== Dependencies
|
@@ -60,7 +60,7 @@ sequence is made up of multiple tracks. It doesn't yet understand format 0
|
|
60
60
|
(a single track containing all events) or format 2 (a collection of format 0
|
61
61
|
files in one file).
|
62
62
|
|
63
|
-
|
63
|
+
=== MIDI::Sequence
|
64
64
|
|
65
65
|
A sequence contains a collection of tracks and global information like the
|
66
66
|
sequence's pulses per quarter note (ppqn) and time signature.
|
@@ -314,7 +314,7 @@ describes the format of MIDI commands.
|
|
314
314
|
= Administrivia
|
315
315
|
|
316
316
|
Author:: Jim Menard (mailto:jim@jimmenard.com)
|
317
|
-
Copyright:: Copyright (c) 2003-
|
317
|
+
Copyright:: Copyright (c) 2003-2013 Jim Menard
|
318
318
|
License:: Distributed under the same license as Ruby.
|
319
319
|
|
320
320
|
|
@@ -327,7 +327,7 @@ http://www.ruby-lang.org/en/LICENSE.txt.
|
|
327
327
|
midilib may be freely copied in its entirety providing this notice, all
|
328
328
|
source code, all documentation, and all other files are included.
|
329
329
|
|
330
|
-
midilib is Copyright (c) 2003-
|
330
|
+
midilib is Copyright (c) 2003-2013 by Jim Menard.
|
331
331
|
|
332
332
|
The song "No Fences" contained in the MIDI file examples/NoFences.mid is
|
333
333
|
Copyright (c) 1992 by Jim Menard (jim@jimmenard.com). It may be freely used
|
@@ -336,6 +336,11 @@ for non-commercial purposes as long as the author is given credit.
|
|
336
336
|
|
337
337
|
== Recent Changes
|
338
338
|
|
339
|
+
=== Changes for 2.0.5:
|
340
|
+
|
341
|
+
Updated +install.rb+ to work with newer versions of Ruby by using
|
342
|
+
+fileutils+ instead of +ftools+.
|
343
|
+
|
339
344
|
=== Changes for 2.0.3:
|
340
345
|
|
341
346
|
New MIDI::Sequence.pulses_to_seconds method.
|
data/Rakefile
CHANGED
@@ -41,6 +41,7 @@ spec = Gem::Specification.new do |s|
|
|
41
41
|
s.email = 'jim@jimmenard.com'
|
42
42
|
s.homepage = 'http://github.com/jimm/midilib'
|
43
43
|
s.rubyforge_project = PROJECT_NAME
|
44
|
+
s.license = 'Ruby'
|
44
45
|
|
45
46
|
s.summary = "MIDI file and event manipulation library"
|
46
47
|
s.description = <<EOF
|
@@ -79,12 +80,7 @@ task :publish => [:rdoc, :package] do
|
|
79
80
|
end
|
80
81
|
|
81
82
|
if RUBY_VERSION >= '1.9'
|
82
|
-
Rake::TestTask.new
|
83
|
-
t.libs << File.join(File.dirname(__FILE__), 'test')
|
84
|
-
t.libs << File.join(File.dirname(__FILE__), 'lib')
|
85
|
-
t.ruby_opts << '-rubygems'
|
86
|
-
t.pattern = "test/**/test_*.rb"
|
87
|
-
end
|
83
|
+
Rake::TestTask.new
|
88
84
|
else
|
89
85
|
task :test do
|
90
86
|
Rake::run_tests
|
data/examples/from_scratch.rb
CHANGED
@@ -40,10 +40,10 @@ track.events << Controller.new(0, CC_VOLUME, 127)
|
|
40
40
|
# delta time length of a single quarter note.
|
41
41
|
track.events << ProgramChange.new(0, 1, 0)
|
42
42
|
quarter_note_length = seq.note_to_delta('quarter')
|
43
|
-
[0, 2, 4, 5, 7, 9, 11, 12].each
|
43
|
+
[0, 2, 4, 5, 7, 9, 11, 12].each do |offset|
|
44
44
|
track.events << NoteOn.new(0, 64 + offset, 127, 0)
|
45
45
|
track.events << NoteOff.new(0, 64 + offset, 127, quarter_note_length)
|
46
|
-
|
46
|
+
end
|
47
47
|
|
48
48
|
# Calling recalc_times is not necessary, because that only sets the events'
|
49
49
|
# start times, which are not written out to the MIDI file. The delta times are
|
@@ -51,6 +51,4 @@ quarter_note_length = seq.note_to_delta('quarter')
|
|
51
51
|
|
52
52
|
# track.recalc_times
|
53
53
|
|
54
|
-
File.open('from_scratch.mid', 'wb') { | file
|
55
|
-
seq.write(file)
|
56
|
-
}
|
54
|
+
File.open('from_scratch.mid', 'wb') { |file| seq.write(file) }
|
data/examples/measures_mbt.rb
CHANGED
@@ -19,12 +19,12 @@ File.open(ARGV[0], 'rb') { | file | seq.read(file) }
|
|
19
19
|
# Get all measures, so events can be mapped to measures:
|
20
20
|
measures = seq.get_measures
|
21
21
|
|
22
|
-
seq.each { |
|
23
|
-
track.each { |
|
22
|
+
seq.each { |track|
|
23
|
+
track.each { |e|
|
24
24
|
if e.kind_of?(MIDI::NoteOn) then
|
25
25
|
# Print out start of notes
|
26
26
|
e.print_note_names = true
|
27
27
|
puts measures.to_mbt(e) + " ch #{e.channel}: #{e.note_to_s}"
|
28
|
-
end
|
29
|
-
}
|
28
|
+
end
|
29
|
+
}
|
30
30
|
}
|
@@ -11,18 +11,18 @@ DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
|
11
11
|
# Read from MIDI file
|
12
12
|
seq = MIDI::Sequence.new()
|
13
13
|
|
14
|
-
File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb')
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb') do |file|
|
15
|
+
# The block we pass in to Sequence.read is called at the end of every
|
16
|
+
# track read. It is optional, but is useful for progress reports.
|
17
|
+
seq.read(file)
|
18
|
+
end
|
19
19
|
|
20
|
-
seq.each
|
20
|
+
seq.each do |track|
|
21
21
|
puts
|
22
22
|
puts "*** track name \"#{track.name}\", \"#{track.instrument}\""
|
23
|
-
track.each
|
23
|
+
track.each do |e|
|
24
24
|
e.print_decimal_numbers = true
|
25
25
|
e.print_channel_numbers_from_one = true
|
26
26
|
puts e if e.kind_of?(MIDI::ProgramChange)
|
27
|
-
|
28
|
-
|
27
|
+
end
|
28
|
+
end
|
data/examples/reader2text.rb
CHANGED
@@ -21,187 +21,187 @@ DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
|
21
21
|
|
22
22
|
class TextTranslator < MIDI::IO::MIDIFile
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# The remaining methods are overrides of methods in MIDI::IO::MIDIFile.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
24
|
+
def initialize(seq, proc = nil)
|
25
|
+
super()
|
26
|
+
@seq = seq
|
27
|
+
@track = nil
|
28
|
+
@update_block = block_given?() ? Proc.new() : proc
|
29
|
+
end
|
30
|
+
|
31
|
+
# Generate a unique number for a channel/note combination. This is used
|
32
|
+
# to remember pending note on events.
|
33
|
+
def note_hash(chan, note)
|
34
|
+
return (chan << 8) + note
|
35
|
+
end
|
36
|
+
|
37
|
+
# Print a delta time.
|
38
|
+
def pdelta
|
39
|
+
print "#{@curr_ticks}: "
|
40
|
+
end
|
41
|
+
|
42
|
+
# The remaining methods are overrides of methods in MIDI::IO::MIDIFile.
|
43
|
+
|
44
|
+
def header(format, ntrks, division)
|
45
|
+
puts "header: format = #{format}, ntrks = #{ntrks}," +
|
46
|
+
" division = #{division}"
|
47
|
+
|
48
|
+
@ntrks = ntrks
|
49
|
+
@update_block.call(nil, @ntrks, 0) if @update_block
|
50
|
+
end
|
51
|
+
|
52
|
+
def start_track()
|
53
|
+
pdelta()
|
54
|
+
puts "track start"
|
55
|
+
|
56
|
+
@pending = []
|
57
|
+
@chan_mask = 0
|
58
|
+
end
|
59
|
+
|
60
|
+
def end_track()
|
61
|
+
pdelta()
|
62
|
+
puts "track end; chans used bitmask = #{@chan_mask}"
|
63
|
+
# Write message for any pending note on messages
|
64
|
+
@pending.each_with_index do |num, chan|
|
65
|
+
puts "pending note off missing for chan #{num >> 8}," +
|
66
|
+
" note #{num & 0xff}" if note_obj
|
67
|
+
end
|
68
|
+
@pending = nil
|
69
|
+
|
70
|
+
# call update block
|
71
|
+
@update_block.call(@track, @ntrks, @seq.tracks.length) if @update_block
|
72
|
+
end
|
73
|
+
|
74
|
+
def note_on(chan, note, vel)
|
75
|
+
pdelta()
|
76
|
+
if vel == 0
|
77
|
+
print "(note on, vel 0) "
|
78
|
+
note_off(chan, note, 64)
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "note on chan #{chan}, note #{note}, vel #{vel}"
|
83
|
+
@pending << note_hash(chan, note)
|
84
|
+
track_uses_channel(chan)
|
85
|
+
end
|
86
|
+
|
87
|
+
def note_off(chan, note, vel)
|
88
|
+
pdelta()
|
89
|
+
# Find note on, create note off, connect the two, and remove
|
90
|
+
# note on from pending list.
|
91
|
+
pnum = note_hash(chan, note)
|
92
|
+
@pending.each_with_index do |num, i|
|
93
|
+
if pnum == num
|
94
|
+
puts "note off chan #{chan}, note #{note}, vel #{vel}"
|
95
|
+
@pending.delete_at(i)
|
96
|
+
return
|
97
|
+
end
|
98
|
+
end
|
99
|
+
puts "note off with no earlier note on (ch #{chan}, note" +
|
100
|
+
" #{note}, vel #{vel})"
|
101
|
+
end
|
102
|
+
|
103
|
+
def pressure(chan, note, press)
|
104
|
+
pdelta()
|
105
|
+
puts "pressure chan #{chan}, note #{note}, press #{press}"
|
106
|
+
track_uses_channel(chan)
|
107
|
+
end
|
108
|
+
|
109
|
+
def controller(chan, control, value)
|
110
|
+
pdelta()
|
111
|
+
puts "controller chan #{chan}, control #{control}, value #{value}"
|
112
|
+
track_uses_channel(chan)
|
113
|
+
end
|
114
|
+
|
115
|
+
def pitch_bend(chan, msb, lsb)
|
116
|
+
pdelta()
|
117
|
+
puts "pitch bend chan #{chan}, msb #{msb}, lsb #{lsb}"
|
118
|
+
track_uses_channel(chan)
|
119
|
+
end
|
120
|
+
|
121
|
+
def program(chan, program)
|
122
|
+
pdelta()
|
123
|
+
puts "program chan #{chan}, program #{program}"
|
124
|
+
track_uses_channel(chan)
|
125
|
+
end
|
126
|
+
|
127
|
+
def chan_pressure(chan, press)
|
128
|
+
pdelta()
|
129
|
+
puts "chan press chan #{chan}, press #{press}"
|
130
|
+
track_uses_channel(chan)
|
131
|
+
end
|
132
|
+
|
133
|
+
def sysex(msg)
|
134
|
+
pdelta()
|
135
|
+
puts "sysex size #{msg.length}"
|
136
|
+
end
|
137
|
+
|
138
|
+
def meta_misc(type, msg)
|
139
|
+
pdelta()
|
140
|
+
puts "meta misc type #{type}, length #{msg.length}"
|
141
|
+
end
|
142
|
+
|
143
|
+
def sequencer_specific(type, msg)
|
144
|
+
pdelta()
|
145
|
+
puts "sequencer specific type #{type}, msg #{msg.length}"
|
146
|
+
end
|
147
|
+
|
148
|
+
def sequence_number(num)
|
149
|
+
pdelta()
|
150
|
+
puts "sequence number #{num}"
|
151
|
+
end
|
152
|
+
|
153
|
+
def text(type, msg)
|
154
|
+
pdelta()
|
155
|
+
msg = MIDI::MetaEvent.bytes_as_str(msg)
|
156
|
+
case type
|
157
|
+
when MIDI::META_SEQ_NAME
|
158
|
+
puts "seq or track name #{msg}"
|
159
|
+
when MIDI::META_INSTRUMENT
|
160
|
+
puts "instrument name #{msg}"
|
161
|
+
when MIDI::META_MARKER
|
162
|
+
puts "marker #{msg}"
|
163
|
+
else
|
164
|
+
puts "text = #{msg}, type = #{type}"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def eot()
|
169
|
+
pdelta()
|
170
|
+
puts "end of track event"
|
171
|
+
end
|
172
|
+
|
173
|
+
def time_signature(numer, denom, clocks, qnotes)
|
174
|
+
pdelta()
|
175
|
+
puts "time sig numer #{numer}, denom #{denom}, clocks #{clocks}," +
|
176
|
+
" qnotes #{qnotes}"
|
177
|
+
end
|
178
|
+
|
179
|
+
def smpte(hour, min, sec, frame, fract)
|
180
|
+
pdelta()
|
181
|
+
puts "smpte #{hour}:#{min}.#{sec}, frame #{frame}, fract #{fract}"
|
182
|
+
end
|
183
|
+
|
184
|
+
def tempo(microsecs)
|
185
|
+
pdelta()
|
186
|
+
bpm = 1.0 / microsecs # quarter notes per microsecond
|
187
|
+
bpm *= 1000000.0 # quarter notes per second
|
188
|
+
bpm *= 60.0 # quarter notes per minute
|
189
|
+
puts "tempo microsecs pqn = #{microsecs} (#{bpm} bpm)"
|
190
|
+
end
|
191
|
+
|
192
|
+
def key_signature(sharpflat, is_minor)
|
193
|
+
pdelta()
|
194
|
+
puts "key sig sharpflat #{sharpflat}, is_minor #{is_minor}"
|
195
|
+
end
|
196
|
+
|
197
|
+
def arbitrary(msg)
|
198
|
+
pdelta()
|
199
|
+
puts "arbitrary length = #{msg.length}"
|
200
|
+
end
|
201
|
+
|
202
|
+
def track_uses_channel(chan)
|
203
|
+
@chan_mask = @chan_mask | (1 << chan)
|
204
|
+
end
|
205
205
|
|
206
206
|
end
|
207
207
|
|
@@ -212,10 +212,10 @@ seq = MIDI::Sequence.new()
|
|
212
212
|
# Specify what class to use when reading the MIDI file.
|
213
213
|
seq.reader_class = TextTranslator
|
214
214
|
|
215
|
-
File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb')
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
215
|
+
File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb') do | file |
|
216
|
+
# The block we pass in to Sequence.read is called at the end of every
|
217
|
+
# track read. It is optional, but is useful for progress reports.
|
218
|
+
seq.read(file) do |track, num_tracks, i|
|
219
|
+
puts "read track #{track ? track.name : ''} (#{i} of #{num_tracks})"
|
220
|
+
end
|
221
|
+
end
|