midilib 2.0.5 → 3.0.1
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 +5 -5
- data/ChangeLog +2 -1
- data/Credits +39 -2
- data/README.rdoc +5 -6
- data/Rakefile +36 -49
- data/TODO.rdoc +13 -2
- data/examples/from_scratch.rb +1 -1
- data/examples/measures_mbt.rb +11 -11
- data/examples/print_program_changes.rb +2 -2
- data/examples/reader2text.rb +47 -47
- data/examples/seq2text.rb +1 -1
- data/examples/split.rb +4 -3
- data/examples/strings.rb +4 -4
- data/examples/transpose.rb +19 -20
- data/install.rb +21 -13
- data/lib/midilib/consts.rb +237 -239
- data/lib/midilib/event.rb +128 -100
- data/lib/midilib/info.rb +3 -5
- data/lib/midilib/io/midifile.rb +155 -182
- data/lib/midilib/io/seqreader.rb +80 -85
- data/lib/midilib/io/seqwriter.rb +93 -88
- data/lib/midilib/measure.rb +78 -80
- data/lib/midilib/mergesort.rb +39 -0
- data/lib/midilib/sequence.rb +40 -32
- data/lib/midilib/track.rb +16 -57
- data/lib/midilib/utils.rb +4 -7
- data/lib/midilib.rb +5 -5
- data/test/event_equality.rb +28 -30
- data/test/test_event.rb +9 -11
- data/test/test_io.rb +83 -3
- data/test/test_mergesort.rb +37 -0
- data/test/test_midifile.rb +6 -19
- data/test/test_sequence.rb +5 -4
- data/test/test_track.rb +9 -38
- data/test/test_varlen.rb +1 -3
- metadata +8 -95
- data/html/IO.html +0 -155
- data/html/MIDI/ActiveSense.html +0 -206
- data/html/MIDI/ChannelEvent.html +0 -231
- data/html/MIDI/ChannelPressure.html +0 -265
- data/html/MIDI/Clock.html +0 -206
- data/html/MIDI/Continue.html +0 -206
- data/html/MIDI/Controller.html +0 -280
- data/html/MIDI/Event.html +0 -489
- data/html/MIDI/IO/MIDIFile.html +0 -2024
- data/html/MIDI/IO/SeqReader.html +0 -904
- data/html/MIDI/IO/SeqWriter.html +0 -572
- data/html/MIDI/IO.html +0 -95
- data/html/MIDI/KeySig.html +0 -353
- data/html/MIDI/MIDI/MIDI/Array.html +0 -255
- data/html/MIDI/MIDI/MIDI.html +0 -95
- data/html/MIDI/MIDI.html +0 -95
- data/html/MIDI/Marker.html +0 -158
- data/html/MIDI/Measure.html +0 -328
- data/html/MIDI/Measures.html +0 -285
- data/html/MIDI/MetaEvent.html +0 -461
- data/html/MIDI/NoteEvent.html +0 -331
- data/html/MIDI/NoteOff.html +0 -228
- data/html/MIDI/NoteOn.html +0 -228
- data/html/MIDI/PitchBend.html +0 -266
- data/html/MIDI/PolyPressure.html +0 -277
- data/html/MIDI/ProgramChange.html +0 -265
- data/html/MIDI/Realtime.html +0 -242
- data/html/MIDI/Sequence.html +0 -896
- data/html/MIDI/SongPointer.html +0 -266
- data/html/MIDI/SongSelect.html +0 -265
- data/html/MIDI/Start.html +0 -206
- data/html/MIDI/Stop.html +0 -206
- data/html/MIDI/SystemCommon.html +0 -158
- data/html/MIDI/SystemExclusive.html +0 -268
- data/html/MIDI/SystemReset.html +0 -206
- data/html/MIDI/Tempo.html +0 -396
- data/html/MIDI/TimeSig.html +0 -388
- data/html/MIDI/Track.html +0 -695
- data/html/MIDI/TuneRequest.html +0 -242
- data/html/MIDI/Utils.html +0 -220
- data/html/MIDI.html +0 -547
- data/html/README_rdoc.html +0 -731
- data/html/TODO_rdoc.html +0 -125
- data/html/created.rid +0 -14
- data/html/css/fonts.css +0 -167
- data/html/css/rdoc.css +0 -590
- 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/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +0 -768
- data/html/js/darkfish.js +0 -161
- data/html/js/jquery.js +0 -4
- data/html/js/navigation.js +0 -142
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +0 -109
- data/html/js/search_index.js +0 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +0 -228
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +0 -1265
data/test/test_io.rb
CHANGED
|
@@ -7,12 +7,13 @@ $LOAD_PATH[0, 0] = File.dirname(__FILE__)
|
|
|
7
7
|
|
|
8
8
|
require 'test/unit'
|
|
9
9
|
require 'midilib'
|
|
10
|
+
require 'midilib/consts'
|
|
10
11
|
require 'event_equality'
|
|
11
12
|
|
|
12
13
|
class IOTester < Test::Unit::TestCase
|
|
13
|
-
|
|
14
14
|
SEQ_TEST_FILE = File.join(File.dirname(__FILE__), 'test.mid')
|
|
15
15
|
OUTPUT_FILE = 'testout.mid'
|
|
16
|
+
TEMPFILE = '/tmp/midilib_test.mid'
|
|
16
17
|
|
|
17
18
|
def compare_tracks(t0, t1)
|
|
18
19
|
assert_equal(t0.name, t1.name, 'track names differ')
|
|
@@ -29,17 +30,70 @@ class IOTester < Test::Unit::TestCase
|
|
|
29
30
|
s0.each_with_index { |track0, i| compare_tracks(track0, s1.tracks[i]) }
|
|
30
31
|
end
|
|
31
32
|
|
|
33
|
+
def compare_sequences_format_0(multitrack_seq, format0_seq)
|
|
34
|
+
assert_equal(multitrack_seq.name, format0_seq.name, 'sequence names differ')
|
|
35
|
+
assert_equal(1, format0_seq.tracks.length, 'number of tracks differ')
|
|
36
|
+
format_1_count = multitrack_seq.tracks.map { |t| t.events.count }.reduce(:+)
|
|
37
|
+
format_0_count = format0_seq.tracks.map { |t| t.events.count }.reduce(:+)
|
|
38
|
+
assert_equal(format_1_count, format_0_count, 'same number of total events')
|
|
39
|
+
end
|
|
40
|
+
|
|
32
41
|
def test_read_and_write
|
|
33
|
-
seq0 = MIDI::Sequence.new
|
|
42
|
+
seq0 = MIDI::Sequence.new
|
|
34
43
|
File.open(SEQ_TEST_FILE, 'rb') { |f| seq0.read(f) }
|
|
35
44
|
File.open(OUTPUT_FILE, 'wb') { |f| seq0.write(f) }
|
|
36
|
-
seq1 = MIDI::Sequence.new
|
|
45
|
+
seq1 = MIDI::Sequence.new
|
|
37
46
|
File.open(OUTPUT_FILE, 'rb') { |f| seq1.read(f) }
|
|
38
47
|
compare_sequences(seq0, seq1)
|
|
39
48
|
ensure
|
|
40
49
|
File.delete(OUTPUT_FILE) if File.exist?(OUTPUT_FILE)
|
|
41
50
|
end
|
|
42
51
|
|
|
52
|
+
def test_read_and_write_format_0
|
|
53
|
+
seq0 = MIDI::Sequence.new
|
|
54
|
+
File.open(SEQ_TEST_FILE, 'rb') { |f| seq0.read(f) }
|
|
55
|
+
File.open(OUTPUT_FILE, 'wb') { |f| seq0.write(f, 0) }
|
|
56
|
+
seq1 = MIDI::Sequence.new
|
|
57
|
+
File.open(OUTPUT_FILE, 'rb') { |f| seq1.read(f) }
|
|
58
|
+
compare_sequences_format_0(seq0, seq1)
|
|
59
|
+
ensure
|
|
60
|
+
File.delete(OUTPUT_FILE) if File.exist?(OUTPUT_FILE)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_read_callback
|
|
64
|
+
seq = MIDI::Sequence.new
|
|
65
|
+
names = []
|
|
66
|
+
num_tracks = -1
|
|
67
|
+
File.open(SEQ_TEST_FILE, 'rb') do |f|
|
|
68
|
+
seq.read(f) do |track, ntracks, i|
|
|
69
|
+
names << (track ? track.name : nil)
|
|
70
|
+
num_tracks = ntracks
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
assert_equal(names, [nil, 'Sequence Name', 'My New Track'])
|
|
74
|
+
assert_equal(num_tracks, 2)
|
|
75
|
+
ensure
|
|
76
|
+
File.delete(OUTPUT_FILE) if File.exist?(OUTPUT_FILE)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_write_callback
|
|
80
|
+
seq = MIDI::Sequence.new
|
|
81
|
+
File.open(SEQ_TEST_FILE, 'rb') { |f| seq.read(f) }
|
|
82
|
+
|
|
83
|
+
names = []
|
|
84
|
+
num_tracks = -1
|
|
85
|
+
File.open(OUTPUT_FILE, 'wb') do |f|
|
|
86
|
+
seq.write(f) do |track, ntracks, i|
|
|
87
|
+
names << (track ? track.name : nil)
|
|
88
|
+
num_tracks = ntracks
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
assert_equal(names, [nil, 'Sequence Name', 'My New Track'])
|
|
92
|
+
assert_equal(num_tracks, 2)
|
|
93
|
+
ensure
|
|
94
|
+
File.delete(OUTPUT_FILE) if File.exist?(OUTPUT_FILE)
|
|
95
|
+
end
|
|
96
|
+
|
|
43
97
|
def test_read_strings
|
|
44
98
|
seq = MIDI::Sequence.new
|
|
45
99
|
File.open(SEQ_TEST_FILE, 'rb') { |f| seq.read(f) }
|
|
@@ -47,4 +101,30 @@ class IOTester < Test::Unit::TestCase
|
|
|
47
101
|
assert_equal(MIDI::GM_PATCH_NAMES[0], seq.tracks[1].instrument)
|
|
48
102
|
end
|
|
49
103
|
|
|
104
|
+
def test_preserve_meta_deltas
|
|
105
|
+
out_seq = MIDI::Sequence.new
|
|
106
|
+
out_track = MIDI::Track.new(out_seq)
|
|
107
|
+
out_seq.tracks << out_track
|
|
108
|
+
out_track.events << MIDI::Tempo.new(MIDI::Tempo.bpm_to_mpq(120))
|
|
109
|
+
# Normally copyright and sequence name events are at time 0, but non-zero
|
|
110
|
+
# start times are allowed.
|
|
111
|
+
out_track.events << MIDI::MetaEvent.new(MIDI::META_COPYRIGHT, '(C) 1950 Donald Duck', 100)
|
|
112
|
+
out_track.events << MIDI::MetaEvent.new(MIDI::META_SEQ_NAME, 'Quack, Track 1', 200)
|
|
113
|
+
out_track.events << MIDI::NoteOn.new(0, 64, 127, 0)
|
|
114
|
+
out_track.events << MIDI::NoteOff.new(0, 64, 127, 100)
|
|
115
|
+
File.open('/tmp/midilib_test.mid', 'wb') { |file| out_seq.write(file) }
|
|
116
|
+
|
|
117
|
+
# Although start times are not written out to the MIDI file, we
|
|
118
|
+
# calculate them because we are about to compare the out events with the
|
|
119
|
+
# newly-read events which will have their start times set.
|
|
120
|
+
out_track.recalc_times
|
|
121
|
+
|
|
122
|
+
in_seq = MIDI::Sequence.new
|
|
123
|
+
File.open(TEMPFILE, 'rb') { |file| in_seq.read(file) }
|
|
124
|
+
in_track = in_seq.tracks[0]
|
|
125
|
+
assert_equal(out_track.events.length, in_track.events.length)
|
|
126
|
+
out_track.events.each_with_index do |event, i|
|
|
127
|
+
assert_equal(event, in_track.events[i])
|
|
128
|
+
end
|
|
129
|
+
end
|
|
50
130
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Start looking for MIDI classes in the directory above this one.
|
|
2
|
+
# This forces us to use the local copy of MIDI, even if there is
|
|
3
|
+
# a previously installed version out there somewhere.
|
|
4
|
+
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
5
|
+
|
|
6
|
+
require 'test/unit'
|
|
7
|
+
require 'midilib/mergesort'
|
|
8
|
+
|
|
9
|
+
class MergesortTester < Test::Unit::TestCase
|
|
10
|
+
def test_mergesort
|
|
11
|
+
track = MIDI::Track.new(nil)
|
|
12
|
+
track.events = []
|
|
13
|
+
|
|
14
|
+
# Two events with later start times but earlier in the event list
|
|
15
|
+
e2 = MIDI::NoteOff.new(0, 64, 64, 100)
|
|
16
|
+
e2.time_from_start = 100
|
|
17
|
+
track.events << e2
|
|
18
|
+
|
|
19
|
+
e3 = MIDI::NoteOn.new(0, 64, 64, 100)
|
|
20
|
+
e3.time_from_start = 100
|
|
21
|
+
track.events << e3
|
|
22
|
+
|
|
23
|
+
# Earliest start time, latest in the list of events
|
|
24
|
+
e1 = MIDI::NoteOn.new(0, 64, 64, 100)
|
|
25
|
+
e1.time_from_start = 0
|
|
26
|
+
track.events << e1
|
|
27
|
+
|
|
28
|
+
# Recalc sorts. Make sure note off/note on pair at t 100 are in the
|
|
29
|
+
# correct order.
|
|
30
|
+
track.recalc_delta_from_times
|
|
31
|
+
|
|
32
|
+
# These tests would fail before we moved to mergesort.
|
|
33
|
+
assert_equal(e1, track.events[0])
|
|
34
|
+
assert_equal(e2, track.events[1])
|
|
35
|
+
assert_equal(e3, track.events[2])
|
|
36
|
+
end
|
|
37
|
+
end
|
data/test/test_midifile.rb
CHANGED
|
@@ -8,30 +8,18 @@ require 'stringio'
|
|
|
8
8
|
require 'midilib'
|
|
9
9
|
|
|
10
10
|
class MIDI::IO::MIDIFile
|
|
11
|
-
|
|
12
|
-
@io = io
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
if RUBY_VERSION < '1.9'
|
|
16
|
-
class StringIO
|
|
17
|
-
def readbyte
|
|
18
|
-
c = getc()
|
|
19
|
-
raise 'unexpected EOF' unless c
|
|
20
|
-
c
|
|
21
|
-
end
|
|
22
|
-
end
|
|
11
|
+
attr_writer :io
|
|
23
12
|
end
|
|
24
13
|
|
|
25
14
|
class MIDIFileTester < Test::Unit::TestCase
|
|
26
|
-
|
|
27
15
|
def setup
|
|
28
16
|
@m = MIDI::IO::MIDIFile.new
|
|
29
17
|
end
|
|
30
18
|
|
|
31
19
|
def test_msg_io
|
|
32
20
|
io = StringIO.new
|
|
33
|
-
io.write(
|
|
34
|
-
io.rewind
|
|
21
|
+
io.write('abcdef')
|
|
22
|
+
io.rewind
|
|
35
23
|
@m.io = io
|
|
36
24
|
@m.msg_init
|
|
37
25
|
@m.msg_read(6)
|
|
@@ -41,9 +29,9 @@ class MIDIFileTester < Test::Unit::TestCase
|
|
|
41
29
|
def test_read32
|
|
42
30
|
io = StringIO.new
|
|
43
31
|
io.write("\0\0\0\6")
|
|
44
|
-
io.rewind
|
|
32
|
+
io.rewind
|
|
45
33
|
@m.io = io
|
|
46
|
-
assert_equal 6, @m.read32
|
|
34
|
+
assert_equal 6, @m.read32
|
|
47
35
|
end
|
|
48
36
|
|
|
49
37
|
def test_write32
|
|
@@ -52,8 +40,7 @@ class MIDIFileTester < Test::Unit::TestCase
|
|
|
52
40
|
$stdout = io
|
|
53
41
|
@m.write32(6)
|
|
54
42
|
$stdout = old_stdout
|
|
55
|
-
io.rewind
|
|
43
|
+
io.rewind
|
|
56
44
|
assert_equal "\0\0\0\6", io.string
|
|
57
45
|
end
|
|
58
|
-
|
|
59
46
|
end
|
data/test/test_sequence.rb
CHANGED
|
@@ -7,7 +7,6 @@ require 'test/unit'
|
|
|
7
7
|
require 'midilib'
|
|
8
8
|
|
|
9
9
|
class SequenceTester < Test::Unit::TestCase
|
|
10
|
-
|
|
11
10
|
def setup
|
|
12
11
|
@seq = MIDI::Sequence.new
|
|
13
12
|
@track = MIDI::Track.new(@seq)
|
|
@@ -28,10 +27,10 @@ class SequenceTester < Test::Unit::TestCase
|
|
|
28
27
|
assert_in_delta 0.5, @seq.pulses_to_seconds(480), 0.00001
|
|
29
28
|
|
|
30
29
|
# A half note should take one second
|
|
31
|
-
assert_in_delta 1.0, @seq.pulses_to_seconds(480*2), 0.00001
|
|
30
|
+
assert_in_delta 1.0, @seq.pulses_to_seconds(480 * 2), 0.00001
|
|
32
31
|
|
|
33
32
|
# An eight note should take 0.25 seconds
|
|
34
|
-
assert_in_delta 0.25, @seq.pulses_to_seconds(480/2), 0.00001
|
|
33
|
+
assert_in_delta 0.25, @seq.pulses_to_seconds(480 / 2), 0.00001
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
def test_length_to_delta
|
|
@@ -43,7 +42,9 @@ class SequenceTester < Test::Unit::TestCase
|
|
|
43
42
|
assert_equal(12, @seq.ppqn)
|
|
44
43
|
assert_equal(12, @seq.length_to_delta(1))
|
|
45
44
|
assert_equal(6, @seq.length_to_delta(0.5))
|
|
46
|
-
|
|
45
|
+
# rounding tests
|
|
46
|
+
assert_equal(6, @seq.length_to_delta(0.49))
|
|
47
|
+
assert_equal(5, @seq.length_to_delta(0.45))
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def test_note_to_length
|
data/test/test_track.rb
CHANGED
|
@@ -7,7 +7,6 @@ require 'test/unit'
|
|
|
7
7
|
require 'midilib'
|
|
8
8
|
|
|
9
9
|
class TrackTester < Test::Unit::TestCase
|
|
10
|
-
|
|
11
10
|
def setup
|
|
12
11
|
@seq = MIDI::Sequence.new
|
|
13
12
|
@track = MIDI::Track.new(@seq)
|
|
@@ -20,7 +19,7 @@ class TrackTester < Test::Unit::TestCase
|
|
|
20
19
|
assert_equal(3, @track.events.length)
|
|
21
20
|
3.times do |i|
|
|
22
21
|
assert_equal(100, @track.events[i].delta_time)
|
|
23
|
-
assert_equal((i+1) * 100, @track.events[i].time_from_start)
|
|
22
|
+
assert_equal((i + 1) * 100, @track.events[i].time_from_start)
|
|
24
23
|
end
|
|
25
24
|
assert_equal(MIDI::Track::UNNAMED, @track.name)
|
|
26
25
|
end
|
|
@@ -30,7 +29,7 @@ class TrackTester < Test::Unit::TestCase
|
|
|
30
29
|
@track.recalc_times
|
|
31
30
|
assert_equal(4, @track.events.length)
|
|
32
31
|
4.times do |i|
|
|
33
|
-
assert_equal((i+1) * 100, @track.events[i].time_from_start)
|
|
32
|
+
assert_equal((i + 1) * 100, @track.events[i].time_from_start)
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
|
|
@@ -41,17 +40,17 @@ class TrackTester < Test::Unit::TestCase
|
|
|
41
40
|
|
|
42
41
|
3.times do |i|
|
|
43
42
|
assert_equal(100, @track.events[i].delta_time)
|
|
44
|
-
assert_equal((i+1) * 100, @track.events[i].time_from_start)
|
|
43
|
+
assert_equal((i + 1) * 100, @track.events[i].time_from_start)
|
|
45
44
|
end
|
|
46
45
|
12.times do |i|
|
|
47
46
|
assert_equal(3, @track.events[3 + i].delta_time)
|
|
48
|
-
assert_equal(300 + ((i+1) * 3),
|
|
47
|
+
assert_equal(300 + ((i + 1) * 3),
|
|
49
48
|
@track.events[3 + i].time_from_start)
|
|
50
49
|
end
|
|
51
50
|
end
|
|
52
51
|
|
|
53
52
|
def test_insert
|
|
54
|
-
@track.events[1,0] = MIDI::NoteOn.new(0, 64, 64, 3)
|
|
53
|
+
@track.events[1, 0] = MIDI::NoteOn.new(0, 64, 64, 3)
|
|
55
54
|
@track.recalc_times
|
|
56
55
|
assert_equal(100, @track.events[0].time_from_start)
|
|
57
56
|
assert_equal(103, @track.events[1].time_from_start)
|
|
@@ -124,8 +123,8 @@ class TrackTester < Test::Unit::TestCase
|
|
|
124
123
|
def test_quantize
|
|
125
124
|
@seq.ppqn = 80
|
|
126
125
|
|
|
127
|
-
@track.quantize(1)
|
|
128
|
-
assert_equal(80, @track.events[0].time_from_start)
|
|
126
|
+
@track.quantize(1) # Quantize to a quarter note
|
|
127
|
+
assert_equal(80, @track.events[0].time_from_start) # was 100
|
|
129
128
|
assert_equal(240, @track.events[1].time_from_start) # was 200
|
|
130
129
|
assert_equal(320, @track.events[2].time_from_start) # was 300
|
|
131
130
|
end
|
|
@@ -137,36 +136,8 @@ class TrackTester < Test::Unit::TestCase
|
|
|
137
136
|
|
|
138
137
|
def test_old_note_class_names
|
|
139
138
|
x = MIDI::NoteOn.new(0, 64, 64, 10)
|
|
140
|
-
assert(x.
|
|
139
|
+
assert(x.is_a?(MIDI::NoteOnEvent)) # old name
|
|
141
140
|
x = MIDI::NoteOff.new(0, 64, 64, 10)
|
|
142
|
-
assert(x.
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def test_mergesort
|
|
146
|
-
@track.events = []
|
|
147
|
-
|
|
148
|
-
# Two events with later start times but earlier in the event list
|
|
149
|
-
e2 = MIDI::NoteOff.new(0, 64, 64, 100)
|
|
150
|
-
e2.time_from_start = 100
|
|
151
|
-
@track.events << e2
|
|
152
|
-
|
|
153
|
-
e3 = MIDI::NoteOn.new(0, 64, 64, 100)
|
|
154
|
-
e3.time_from_start = 100
|
|
155
|
-
@track.events << e3
|
|
156
|
-
|
|
157
|
-
# Earliest start time, latest in the list of events
|
|
158
|
-
e1 = MIDI::NoteOn.new(0, 64, 64, 100)
|
|
159
|
-
e1.time_from_start = 0
|
|
160
|
-
@track.events << e1
|
|
161
|
-
|
|
162
|
-
# Recalc sorts. Make sure note off/note on pair at t 100 are in the
|
|
163
|
-
# correct order.
|
|
164
|
-
@track.recalc_delta_from_times
|
|
165
|
-
|
|
166
|
-
# These tests would fail before we moved to mergesort.
|
|
167
|
-
assert_equal(e1, @track.events[0])
|
|
168
|
-
assert_equal(e2, @track.events[1])
|
|
169
|
-
assert_equal(e3, @track.events[2])
|
|
170
|
-
|
|
141
|
+
assert(x.is_a?(MIDI::NoteOffEvent)) # old name
|
|
171
142
|
end
|
|
172
143
|
end
|
data/test/test_varlen.rb
CHANGED
|
@@ -7,7 +7,6 @@ require 'test/unit'
|
|
|
7
7
|
require 'midilib'
|
|
8
8
|
|
|
9
9
|
class VarLenTester < Test::Unit::TestCase
|
|
10
|
-
|
|
11
10
|
VAR_LEN_TEST_DATA = {
|
|
12
11
|
0x00000000 => 0x00,
|
|
13
12
|
0x00000040 => 0x40,
|
|
@@ -20,7 +19,7 @@ class VarLenTester < Test::Unit::TestCase
|
|
|
20
19
|
0x001FFFFF => 0xFFFF7F,
|
|
21
20
|
0x00200000 => 0x81808000,
|
|
22
21
|
0x08000000 => 0xC0808000,
|
|
23
|
-
0x0FFFFFFF => 0xFFFFFF7F
|
|
22
|
+
0x0FFFFFFF => 0xFFFFFF7F
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
def num_to_var_len(num, answer)
|
|
@@ -34,5 +33,4 @@ class VarLenTester < Test::Unit::TestCase
|
|
|
34
33
|
def test_num_to_var_len
|
|
35
34
|
VAR_LEN_TEST_DATA.each { |varlen, answer| num_to_var_len(varlen, answer) }
|
|
36
35
|
end
|
|
37
|
-
|
|
38
36
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: midilib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jim Menard
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-09-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
midilib is a pure Ruby MIDI library useful for reading and
|
|
@@ -35,94 +35,6 @@ files:
|
|
|
35
35
|
- examples/split.rb
|
|
36
36
|
- examples/strings.rb
|
|
37
37
|
- examples/transpose.rb
|
|
38
|
-
- html/IO.html
|
|
39
|
-
- html/MIDI.html
|
|
40
|
-
- html/MIDI/ActiveSense.html
|
|
41
|
-
- html/MIDI/ChannelEvent.html
|
|
42
|
-
- html/MIDI/ChannelPressure.html
|
|
43
|
-
- html/MIDI/Clock.html
|
|
44
|
-
- html/MIDI/Continue.html
|
|
45
|
-
- html/MIDI/Controller.html
|
|
46
|
-
- html/MIDI/Event.html
|
|
47
|
-
- html/MIDI/IO.html
|
|
48
|
-
- html/MIDI/IO/MIDIFile.html
|
|
49
|
-
- html/MIDI/IO/SeqReader.html
|
|
50
|
-
- html/MIDI/IO/SeqWriter.html
|
|
51
|
-
- html/MIDI/KeySig.html
|
|
52
|
-
- html/MIDI/MIDI.html
|
|
53
|
-
- html/MIDI/MIDI/MIDI.html
|
|
54
|
-
- html/MIDI/MIDI/MIDI/Array.html
|
|
55
|
-
- html/MIDI/Marker.html
|
|
56
|
-
- html/MIDI/Measure.html
|
|
57
|
-
- html/MIDI/Measures.html
|
|
58
|
-
- html/MIDI/MetaEvent.html
|
|
59
|
-
- html/MIDI/NoteEvent.html
|
|
60
|
-
- html/MIDI/NoteOff.html
|
|
61
|
-
- html/MIDI/NoteOn.html
|
|
62
|
-
- html/MIDI/PitchBend.html
|
|
63
|
-
- html/MIDI/PolyPressure.html
|
|
64
|
-
- html/MIDI/ProgramChange.html
|
|
65
|
-
- html/MIDI/Realtime.html
|
|
66
|
-
- html/MIDI/Sequence.html
|
|
67
|
-
- html/MIDI/SongPointer.html
|
|
68
|
-
- html/MIDI/SongSelect.html
|
|
69
|
-
- html/MIDI/Start.html
|
|
70
|
-
- html/MIDI/Stop.html
|
|
71
|
-
- html/MIDI/SystemCommon.html
|
|
72
|
-
- html/MIDI/SystemExclusive.html
|
|
73
|
-
- html/MIDI/SystemReset.html
|
|
74
|
-
- html/MIDI/Tempo.html
|
|
75
|
-
- html/MIDI/TimeSig.html
|
|
76
|
-
- html/MIDI/Track.html
|
|
77
|
-
- html/MIDI/TuneRequest.html
|
|
78
|
-
- html/MIDI/Utils.html
|
|
79
|
-
- html/README_rdoc.html
|
|
80
|
-
- html/TODO_rdoc.html
|
|
81
|
-
- html/created.rid
|
|
82
|
-
- html/css/fonts.css
|
|
83
|
-
- html/css/rdoc.css
|
|
84
|
-
- html/fonts/Lato-Light.ttf
|
|
85
|
-
- html/fonts/Lato-LightItalic.ttf
|
|
86
|
-
- html/fonts/Lato-Regular.ttf
|
|
87
|
-
- html/fonts/Lato-RegularItalic.ttf
|
|
88
|
-
- html/fonts/SourceCodePro-Bold.ttf
|
|
89
|
-
- html/fonts/SourceCodePro-Regular.ttf
|
|
90
|
-
- html/images/add.png
|
|
91
|
-
- html/images/arrow_up.png
|
|
92
|
-
- html/images/brick.png
|
|
93
|
-
- html/images/brick_link.png
|
|
94
|
-
- html/images/bug.png
|
|
95
|
-
- html/images/bullet_black.png
|
|
96
|
-
- html/images/bullet_toggle_minus.png
|
|
97
|
-
- html/images/bullet_toggle_plus.png
|
|
98
|
-
- html/images/date.png
|
|
99
|
-
- html/images/delete.png
|
|
100
|
-
- html/images/find.png
|
|
101
|
-
- html/images/loadingAnimation.gif
|
|
102
|
-
- html/images/macFFBgHack.png
|
|
103
|
-
- html/images/package.png
|
|
104
|
-
- html/images/page_green.png
|
|
105
|
-
- html/images/page_white_text.png
|
|
106
|
-
- html/images/page_white_width.png
|
|
107
|
-
- html/images/plugin.png
|
|
108
|
-
- html/images/ruby.png
|
|
109
|
-
- html/images/tag_blue.png
|
|
110
|
-
- html/images/tag_green.png
|
|
111
|
-
- html/images/transparent.png
|
|
112
|
-
- html/images/wrench.png
|
|
113
|
-
- html/images/wrench_orange.png
|
|
114
|
-
- html/images/zoom.png
|
|
115
|
-
- html/index.html
|
|
116
|
-
- html/js/darkfish.js
|
|
117
|
-
- html/js/jquery.js
|
|
118
|
-
- html/js/navigation.js
|
|
119
|
-
- html/js/navigation.js.gz
|
|
120
|
-
- html/js/search.js
|
|
121
|
-
- html/js/search_index.js
|
|
122
|
-
- html/js/search_index.js.gz
|
|
123
|
-
- html/js/searcher.js
|
|
124
|
-
- html/js/searcher.js.gz
|
|
125
|
-
- html/table_of_contents.html
|
|
126
38
|
- install.rb
|
|
127
39
|
- lib/midilib.rb
|
|
128
40
|
- lib/midilib/consts.rb
|
|
@@ -132,6 +44,7 @@ files:
|
|
|
132
44
|
- lib/midilib/io/seqreader.rb
|
|
133
45
|
- lib/midilib/io/seqwriter.rb
|
|
134
46
|
- lib/midilib/measure.rb
|
|
47
|
+
- lib/midilib/mergesort.rb
|
|
135
48
|
- lib/midilib/sequence.rb
|
|
136
49
|
- lib/midilib/track.rb
|
|
137
50
|
- lib/midilib/utils.rb
|
|
@@ -139,6 +52,7 @@ files:
|
|
|
139
52
|
- test/test.mid
|
|
140
53
|
- test/test_event.rb
|
|
141
54
|
- test/test_io.rb
|
|
55
|
+
- test/test_mergesort.rb
|
|
142
56
|
- test/test_midifile.rb
|
|
143
57
|
- test/test_sequence.rb
|
|
144
58
|
- test/test_track.rb
|
|
@@ -147,7 +61,7 @@ homepage: http://github.com/jimm/midilib
|
|
|
147
61
|
licenses:
|
|
148
62
|
- Ruby
|
|
149
63
|
metadata: {}
|
|
150
|
-
post_install_message:
|
|
64
|
+
post_install_message:
|
|
151
65
|
rdoc_options:
|
|
152
66
|
- "--main"
|
|
153
67
|
- README.rdoc
|
|
@@ -165,9 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
79
|
version: '0'
|
|
166
80
|
requirements:
|
|
167
81
|
- none
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
signing_key:
|
|
82
|
+
rubygems_version: 3.3.7
|
|
83
|
+
signing_key:
|
|
171
84
|
specification_version: 4
|
|
172
85
|
summary: MIDI file and event manipulation library
|
|
173
86
|
test_files: []
|
data/html/IO.html
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
|
|
7
|
-
<title>class IO - midilib</title>
|
|
8
|
-
|
|
9
|
-
<script type="text/javascript">
|
|
10
|
-
var rdoc_rel_prefix = "./";
|
|
11
|
-
</script>
|
|
12
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<body id="top" role="document" class="class">
|
|
22
|
-
<nav role="navigation">
|
|
23
|
-
<div id="project-navigation">
|
|
24
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
25
|
-
<h2>
|
|
26
|
-
<a href="./index.html" rel="home">Home</a>
|
|
27
|
-
</h2>
|
|
28
|
-
|
|
29
|
-
<div id="table-of-contents-navigation">
|
|
30
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
|
31
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
|
32
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
37
|
-
<form action="#" method="get" accept-charset="utf-8">
|
|
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"
|
|
42
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
|
43
|
-
</div>
|
|
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>
|
|
50
|
-
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<div id="class-metadata">
|
|
56
|
-
|
|
57
|
-
<div id="parent-class-section" class="nav-section">
|
|
58
|
-
<h3>Parent</h3>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<p class="link">Object
|
|
62
|
-
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<!-- Method Quickref -->
|
|
68
|
-
<div id="method-list-section" class="nav-section">
|
|
69
|
-
<h3>Methods</h3>
|
|
70
|
-
|
|
71
|
-
<ul class="link-list" role="directory">
|
|
72
|
-
|
|
73
|
-
<li ><a href="#method-i-readbyte">#readbyte</a>
|
|
74
|
-
|
|
75
|
-
</ul>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
</div>
|
|
79
|
-
</nav>
|
|
80
|
-
|
|
81
|
-
<main role="main" aria-labelledby="class-IO">
|
|
82
|
-
<h1 id="class-IO" class="class">
|
|
83
|
-
class IO
|
|
84
|
-
</h1>
|
|
85
|
-
|
|
86
|
-
<section class="description">
|
|
87
|
-
|
|
88
|
-
</section>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
104
|
-
<header>
|
|
105
|
-
<h3>Public Instance Methods</h3>
|
|
106
|
-
</header>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<div id="method-i-readbyte" class="method-detail ">
|
|
110
|
-
|
|
111
|
-
<div class="method-heading">
|
|
112
|
-
<span class="method-name">readbyte</span><span
|
|
113
|
-
class="method-args">()</span>
|
|
114
|
-
|
|
115
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
116
|
-
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<div class="method-description">
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<div class="method-source-code" id="readbyte-source">
|
|
128
|
-
<pre><span class="ruby-comment"># File lib/midilib/io/midifile.rb, line 5</span>
|
|
129
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">readbyte</span>
|
|
130
|
-
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">getc</span>()
|
|
131
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-string">'unexpected EOF'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">c</span>
|
|
132
|
-
<span class="ruby-identifier">c</span>
|
|
133
|
-
<span class="ruby-keyword">end</span></pre>
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
</div>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
</section>
|
|
145
|
-
|
|
146
|
-
</section>
|
|
147
|
-
</main>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<footer id="validator-badges" role="contentinfo">
|
|
151
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
152
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
|
153
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
154
|
-
</footer>
|
|
155
|
-
|