midilib 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Credits +5 -0
  3. data/html/MIDI/ActiveSense.html +171 -0
  4. data/html/MIDI/ChannelEvent.html +190 -0
  5. data/html/MIDI/ChannelPressure.html +212 -0
  6. data/html/MIDI/Clock.html +171 -0
  7. data/html/MIDI/Continue.html +171 -0
  8. data/html/MIDI/Controller.html +224 -0
  9. data/html/MIDI/Event.html +349 -0
  10. data/html/MIDI/IO/MIDIFile.html +1392 -0
  11. data/html/MIDI/IO/SeqReader.html +642 -0
  12. data/html/MIDI/IO/SeqWriter.html +442 -0
  13. data/html/MIDI/IO.html +91 -0
  14. data/html/MIDI/KeySig.html +292 -0
  15. data/html/MIDI/Marker.html +138 -0
  16. data/html/MIDI/Measure.html +260 -0
  17. data/html/MIDI/Measures.html +222 -0
  18. data/html/MIDI/MetaEvent.html +353 -0
  19. data/html/MIDI/NoteEvent.html +255 -0
  20. data/html/MIDI/NoteOff.html +188 -0
  21. data/html/MIDI/NoteOn.html +188 -0
  22. data/html/MIDI/PitchBend.html +213 -0
  23. data/html/MIDI/PolyPressure.html +216 -0
  24. data/html/MIDI/ProgramChange.html +212 -0
  25. data/html/MIDI/Realtime.html +194 -0
  26. data/html/MIDI/Sequence.html +641 -0
  27. data/html/MIDI/SongPointer.html +213 -0
  28. data/html/MIDI/SongSelect.html +212 -0
  29. data/html/MIDI/Start.html +171 -0
  30. data/html/MIDI/Stop.html +171 -0
  31. data/html/MIDI/SystemCommon.html +138 -0
  32. data/html/MIDI/SystemExclusive.html +215 -0
  33. data/html/MIDI/SystemReset.html +171 -0
  34. data/html/MIDI/Tempo.html +292 -0
  35. data/html/MIDI/TimeSig.html +286 -0
  36. data/html/MIDI/Track.html +489 -0
  37. data/html/MIDI/TuneRequest.html +194 -0
  38. data/html/MIDI/Utils.html +178 -0
  39. data/html/MIDI.html +281 -0
  40. data/html/Object.html +197 -0
  41. data/html/README_rdoc.html +545 -0
  42. data/html/TODO_rdoc.html +123 -0
  43. data/html/created.rid +15 -0
  44. data/html/css/fonts.css +167 -0
  45. data/html/css/rdoc.css +639 -0
  46. data/html/fonts/Lato-Light.ttf +0 -0
  47. data/html/fonts/Lato-LightItalic.ttf +0 -0
  48. data/html/fonts/Lato-Regular.ttf +0 -0
  49. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  50. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  51. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  52. data/html/images/add.png +0 -0
  53. data/html/images/arrow_up.png +0 -0
  54. data/html/images/brick.png +0 -0
  55. data/html/images/brick_link.png +0 -0
  56. data/html/images/bug.png +0 -0
  57. data/html/images/bullet_black.png +0 -0
  58. data/html/images/bullet_toggle_minus.png +0 -0
  59. data/html/images/bullet_toggle_plus.png +0 -0
  60. data/html/images/date.png +0 -0
  61. data/html/images/delete.png +0 -0
  62. data/html/images/find.png +0 -0
  63. data/html/images/loadingAnimation.gif +0 -0
  64. data/html/images/macFFBgHack.png +0 -0
  65. data/html/images/package.png +0 -0
  66. data/html/images/page_green.png +0 -0
  67. data/html/images/page_white_text.png +0 -0
  68. data/html/images/page_white_width.png +0 -0
  69. data/html/images/plugin.png +0 -0
  70. data/html/images/ruby.png +0 -0
  71. data/html/images/tag_blue.png +0 -0
  72. data/html/images/tag_green.png +0 -0
  73. data/html/images/transparent.png +0 -0
  74. data/html/images/wrench.png +0 -0
  75. data/html/images/wrench_orange.png +0 -0
  76. data/html/images/zoom.png +0 -0
  77. data/html/index.html +534 -0
  78. data/html/js/darkfish.js +84 -0
  79. data/html/js/navigation.js +105 -0
  80. data/html/js/navigation.js.gz +0 -0
  81. data/html/js/search.js +110 -0
  82. data/html/js/search_index.js +1 -0
  83. data/html/js/search_index.js.gz +0 -0
  84. data/html/js/searcher.js +229 -0
  85. data/html/js/searcher.js.gz +0 -0
  86. data/html/table_of_contents.html +1258 -0
  87. data/lib/midilib/info.rb +2 -2
  88. data/lib/midilib/io/seqreader.rb +18 -5
  89. data/test/test_io.rb +18 -5
  90. metadata +85 -1
data/lib/midilib/info.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module MIDI
2
2
  VERSION_MAJOR = 3
3
- VERSION_MINOR = 0
4
- VERSION_TWEAK = 1
3
+ VERSION_MINOR = 1
4
+ VERSION_TWEAK = 0
5
5
  Version = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_TWEAK}"
6
6
  Copyright = 'Copyright (c) 2003-2022 by Jim Menard <jim@jimmenard.com>'
7
7
  end
@@ -81,16 +81,29 @@ module MIDI
81
81
  def note_off(chan, note, vel)
82
82
  # Find note on, create note off, connect the two, and remove
83
83
  # note on from pending list.
84
+
85
+ corresp_note_on = nil
86
+
84
87
  @pending.each_with_index do |on, i|
85
88
  next unless on.note == note && on.channel == chan
86
89
 
87
- make_note_off(on, vel)
88
90
  @pending.delete_at(i)
89
- return
91
+ corresp_note_on = on
92
+ break
90
93
  end
91
- if $DEBUG
92
- warn "note off with no earlier note on (ch #{chan}, note" +
93
- " #{note}, vel #{vel})"
94
+
95
+ if corresp_note_on
96
+ make_note_off(corresp_note_on, vel)
97
+ else
98
+ # When a corresponding note on is missing,
99
+ # keep note off as input with lefting on/off attr to nil.
100
+ off = NoteOff.new(chan, note, vel, @curr_ticks)
101
+ @track.events << off
102
+
103
+ if $DEBUG
104
+ warn "note off with no earlier note on (ch #{chan}, note" +
105
+ " #{note}, vel #{vel})"
106
+ end
94
107
  end
95
108
  end
96
109
 
data/test/test_io.rb CHANGED
@@ -101,17 +101,30 @@ class IOTester < Test::Unit::TestCase
101
101
  assert_equal(MIDI::GM_PATCH_NAMES[0], seq.tracks[1].instrument)
102
102
  end
103
103
 
104
- def test_preserve_meta_deltas
104
+ def test_preserve_deltas_in_some_situations
105
105
  out_seq = MIDI::Sequence.new
106
106
  out_track = MIDI::Track.new(out_seq)
107
107
  out_seq.tracks << out_track
108
108
  out_track.events << MIDI::Tempo.new(MIDI::Tempo.bpm_to_mpq(120))
109
+
110
+ # 1) The meta events with non-zero delta time
109
111
  # Normally copyright and sequence name events are at time 0, but non-zero
110
112
  # 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)
113
+ begin
114
+ out_track.events << MIDI::MetaEvent.new(MIDI::META_COPYRIGHT, '(C) 1950 Donald Duck', 100)
115
+ out_track.events << MIDI::MetaEvent.new(MIDI::META_SEQ_NAME, 'Quack, Track 1', 200)
116
+ out_track.events << MIDI::NoteOn.new(0, 64, 127, 0)
117
+ out_track.events << MIDI::NoteOff.new(0, 64, 127, 100)
118
+ end
119
+
120
+ # 2) The unusual note off event with non-zero delta time
121
+ begin
122
+ out_track.events << MIDI::NoteOff.new(0, 65, 127, 120)
123
+ out_track.events << MIDI::NoteOn.new(0, 65, 127, 0)
124
+ # Add note off (which will be complemented at #end_track if missing) for later comparison.
125
+ out_track.events << MIDI::NoteOff.new(0, 65, 127, 230)
126
+ end
127
+
115
128
  File.open('/tmp/midilib_test.mid', 'wb') { |file| out_seq.write(file) }
116
129
 
117
130
  # Although start times are not written out to the MIDI file, we
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midilib
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Menard
@@ -35,6 +35,90 @@ files:
35
35
  - examples/split.rb
36
36
  - examples/strings.rb
37
37
  - examples/transpose.rb
38
+ - html/MIDI.html
39
+ - html/MIDI/ActiveSense.html
40
+ - html/MIDI/ChannelEvent.html
41
+ - html/MIDI/ChannelPressure.html
42
+ - html/MIDI/Clock.html
43
+ - html/MIDI/Continue.html
44
+ - html/MIDI/Controller.html
45
+ - html/MIDI/Event.html
46
+ - html/MIDI/IO.html
47
+ - html/MIDI/IO/MIDIFile.html
48
+ - html/MIDI/IO/SeqReader.html
49
+ - html/MIDI/IO/SeqWriter.html
50
+ - html/MIDI/KeySig.html
51
+ - html/MIDI/Marker.html
52
+ - html/MIDI/Measure.html
53
+ - html/MIDI/Measures.html
54
+ - html/MIDI/MetaEvent.html
55
+ - html/MIDI/NoteEvent.html
56
+ - html/MIDI/NoteOff.html
57
+ - html/MIDI/NoteOn.html
58
+ - html/MIDI/PitchBend.html
59
+ - html/MIDI/PolyPressure.html
60
+ - html/MIDI/ProgramChange.html
61
+ - html/MIDI/Realtime.html
62
+ - html/MIDI/Sequence.html
63
+ - html/MIDI/SongPointer.html
64
+ - html/MIDI/SongSelect.html
65
+ - html/MIDI/Start.html
66
+ - html/MIDI/Stop.html
67
+ - html/MIDI/SystemCommon.html
68
+ - html/MIDI/SystemExclusive.html
69
+ - html/MIDI/SystemReset.html
70
+ - html/MIDI/Tempo.html
71
+ - html/MIDI/TimeSig.html
72
+ - html/MIDI/Track.html
73
+ - html/MIDI/TuneRequest.html
74
+ - html/MIDI/Utils.html
75
+ - html/Object.html
76
+ - html/README_rdoc.html
77
+ - html/TODO_rdoc.html
78
+ - html/created.rid
79
+ - html/css/fonts.css
80
+ - html/css/rdoc.css
81
+ - html/fonts/Lato-Light.ttf
82
+ - html/fonts/Lato-LightItalic.ttf
83
+ - html/fonts/Lato-Regular.ttf
84
+ - html/fonts/Lato-RegularItalic.ttf
85
+ - html/fonts/SourceCodePro-Bold.ttf
86
+ - html/fonts/SourceCodePro-Regular.ttf
87
+ - html/images/add.png
88
+ - html/images/arrow_up.png
89
+ - html/images/brick.png
90
+ - html/images/brick_link.png
91
+ - html/images/bug.png
92
+ - html/images/bullet_black.png
93
+ - html/images/bullet_toggle_minus.png
94
+ - html/images/bullet_toggle_plus.png
95
+ - html/images/date.png
96
+ - html/images/delete.png
97
+ - html/images/find.png
98
+ - html/images/loadingAnimation.gif
99
+ - html/images/macFFBgHack.png
100
+ - html/images/package.png
101
+ - html/images/page_green.png
102
+ - html/images/page_white_text.png
103
+ - html/images/page_white_width.png
104
+ - html/images/plugin.png
105
+ - html/images/ruby.png
106
+ - html/images/tag_blue.png
107
+ - html/images/tag_green.png
108
+ - html/images/transparent.png
109
+ - html/images/wrench.png
110
+ - html/images/wrench_orange.png
111
+ - html/images/zoom.png
112
+ - html/index.html
113
+ - html/js/darkfish.js
114
+ - html/js/navigation.js
115
+ - html/js/navigation.js.gz
116
+ - html/js/search.js
117
+ - html/js/search_index.js
118
+ - html/js/search_index.js.gz
119
+ - html/js/searcher.js
120
+ - html/js/searcher.js.gz
121
+ - html/table_of_contents.html
38
122
  - install.rb
39
123
  - lib/midilib.rb
40
124
  - lib/midilib/consts.rb