midilib 3.1.0 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +12 -12
- data/Credits +7 -0
- data/README.rdoc +12 -148
- data/Rakefile +5 -15
- data/TODO.rdoc +8 -7
- data/examples/from_scratch.rb +2 -7
- data/examples/measures_mbt.rb +1 -6
- data/examples/print_program_changes.rb +1 -3
- data/examples/reader2text.rb +2 -7
- data/examples/seq2text.rb +1 -6
- data/examples/split.rb +1 -6
- data/examples/strings.rb +2 -7
- data/examples/transpose.rb +3 -8
- data/lib/midilib/consts.rb +2 -0
- data/lib/midilib/event.rb +2 -2
- data/lib/midilib/info.rb +4 -4
- data/lib/midilib/io/seqreader.rb +11 -27
- data/lib/midilib/io/seqwriter.rb +6 -4
- data/lib/midilib/track.rb +38 -6
- data/test/test_event.rb +13 -6
- data/test/test_io.rb +144 -13
- data/test/test_mergesort.rb +1 -6
- data/test/test_midifile.rb +1 -6
- data/test/test_sequence.rb +1 -6
- data/test/test_track.rb +66 -7
- data/test/test_varlen.rb +1 -6
- metadata +3 -87
- data/html/MIDI/ActiveSense.html +0 -171
- data/html/MIDI/ChannelEvent.html +0 -190
- data/html/MIDI/ChannelPressure.html +0 -212
- data/html/MIDI/Clock.html +0 -171
- data/html/MIDI/Continue.html +0 -171
- data/html/MIDI/Controller.html +0 -224
- data/html/MIDI/Event.html +0 -349
- data/html/MIDI/IO/MIDIFile.html +0 -1392
- data/html/MIDI/IO/SeqReader.html +0 -642
- data/html/MIDI/IO/SeqWriter.html +0 -442
- data/html/MIDI/IO.html +0 -91
- data/html/MIDI/KeySig.html +0 -292
- data/html/MIDI/Marker.html +0 -138
- data/html/MIDI/Measure.html +0 -260
- data/html/MIDI/Measures.html +0 -222
- data/html/MIDI/MetaEvent.html +0 -353
- data/html/MIDI/NoteEvent.html +0 -255
- data/html/MIDI/NoteOff.html +0 -188
- data/html/MIDI/NoteOn.html +0 -188
- data/html/MIDI/PitchBend.html +0 -213
- data/html/MIDI/PolyPressure.html +0 -216
- data/html/MIDI/ProgramChange.html +0 -212
- data/html/MIDI/Realtime.html +0 -194
- data/html/MIDI/Sequence.html +0 -641
- data/html/MIDI/SongPointer.html +0 -213
- data/html/MIDI/SongSelect.html +0 -212
- data/html/MIDI/Start.html +0 -171
- data/html/MIDI/Stop.html +0 -171
- data/html/MIDI/SystemCommon.html +0 -138
- data/html/MIDI/SystemExclusive.html +0 -215
- data/html/MIDI/SystemReset.html +0 -171
- data/html/MIDI/Tempo.html +0 -292
- data/html/MIDI/TimeSig.html +0 -286
- data/html/MIDI/Track.html +0 -489
- data/html/MIDI/TuneRequest.html +0 -194
- data/html/MIDI/Utils.html +0 -178
- data/html/MIDI.html +0 -281
- data/html/Object.html +0 -197
- data/html/README_rdoc.html +0 -545
- data/html/TODO_rdoc.html +0 -123
- data/html/created.rid +0 -15
- data/html/css/fonts.css +0 -167
- data/html/css/rdoc.css +0 -639
- 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 -534
- data/html/js/darkfish.js +0 -84
- data/html/js/navigation.js +0 -105
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +0 -110
- data/html/js/search_index.js +0 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +0 -229
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +0 -1258
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21a0b490f3e0df0eb8208d1b07dd7a2d499a3ea7748bdaf89e05c180adc2db84
|
4
|
+
data.tar.gz: 0bece3bec4a4e48044712dd44d40e899283fd2eec9cac1a30ddd91b3ac29bf15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '069eaeafc603927b80d5764593c7ce63bfb9e5d0e3cf3b7c95dee3d42b3a94c604f753b11f2ea6e6ef71d2a203dfaf0acf377a4087531e713b9b16568b390135'
|
7
|
+
data.tar.gz: 7bf1f098d3bdf2587d5e2a3146df7fcc3d3d06c176c693ec9ef504e4c2e03d66913f1067091961832f848ccb7278e569be424e3d971476481f0927957540a0fc
|
data/ChangeLog
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
This change log is no longer maintaned. For further change descriptions,
|
2
2
|
see the Git logs.
|
3
3
|
|
4
|
-
2007-12-11 Jim Menard <jim@
|
4
|
+
2007-12-11 Jim Menard <jim@jimmenard.com>
|
5
5
|
|
6
6
|
* lib/midilib/io/seqreader.rb: Fixed text method and added default
|
7
7
|
implementation of key_signature.
|
8
8
|
|
9
|
-
2007-12-09 Jim Menard <jim@
|
9
|
+
2007-12-09 Jim Menard <jim@jimmenard.com>
|
10
10
|
|
11
11
|
* examples/measures_mbt.rb: Added.
|
12
12
|
|
13
|
-
2007-12-09 Jim Menard <jim@
|
13
|
+
2007-12-09 Jim Menard <jim@jimmenard.com>
|
14
14
|
|
15
15
|
* lib/midilib/event.rb: Added code that fixes bpm calculation
|
16
16
|
bugs, and his TimeSig and KeySig classes.
|
@@ -19,17 +19,17 @@ see the Git logs.
|
|
19
19
|
|
20
20
|
* lib/midilib/sequence.rb: Fixed clock. Added get_measures method.
|
21
21
|
|
22
|
-
2007-12-09 Jim Menard <jim@
|
22
|
+
2007-12-09 Jim Menard <jim@jimmenard.com>
|
23
23
|
|
24
24
|
* lib/midilib/event.rb: added program_change? and
|
25
25
|
print_channel_numbers_from_one to Event.
|
26
26
|
|
27
|
-
2007-03-17 Jim Menard <
|
27
|
+
2007-03-17 Jim Menard <jim@jimmenard.com>
|
28
28
|
|
29
29
|
* Version 1.0.0 released. I will no longer be maintaining this
|
30
30
|
change log; the Subversion comments should be sufficient.
|
31
31
|
|
32
|
-
2006-08-20 Jim Menard <
|
32
|
+
2006-08-20 Jim Menard <jim@jimmenard.com>
|
33
33
|
|
34
34
|
* lib/midilib/event.rb (PolyPressure::initialize): Fixed the
|
35
35
|
misspelled POLY_PRESSURE cosntant, thanks to Mario Pehle
|
@@ -39,7 +39,7 @@ see the Git logs.
|
|
39
39
|
|
40
40
|
* test/test.mid: created (copied examples/from_scratch.mid).
|
41
41
|
|
42
|
-
2005-03-21 Jim Menard <
|
42
|
+
2005-03-21 Jim Menard <jim@jimmenard.com>
|
43
43
|
|
44
44
|
* Version 0.8.4 released.
|
45
45
|
|
@@ -48,7 +48,7 @@ see the Git logs.
|
|
48
48
|
(SystemCommon::initialize): moved @is_system = true to here
|
49
49
|
(SystemExclusive::initialize): ...from here.
|
50
50
|
|
51
|
-
2005-03-20 Jim Menard <
|
51
|
+
2005-03-20 Jim Menard <jim@jimmenard.com>
|
52
52
|
|
53
53
|
* lib/midilib/sequence.rb (Sequence::note_to_delta): created.
|
54
54
|
(Sequence::note_to_length): created.
|
@@ -56,11 +56,11 @@ see the Git logs.
|
|
56
56
|
|
57
57
|
* examples/from_scratch.rb: created.
|
58
58
|
|
59
|
-
2004-07-16 Jim Menard <
|
59
|
+
2004-07-16 Jim Menard <jim@jimmenard.com>
|
60
60
|
|
61
61
|
* Version 0.8.3 released.
|
62
62
|
|
63
|
-
2004-07-10 Jim Menard <
|
63
|
+
2004-07-10 Jim Menard <jim@jimmenard.com>
|
64
64
|
|
65
65
|
* lib/midilib/event.rb (NoteEvent::note_to_s): created.
|
66
66
|
(Event::number_to_s): created.
|
@@ -68,7 +68,7 @@ see the Git logs.
|
|
68
68
|
attributes.
|
69
69
|
(to_s all classes): use @print_note_names and @print_decimal_numbers
|
70
70
|
|
71
|
-
2004-06-30 Jim Menard <
|
71
|
+
2004-06-30 Jim Menard <jim@jimmenard.com>
|
72
72
|
|
73
73
|
* Version 0.8.2 released.
|
74
74
|
|
@@ -103,7 +103,7 @@ see the Git logs.
|
|
103
103
|
* lib/midilib/io/seqreader.rb (SeqReader::initialize): added block
|
104
104
|
rdoc comment.
|
105
105
|
|
106
|
-
2004-06-27 Jim Menard <
|
106
|
+
2004-06-27 Jim Menard <jim@jimmenard.com>
|
107
107
|
|
108
108
|
* Version 0.8.1 released.
|
109
109
|
|
data/Credits
CHANGED
@@ -96,3 +96,10 @@ Miika Alonen (@amiika on Github)
|
|
96
96
|
|
97
97
|
Found a bug caused by note offs coming right before note ons. See
|
98
98
|
https://github.com/jimm/midilib/pull/21 for a detailed write-up.
|
99
|
+
|
100
|
+
@mike-bourgeous on Github
|
101
|
+
|
102
|
+
Opened an issue (https://github.com/jimm/midilib/issues/24) which led to
|
103
|
+
the addition of end of track meta events when reading and writing MIDI
|
104
|
+
files.
|
105
|
+
Found and fixed a bug in SongPointer#data_as_bytes.
|
data/README.rdoc
CHANGED
@@ -91,6 +91,15 @@ This bit mask is set when the track is read from the MIDI file by a SeqReader
|
|
91
91
|
but is _not_ kept up to date by any other methods. Specifically, if you add
|
92
92
|
events to a track at any other time, the bit mask will not be updated.
|
93
93
|
|
94
|
+
When a Track is read from a MIDI file, a MIDI::META_TRACK_END event is added
|
95
|
+
to the end if there isn't one in the file already. When a Track is written
|
96
|
+
to a MIDI file, a MIDI::META_TRACK_END event is always output even if the
|
97
|
+
Track does not have one.
|
98
|
+
|
99
|
+
The Track#merge method ensures that there is only one MIDI::META_TRACK_END
|
100
|
+
event after the merge and that it's at its proper place at the end of the
|
101
|
+
list of events. It does so by calling Track#ensure_track_end_meta_event.
|
102
|
+
|
94
103
|
=== MIDI::Measure
|
95
104
|
|
96
105
|
This class contains information about a measure from the sequence. Measure
|
@@ -133,7 +142,7 @@ string. When assigning to a meta event's data, if you pass in a string it will
|
|
133
142
|
get converted to an array of bytes.
|
134
143
|
|
135
144
|
|
136
|
-
== How To Use
|
145
|
+
== How To Use midilib
|
137
146
|
|
138
147
|
The following examples show you how to use midilib to read, write, and
|
139
148
|
manipulate MIDI files and modify track events. See also the files in the
|
@@ -313,7 +322,7 @@ describes the format of MIDI commands.
|
|
313
322
|
= Administrivia
|
314
323
|
|
315
324
|
Author:: Jim Menard (mailto:jim@jimmenard.com)
|
316
|
-
Copyright:: Copyright (c) 2003-
|
325
|
+
Copyright:: Copyright (c) 2003-2023 Jim Menard
|
317
326
|
License:: Distributed under the same license as Ruby.
|
318
327
|
|
319
328
|
|
@@ -326,157 +335,12 @@ http://www.ruby-lang.org/en/LICENSE.txt.
|
|
326
335
|
midilib may be freely copied in its entirety providing this notice, all
|
327
336
|
source code, all documentation, and all other files are included.
|
328
337
|
|
329
|
-
midilib is Copyright (c) 2003-
|
338
|
+
midilib is Copyright (c) 2003-2023 by Jim Menard.
|
330
339
|
|
331
340
|
The song "No Fences" contained in the MIDI file examples/NoFences.mid is
|
332
341
|
Copyright (c) 1992 by Jim Menard (jim@jimmenard.com). It may be freely used
|
333
342
|
for non-commercial purposes as long as the author is given credit.
|
334
343
|
|
335
|
-
|
336
|
-
== Recent Changes
|
337
|
-
|
338
|
-
=== Changes for 2.0.5:
|
339
|
-
|
340
|
-
Updated +install.rb+ to work with newer versions of Ruby by using
|
341
|
-
+fileutils+ instead of +ftools+.
|
342
|
-
|
343
|
-
=== Changes for 2.0.3:
|
344
|
-
|
345
|
-
New MIDI::Sequence.pulses_to_seconds method.
|
346
|
-
|
347
|
-
=== Changes for 2.0.2:
|
348
|
-
|
349
|
-
Stop monkeypatching Array in MIDI::Track.
|
350
|
-
|
351
|
-
=== Changes for 2.0.0:
|
352
|
-
|
353
|
-
MIDI::NoteOnEvent and MIDI::NoteOffEvent renamed to MIDI::NoteOn and
|
354
|
-
MIDI::NoteOff. The old names will still work for a while.
|
355
|
-
|
356
|
-
The MIDI::Event boolean methods like meta? and note? have been removed. Use
|
357
|
-
the event classes themselves (for example, MIDI::MetaEvent === my_event or
|
358
|
-
my_event.kind_of?(MIDI::MetaEvent)). Case statements that use classes work,
|
359
|
-
too:
|
360
|
-
|
361
|
-
case my_event
|
362
|
-
when MIDI::NoteEvent # superclass of note on, note off, poly press
|
363
|
-
do_this()
|
364
|
-
when MIDI::Controller
|
365
|
-
do_that()
|
366
|
-
end
|
367
|
-
|
368
|
-
Introduced Adam Murray's stable sorting code for
|
369
|
-
MIDI::Track#recalc_delta_from_times. See
|
370
|
-
http://wiki.github.com/adamjmurray/cosy/midilib-notes and
|
371
|
-
http://github.com/adamjmurray/cosy/blob/master/lib/cosy/helper/midi_file_renderer_helper.rb
|
372
|
-
for details.
|
373
|
-
|
374
|
-
Aliased MIDI::Track#sort to MIDI::Track#recalc_delta_from_times, since all
|
375
|
-
sort did was sort the events then call recalc_delta_from_times, and
|
376
|
-
recalc_delta_from_times sorts the events before doing anything else.
|
377
|
-
|
378
|
-
MIDI::Tempo#mpq_to_bpm now returns a float.
|
379
|
-
|
380
|
-
=== Changes for 1.2.0:
|
381
|
-
|
382
|
-
Use byte arrays instead of strings for passing around data. All tests now pass
|
383
|
-
for both Ruby 1.8.X and 1.9.X.
|
384
|
-
|
385
|
-
=== New code repository
|
386
|
-
|
387
|
-
The midilib code is now hosted at Github (http://github.com/jimm/midilib).
|
388
|
-
|
389
|
-
=== Changes for 1.1.4:
|
390
|
-
|
391
|
-
* Fixed a bug in KeySig.data_as_bytes. Thanks to Noah Thorp for finding this
|
392
|
-
and the bug fixed in 1.1.3.
|
393
|
-
|
394
|
-
=== Changes for 1.1.3:
|
395
|
-
|
396
|
-
* Fixed the way midilib detects the behavior of IO.getc.
|
397
|
-
|
398
|
-
=== Changes for 1.1.2:
|
399
|
-
|
400
|
-
* Define MIDI::IO::MIDIFile.getc differently for different Ruby versions,
|
401
|
-
instead of checking for String.bytes every time we read a byte.
|
402
|
-
|
403
|
-
=== Changes for 1.1.1:
|
404
|
-
|
405
|
-
* Make MIDI::IO::MIDIFile.getc do the right thing for both Ruby 1.8 and 1.9.
|
406
|
-
|
407
|
-
=== Changes for 1.1.0:
|
408
|
-
|
409
|
-
* Added test/test.mid to list of files to be included when packaging midifile
|
410
|
-
for distribution.
|
411
|
-
|
412
|
-
=== Changes for 1.0.0:
|
413
|
-
|
414
|
-
* Fixed the bug in Track#recalc_delta_from_times found by Christopher Rose.
|
415
|
-
|
416
|
-
=== Changes for 0.8.7:
|
417
|
-
|
418
|
-
* Fixed the misspelled POLY_PRESSURE constant, thanks to Mario Pehle.
|
419
|
-
|
420
|
-
=== Changes for 0.8.6:
|
421
|
-
|
422
|
-
* Added missing test/test.mid.
|
423
|
-
|
424
|
-
=== Changes for 0.8.5:
|
425
|
-
|
426
|
-
* Fixed bugs in MIDI::PitchBend reading and writing, thanks to Emanuel
|
427
|
-
Borsboom.
|
428
|
-
|
429
|
-
* Fixed a bug in MIDI::Track#quantize.
|
430
|
-
|
431
|
-
* The argument to MIDI::Track#quantize has changed: it is now either a note
|
432
|
-
name ("sixteenth", "32nd", "8th triplet") or a length (1 = quarter, 0.25 =
|
433
|
-
sixteenth). This is a drastic change that will break all previous calls to
|
434
|
-
quantize. However, since that method was broken already, I don't feel it's
|
435
|
-
a burden to anybody to change the arguments.
|
436
|
-
|
437
|
-
=== Changes for 0.8.4:
|
438
|
-
|
439
|
-
* Realtime status bytes now set @is_realtime to true and return true when
|
440
|
-
realtime? is called.
|
441
|
-
|
442
|
-
* All system common events now set @is_system to true and return true when
|
443
|
-
system? is called, not just system exclusive events.
|
444
|
-
|
445
|
-
* Added examples/from_scratch.rb, which shows how to create a sequence
|
446
|
-
manually.
|
447
|
-
|
448
|
-
* New MIDI::Sequence methods that turn note length names like "32nd", "dotted
|
449
|
-
quarter", and "16th triplet" into delta times. See the docs below and
|
450
|
-
MIDI::Sequence::length_to_delta, MIDI::Sequence::note_to_length, and
|
451
|
-
MIDI::Sequence::note_to_delta.
|
452
|
-
|
453
|
-
|
454
|
-
=== Changes for 0.8.3:
|
455
|
-
|
456
|
-
* Added MIDI::NoteEvent.note_to_s, which returns note name as a string like
|
457
|
-
"C4" or "F#6".
|
458
|
-
|
459
|
-
* Added new boolean attributes to MIDI::Event: @print_decimal_numbers and
|
460
|
-
@print_note_names. These are used by all Event to_s methods. See
|
461
|
-
examples/seq2text.rb for an example.
|
462
|
-
|
463
|
-
=== Changes for 0.8.2:
|
464
|
-
|
465
|
-
* Changed MIDI::MetaEvent.type to MIDI::MetaEvent.event_type to avoid
|
466
|
-
runtime complaints about Object#type calls.
|
467
|
-
* Added 'b' binary flag to file open modes for Windows.
|
468
|
-
* Fixed $LOAD_PATH in example files.
|
469
|
-
* Fixed read and write block arguments.
|
470
|
-
* Fixed other example script bugs.
|
471
|
-
|
472
|
-
=== Changes for 0.8.1:
|
473
|
-
|
474
|
-
* Fixed track sorting.
|
475
|
-
* Fixed track's recalc_delta_from_times method.
|
476
|
-
* Fixed event quantization.
|
477
|
-
* More tests and documentation.
|
478
|
-
|
479
|
-
|
480
344
|
== Warranty
|
481
345
|
|
482
346
|
This software is provided "as is" and without any express or implied
|
data/Rakefile
CHANGED
@@ -33,7 +33,6 @@ spec = Gem::Specification.new do |s|
|
|
33
33
|
s.author = 'Jim Menard'
|
34
34
|
s.email = 'jim@jimmenard.com'
|
35
35
|
s.homepage = 'http://github.com/jimm/midilib'
|
36
|
-
s.rubyforge_project = PROJECT_NAME
|
37
36
|
s.license = 'Ruby'
|
38
37
|
|
39
38
|
s.summary = 'MIDI file and event manipulation library'
|
@@ -43,20 +42,11 @@ spec = Gem::Specification.new do |s|
|
|
43
42
|
EOF
|
44
43
|
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
pkg.need_tar = true
|
52
|
-
end
|
53
|
-
else
|
54
|
-
# Creates a :package task (also named :gem). Also useful are
|
55
|
-
# :clobber_package and :repackage.
|
56
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
57
|
-
pkg.need_zip = true
|
58
|
-
pkg.need_tar = true
|
59
|
-
end
|
45
|
+
# Creates a :package task (also named :gem). Also useful are
|
46
|
+
# :clobber_package and :repackage.
|
47
|
+
Gem::PackageTask.new(spec) do |pkg|
|
48
|
+
pkg.need_zip = true
|
49
|
+
pkg.need_tar = true
|
60
50
|
end
|
61
51
|
|
62
52
|
# creates an "rdoc" task
|
data/TODO.rdoc
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
== Bugs
|
2
2
|
|
3
3
|
midilib does not handle tempo changes when calculating +beats_per_minute+.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
See https://github.com/jimm/midilib/issues/8 which describes the issue. The
|
5
|
+
tempo events are correctly handled when reading/writing/moving them around,
|
6
|
+
it's just the functions that answer questions about the current tempo that
|
7
|
+
are wrong. See https://github.com/jimm/midilib/issues/8. The method
|
8
|
+
+beats_per_minute+ and related methods like +pulses_to_seconds+ will have to
|
9
|
+
take into account the possibility of more than one tempo event. They will
|
10
|
+
probably have to take new arguments specifying where in the sequence the
|
11
|
+
beats or pulses are being requested. For example we could have
|
11
12
|
+beats_per_minute(at_seconds: 0.0, at_beat: 0.0)+ (where the two keyword
|
12
13
|
args are mutually exclusive). Perhaps there should be separately named
|
13
14
|
public methods like +beats_per_minute_at_seconds+ and
|
data/examples/from_scratch.rb
CHANGED
@@ -5,13 +5,8 @@
|
|
5
5
|
# This script shows you how to create a new sequence from scratch and save it
|
6
6
|
# to a MIDI file. It creates a file called 'from_scratch.mid'.
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
# installed version out there somewhere.
|
11
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
12
|
-
|
13
|
-
require 'midilib/sequence'
|
14
|
-
require 'midilib/consts'
|
8
|
+
require_relative '../lib/midilib/sequence'
|
9
|
+
require_relative '../lib/midilib/consts'
|
15
10
|
include MIDI
|
16
11
|
|
17
12
|
seq = Sequence.new
|
data/examples/measures_mbt.rb
CHANGED
@@ -6,12 +6,7 @@
|
|
6
6
|
# in a "sequencer-style" manner:
|
7
7
|
# Measure:Beat:Tick Channel: Note-name
|
8
8
|
|
9
|
-
|
10
|
-
# This forces us to use the local copy, even if there is a previously
|
11
|
-
# installed version out there somewhere.
|
12
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
13
|
-
|
14
|
-
require 'midilib/sequence'
|
9
|
+
require_relative '../lib/midilib/sequence'
|
15
10
|
|
16
11
|
seq = MIDI::Sequence.new
|
17
12
|
File.open(ARGV[0], 'rb') { |file| seq.read(file) }
|
@@ -2,9 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Shows use of print_decimal_numbers and print_channel_numbers_from_one.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
require 'midilib/sequence'
|
5
|
+
require_relative '../lib/midilib/sequence'
|
8
6
|
|
9
7
|
DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
10
8
|
|
data/examples/reader2text.rb
CHANGED
@@ -9,13 +9,8 @@
|
|
9
9
|
# For a simpler way to do the same thing, see seq2text.rb.
|
10
10
|
#
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
# installed version out there somewhere.
|
15
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
16
|
-
|
17
|
-
require 'midilib/sequence'
|
18
|
-
require 'midilib/io/midifile'
|
12
|
+
require_relative '../lib/midilib/sequence'
|
13
|
+
require_relative '../lib/midilib/io/midifile'
|
19
14
|
|
20
15
|
DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
21
16
|
|
data/examples/seq2text.rb
CHANGED
@@ -9,12 +9,7 @@
|
|
9
9
|
# reader2tex.rb.
|
10
10
|
#
|
11
11
|
|
12
|
-
|
13
|
-
# This forces us to use the local copy, even if there is a previously
|
14
|
-
# installed version out there somewhere.
|
15
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
16
|
-
|
17
|
-
require 'midilib/sequence'
|
12
|
+
require_relative '../lib/midilib/sequence'
|
18
13
|
|
19
14
|
DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
20
15
|
|
data/examples/split.rb
CHANGED
@@ -9,12 +9,7 @@
|
|
9
9
|
# If -x is specified, the 0th temp track is not included in each file.
|
10
10
|
# Instead, it is output in a separate file named 'tempo_track.mid'.
|
11
11
|
|
12
|
-
|
13
|
-
# This forces us to use the local copy, even if there is a previously
|
14
|
-
# installed version out there somewhere.
|
15
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
16
|
-
|
17
|
-
require 'midilib/sequence'
|
12
|
+
require_relative '../lib/midilib/sequence'
|
18
13
|
|
19
14
|
DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
20
15
|
|
data/examples/strings.rb
CHANGED
@@ -5,13 +5,8 @@
|
|
5
5
|
# Prints all strings (track names, etc.) found in the MIDI file.
|
6
6
|
#
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
# installed version out there somewhere.
|
11
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
12
|
-
|
13
|
-
require 'midilib/sequence'
|
14
|
-
require 'midilib/consts'
|
8
|
+
require_relative '../lib/midilib/sequence'
|
9
|
+
require_relative '../lib/midilib/consts'
|
15
10
|
|
16
11
|
DEFAULT_MIDI_TEST_FILE = 'NoFences.mid'
|
17
12
|
|
data/examples/transpose.rb
CHANGED
@@ -7,15 +7,10 @@
|
|
7
7
|
# -t half_steps default = 12 (one octave up)
|
8
8
|
#
|
9
9
|
|
10
|
-
# Start looking for MIDI module classes in the directory above this one.
|
11
|
-
# This forces us to use the local copy, even if there is a previously
|
12
|
-
# installed version out there somewhere.
|
13
|
-
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
14
|
-
|
15
10
|
require 'getoptlong'
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
require_relative '../lib/midilib/sequence'
|
12
|
+
require_relative '../lib/midilib/io/seqreader'
|
13
|
+
require_relative '../lib/midilib/io/seqwriter'
|
19
14
|
|
20
15
|
def usage
|
21
16
|
$stderr.print <<~EOF
|
data/lib/midilib/consts.rb
CHANGED
@@ -77,6 +77,7 @@ module MIDI
|
|
77
77
|
# = 0 - 31 = continuous, MSB
|
78
78
|
# = 32 - 63 = continuous, LSB
|
79
79
|
# = 64 - 97 = switches
|
80
|
+
CC_BANK_MSB = 0
|
80
81
|
CC_MOD_WHEEL = 1
|
81
82
|
CC_BREATH_CONTROLLER = 2
|
82
83
|
CC_FOOT_CONTROLLER = 4
|
@@ -92,6 +93,7 @@ module MIDI
|
|
92
93
|
CC_GEN_PURPOSE_4 = 19
|
93
94
|
|
94
95
|
# [32 - 63] are LSB for [0 - 31]
|
96
|
+
CC_BANK_LSB = 32
|
95
97
|
CC_DATA_ENTRY_LSB = 38
|
96
98
|
|
97
99
|
#--
|
data/lib/midilib/event.rb
CHANGED
data/lib/midilib/info.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module MIDI
|
2
|
-
VERSION_MAJOR =
|
3
|
-
VERSION_MINOR =
|
4
|
-
VERSION_TWEAK =
|
2
|
+
VERSION_MAJOR = 4
|
3
|
+
VERSION_MINOR = 0
|
4
|
+
VERSION_TWEAK = 2
|
5
5
|
Version = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_TWEAK}"
|
6
|
-
Copyright = 'Copyright (c) 2003-
|
6
|
+
Copyright = 'Copyright (c) 2003-2023 by Jim Menard <jim@jimmenard.com>'
|
7
7
|
end
|
data/lib/midilib/io/seqreader.rb
CHANGED
@@ -8,16 +8,9 @@ module MIDI
|
|
8
8
|
# callback methods for each MIDI event and use them to build Track and
|
9
9
|
# Event objects and give the tracks to a Sequence.
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# the track's start (see end_track below).
|
15
|
-
#
|
16
|
-
# META_TRACK_END events are not added to tracks. This way, we don't have
|
17
|
-
# to worry about making sure the last event is always a track end event.
|
18
|
-
# We rely on the SeqWriter to append a META_TRACK_END event to each
|
19
|
-
# track when it is output.
|
20
|
-
|
11
|
+
# Ensures that each track ends with an end of track meta event, and that
|
12
|
+
# Track#recalc_times is called at the end of the track so it can update
|
13
|
+
# each event with its time from the track's start (see end_track below).
|
21
14
|
class SeqReader < MIDIFile
|
22
15
|
# The optional &block is called once at the start of the file and
|
23
16
|
# again at the end of each track. There are three arguments to the
|
@@ -51,12 +44,9 @@ module MIDI
|
|
51
44
|
@pending.each { |on| make_note_off(on, 64) }
|
52
45
|
@pending = nil
|
53
46
|
|
54
|
-
#
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
# Let the track calculate event times from start of track. This is
|
59
|
-
# in lieu of calling Track.add for each event.
|
47
|
+
# Make sure track has an end of track event and that all of the
|
48
|
+
# `time_from_start` values are correct.
|
49
|
+
@track.ensure_track_end_meta_event
|
60
50
|
@track.recalc_times
|
61
51
|
|
62
52
|
# Store bitmask of all channels used into track
|
@@ -102,7 +92,7 @@ module MIDI
|
|
102
92
|
|
103
93
|
if $DEBUG
|
104
94
|
warn "note off with no earlier note on (ch #{chan}, note" +
|
105
|
-
|
95
|
+
" #{note}, vel #{vel})"
|
106
96
|
end
|
107
97
|
end
|
108
98
|
end
|
@@ -143,6 +133,10 @@ module MIDI
|
|
143
133
|
@track.events << SystemExclusive.new(msg, @curr_ticks)
|
144
134
|
end
|
145
135
|
|
136
|
+
def eot
|
137
|
+
@track.events << MetaEvent.new(META_TRACK_END, nil, @curr_ticks)
|
138
|
+
end
|
139
|
+
|
146
140
|
def meta_misc(type, msg)
|
147
141
|
@track.events << MetaEvent.new(type, msg, @curr_ticks)
|
148
142
|
end
|
@@ -168,16 +162,6 @@ module MIDI
|
|
168
162
|
end
|
169
163
|
end
|
170
164
|
|
171
|
-
# --
|
172
|
-
# Don't bother adding the META_TRACK_END event to the track. This way,
|
173
|
-
# we don't have to worry about always making sure the last event is
|
174
|
-
# always a track end event. We just have to make sure to write one when
|
175
|
-
# the track is output back to a file.
|
176
|
-
# def eot()
|
177
|
-
# @track.events << MetaEvent.new(META_TRACK_END, nil, @curr_ticks)
|
178
|
-
# end
|
179
|
-
# ++
|
180
|
-
|
181
165
|
def time_signature(numer, denom, clocks, qnotes)
|
182
166
|
@seq.time_signature(numer, denom, clocks, qnotes)
|
183
167
|
@track.events << TimeSig.new(numer, denom, clocks, qnotes, @curr_ticks)
|
data/lib/midilib/io/seqwriter.rb
CHANGED
@@ -66,10 +66,12 @@ module MIDI
|
|
66
66
|
prev_status = status
|
67
67
|
end
|
68
68
|
|
69
|
-
# Write track end event.
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
# Write track end event if the track doesn't have one.
|
70
|
+
unless track.events.last.is_a?(MetaEvent) && track.events.last.meta_type == META_TRACK_END
|
71
|
+
event = MetaEvent.new(META_TRACK_END)
|
72
|
+
write_var_len(0)
|
73
|
+
@bytes_written += write_bytes(event.data_as_bytes)
|
74
|
+
end
|
73
75
|
|
74
76
|
# Go back to beginning of track data and write number of bytes,
|
75
77
|
# then come back here to end of file.
|