midilib 1.1.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{README → README.rdoc} +12 -3
- data/Rakefile +11 -5
- data/TODO.rdoc +31 -0
- data/html/classes/IO.html +137 -0
- data/html/classes/IO.src/M000001.html +20 -0
- data/html/classes/MIDI/ActiveSense.html +10 -10
- data/html/classes/MIDI/ActiveSense.src/{M000158.html → M000160.html} +1 -1
- data/html/classes/MIDI/ActiveSense.src/{M000159.html → M000161.html} +1 -1
- data/html/classes/MIDI/ChannelEvent.html +10 -10
- data/html/classes/MIDI/ChannelEvent.src/{M000130.html → M000132.html} +0 -0
- data/html/classes/MIDI/ChannelEvent.src/{M000131.html → M000133.html} +0 -0
- data/html/classes/MIDI/ChannelPressure.html +15 -15
- data/html/classes/MIDI/ChannelPressure.src/M000092.html +5 -4
- data/html/classes/MIDI/ChannelPressure.src/{M000091.html → M000093.html} +2 -3
- data/html/classes/MIDI/ChannelPressure.src/M000094.html +18 -0
- data/html/classes/MIDI/Clock.html +10 -10
- data/html/classes/MIDI/Clock.src/{M000146.html → M000148.html} +1 -1
- data/html/classes/MIDI/Clock.src/{M000147.html → M000149.html} +1 -1
- data/html/classes/MIDI/Continue.html +10 -10
- data/html/classes/MIDI/Continue.src/{M000144.html → M000146.html} +1 -1
- data/html/classes/MIDI/Continue.src/{M000145.html → M000147.html} +1 -1
- data/html/classes/MIDI/Controller.html +15 -15
- data/html/classes/MIDI/Controller.src/M000137.html +7 -4
- data/html/classes/MIDI/Controller.src/{M000136.html → M000138.html} +2 -3
- data/html/classes/MIDI/Controller.src/M000139.html +18 -0
- data/html/classes/MIDI/Event.html +90 -90
- data/html/classes/MIDI/Event.src/M000169.html +16 -4
- data/html/classes/MIDI/Event.src/M000170.html +4 -4
- data/html/classes/MIDI/Event.src/M000171.html +4 -4
- data/html/classes/MIDI/Event.src/M000172.html +4 -4
- data/html/classes/MIDI/Event.src/M000173.html +4 -4
- data/html/classes/MIDI/Event.src/M000174.html +4 -4
- data/html/classes/MIDI/Event.src/M000175.html +4 -4
- data/html/classes/MIDI/Event.src/M000176.html +4 -4
- data/html/classes/MIDI/Event.src/M000177.html +4 -4
- data/html/classes/MIDI/Event.src/M000178.html +4 -4
- data/html/classes/MIDI/Event.src/M000179.html +4 -8
- data/html/classes/MIDI/Event.src/M000180.html +4 -4
- data/html/classes/MIDI/Event.src/M000181.html +8 -4
- data/html/classes/MIDI/Event.src/M000182.html +4 -5
- data/html/classes/MIDI/Event.src/M000183.html +4 -4
- data/html/classes/MIDI/Event.src/M000184.html +19 -0
- data/html/classes/MIDI/{PolyPressure.src/M000197.html → Event.src/M000185.html} +4 -4
- data/html/classes/MIDI/IO/MIDIFile.html +247 -230
- data/html/classes/MIDI/IO/MIDIFile.src/M000031.html +9 -6
- data/html/classes/MIDI/IO/MIDIFile.src/M000032.html +11 -6
- data/html/classes/MIDI/IO/MIDIFile.src/M000033.html +4 -4
- data/html/classes/MIDI/IO/MIDIFile.src/M000034.html +6 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000035.html +5 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000036.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000037.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000038.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000039.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000040.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000041.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000042.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000043.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000044.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000045.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000046.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000047.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000048.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000049.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000050.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000051.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000052.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000053.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000054.html +3 -3
- data/html/classes/MIDI/IO/MIDIFile.src/M000055.html +3 -29
- data/html/classes/MIDI/IO/MIDIFile.src/M000056.html +3 -20
- data/html/classes/MIDI/IO/MIDIFile.src/M000057.html +21 -74
- data/html/classes/MIDI/IO/MIDIFile.src/M000058.html +20 -4
- data/html/classes/MIDI/IO/MIDIFile.src/M000059.html +81 -33
- data/html/classes/MIDI/IO/MIDIFile.src/M000060.html +4 -28
- data/html/classes/MIDI/IO/MIDIFile.src/M000061.html +35 -5
- data/html/classes/MIDI/IO/MIDIFile.src/M000062.html +28 -5
- data/html/classes/MIDI/IO/MIDIFile.src/M000063.html +5 -6
- data/html/classes/MIDI/IO/MIDIFile.src/M000064.html +5 -7
- data/html/classes/MIDI/IO/MIDIFile.src/M000065.html +5 -16
- data/html/classes/MIDI/IO/MIDIFile.src/M000066.html +7 -6
- data/html/classes/MIDI/IO/MIDIFile.src/M000067.html +17 -8
- data/html/classes/MIDI/IO/MIDIFile.src/M000068.html +6 -16
- data/html/classes/MIDI/IO/MIDIFile.src/M000069.html +8 -4
- data/html/classes/MIDI/IO/MIDIFile.src/M000070.html +16 -6
- data/html/classes/MIDI/IO/MIDIFile.src/M000071.html +4 -4
- data/html/classes/MIDI/IO/MIDIFile.src/M000072.html +6 -4
- data/html/classes/MIDI/IO/MIDIFile.src/{M000029.html → M000073.html} +4 -8
- data/html/classes/MIDI/IO/MIDIFile.src/M000074.html +18 -0
- data/html/classes/MIDI/IO/SeqReader.html +98 -98
- data/html/classes/MIDI/IO/SeqReader.src/M000002.html +8 -8
- data/html/classes/MIDI/IO/SeqReader.src/M000003.html +7 -6
- data/html/classes/MIDI/IO/SeqReader.src/M000004.html +6 -19
- data/html/classes/MIDI/IO/SeqReader.src/M000005.html +19 -11
- data/html/classes/MIDI/IO/SeqReader.src/M000006.html +12 -14
- data/html/classes/MIDI/IO/SeqReader.src/M000007.html +14 -7
- data/html/classes/MIDI/IO/SeqReader.src/M000008.html +7 -5
- data/html/classes/MIDI/IO/SeqReader.src/M000009.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000010.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000011.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000012.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000013.html +5 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000014.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000015.html +4 -15
- data/html/classes/MIDI/IO/SeqReader.src/M000016.html +15 -5
- data/html/classes/MIDI/IO/SeqReader.src/M000017.html +5 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000018.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000019.html +4 -4
- data/html/classes/MIDI/IO/SeqReader.src/M000020.html +18 -0
- data/html/classes/MIDI/IO/SeqWriter.html +60 -45
- data/html/classes/MIDI/IO/SeqWriter.src/M000021.html +5 -11
- data/html/classes/MIDI/IO/SeqWriter.src/M000022.html +11 -8
- data/html/classes/MIDI/IO/SeqWriter.src/M000023.html +8 -40
- data/html/classes/MIDI/IO/SeqWriter.src/M000024.html +39 -34
- data/html/classes/MIDI/IO/SeqWriter.src/M000025.html +35 -7
- data/html/classes/MIDI/IO/SeqWriter.src/M000026.html +7 -5
- data/html/classes/MIDI/IO/SeqWriter.src/M000027.html +5 -10
- data/html/classes/MIDI/IO/SeqWriter.src/M000028.html +8 -11
- data/html/classes/MIDI/IO/SeqWriter.src/M000029.html +24 -0
- data/html/classes/MIDI/IO/SeqWriter.src/M000030.html +19 -0
- data/html/classes/MIDI/KeySig.html +30 -30
- data/html/classes/MIDI/KeySig.src/M000140.html +5 -4
- data/html/classes/MIDI/KeySig.src/M000141.html +9 -4
- data/html/classes/MIDI/KeySig.src/M000142.html +4 -4
- data/html/classes/MIDI/KeySig.src/M000143.html +4 -9
- data/html/classes/MIDI/KeySig.src/M000144.html +18 -0
- data/html/classes/MIDI/KeySig.src/M000145.html +23 -0
- data/html/classes/MIDI/Marker.html +5 -5
- data/html/classes/MIDI/Marker.src/{M000112.html → M000114.html} +1 -1
- data/html/classes/MIDI/Measure.html +15 -15
- data/html/classes/MIDI/Measure.src/M000150.html +9 -4
- data/html/classes/MIDI/Measure.src/{M000149.html → M000151.html} +0 -0
- data/html/classes/MIDI/Measure.src/M000152.html +18 -0
- data/html/classes/MIDI/Measures.html +15 -15
- data/html/classes/MIDI/Measures.src/M000108.html +6 -7
- data/html/classes/MIDI/Measures.src/{M000107.html → M000109.html} +0 -0
- data/html/classes/MIDI/Measures.src/M000110.html +21 -0
- data/html/classes/MIDI/MetaEvent.html +15 -15
- data/html/classes/MIDI/MetaEvent.src/M000195.html +7 -39
- data/html/classes/MIDI/MetaEvent.src/{M000194.html → M000196.html} +3 -3
- data/html/classes/MIDI/MetaEvent.src/M000197.html +53 -0
- data/html/classes/MIDI/NoteEvent.html +21 -21
- data/html/classes/MIDI/NoteEvent.src/M000095.html +7 -4
- data/html/classes/MIDI/NoteEvent.src/M000096.html +6 -8
- data/html/classes/MIDI/NoteEvent.src/M000097.html +18 -0
- data/html/classes/MIDI/NoteEvent.src/M000098.html +21 -0
- data/html/classes/MIDI/NoteOffEvent.html +10 -10
- data/html/classes/MIDI/NoteOffEvent.src/{M000088.html → M000090.html} +1 -1
- data/html/classes/MIDI/NoteOffEvent.src/{M000089.html → M000091.html} +1 -1
- data/html/classes/MIDI/NoteOnEvent.html +10 -10
- data/html/classes/MIDI/NoteOnEvent.src/{M000104.html → M000106.html} +1 -1
- data/html/classes/MIDI/NoteOnEvent.src/{M000105.html → M000107.html} +1 -1
- data/html/classes/MIDI/PitchBend.html +15 -15
- data/html/classes/MIDI/PitchBend.src/M000111.html +5 -4
- data/html/classes/MIDI/PitchBend.src/{M000110.html → M000112.html} +2 -3
- data/html/classes/MIDI/PitchBend.src/M000113.html +18 -0
- data/html/classes/MIDI/PolyPressure.html +20 -20
- data/html/classes/MIDI/PolyPressure.src/M000198.html +4 -4
- data/html/classes/MIDI/PolyPressure.src/M000199.html +4 -5
- data/html/classes/MIDI/PolyPressure.src/M000200.html +18 -0
- data/html/classes/MIDI/PolyPressure.src/M000201.html +19 -0
- data/html/classes/MIDI/ProgramChange.html +15 -15
- data/html/classes/MIDI/ProgramChange.src/M000103.html +6 -4
- data/html/classes/MIDI/ProgramChange.src/{M000102.html → M000104.html} +2 -3
- data/html/classes/MIDI/ProgramChange.src/M000105.html +18 -0
- data/html/classes/MIDI/Realtime.html +15 -15
- data/html/classes/MIDI/Realtime.src/M000087.html +5 -4
- data/html/classes/MIDI/Realtime.src/{M000086.html → M000088.html} +2 -3
- data/html/classes/MIDI/Realtime.src/M000089.html +18 -0
- data/html/classes/MIDI/Sequence.html +76 -76
- data/html/classes/MIDI/Sequence.src/M000115.html +14 -8
- data/html/classes/MIDI/Sequence.src/{M000114.html → M000116.html} +0 -0
- data/html/classes/MIDI/Sequence.src/M000117.html +22 -0
- data/html/classes/MIDI/Sequence.src/M000120.html +4 -4
- data/html/classes/MIDI/Sequence.src/M000121.html +13 -5
- data/html/classes/MIDI/Sequence.src/M000122.html +4 -5
- data/html/classes/MIDI/Sequence.src/M000123.html +5 -5
- data/html/classes/MIDI/Sequence.src/M000124.html +5 -5
- data/html/classes/MIDI/Sequence.src/M000125.html +5 -4
- data/html/classes/MIDI/Sequence.src/M000126.html +5 -40
- data/html/classes/MIDI/Sequence.src/{M000118.html → M000127.html} +4 -4
- data/html/classes/MIDI/Sequence.src/M000128.html +54 -0
- data/html/classes/MIDI/SongPointer.html +15 -15
- data/html/classes/MIDI/SongPointer.src/M000162.html +5 -4
- data/html/classes/MIDI/SongPointer.src/{M000161.html → M000163.html} +2 -3
- data/html/classes/MIDI/SongPointer.src/M000164.html +18 -0
- data/html/classes/MIDI/SongSelect.html +15 -15
- data/html/classes/MIDI/SongSelect.src/M000134.html +5 -4
- data/html/classes/MIDI/SongSelect.src/{M000133.html → M000135.html} +2 -3
- data/html/classes/MIDI/SongSelect.src/M000136.html +18 -0
- data/html/classes/MIDI/Start.html +10 -10
- data/html/classes/MIDI/Start.src/{M000099.html → M000101.html} +1 -1
- data/html/classes/MIDI/Start.src/{M000100.html → M000102.html} +1 -1
- data/html/classes/MIDI/Stop.html +10 -10
- data/html/classes/MIDI/Stop.src/{M000097.html → M000099.html} +1 -1
- data/html/classes/MIDI/Stop.src/{M000098.html → M000100.html} +1 -1
- data/html/classes/MIDI/SystemCommon.html +5 -5
- data/html/classes/MIDI/SystemCommon.src/{M000166.html → M000168.html} +1 -1
- data/html/classes/MIDI/SystemExclusive.html +15 -15
- data/html/classes/MIDI/SystemExclusive.src/M000165.html +5 -4
- data/html/classes/MIDI/SystemExclusive.src/{M000164.html → M000166.html} +3 -3
- data/html/classes/MIDI/SystemExclusive.src/M000167.html +18 -0
- data/html/classes/MIDI/SystemReset.html +10 -10
- data/html/classes/MIDI/SystemReset.src/{M000083.html → M000085.html} +1 -1
- data/html/classes/MIDI/SystemReset.src/{M000084.html → M000086.html} +1 -1
- data/html/classes/MIDI/Tempo.html +35 -35
- data/html/classes/MIDI/Tempo.src/M000186.html +4 -4
- data/html/classes/MIDI/Tempo.src/M000187.html +6 -4
- data/html/classes/MIDI/Tempo.src/M000188.html +4 -4
- data/html/classes/MIDI/Tempo.src/M000189.html +4 -11
- data/html/classes/MIDI/Tempo.src/M000190.html +4 -4
- data/html/classes/MIDI/{TimeSig.src/M000152.html → Tempo.src/M000191.html} +7 -8
- data/html/classes/MIDI/{Event.src/M000168.html → Tempo.src/M000192.html} +4 -4
- data/html/classes/MIDI/TimeSig.html +37 -37
- data/html/classes/MIDI/TimeSig.src/M000153.html +5 -4
- data/html/classes/MIDI/TimeSig.src/M000154.html +11 -4
- data/html/classes/MIDI/TimeSig.src/M000155.html +4 -4
- data/html/classes/MIDI/TimeSig.src/M000156.html +4 -4
- data/html/classes/MIDI/TimeSig.src/M000157.html +4 -4
- data/html/classes/MIDI/TimeSig.src/M000158.html +18 -0
- data/html/classes/MIDI/TimeSig.src/M000159.html +18 -0
- data/html/classes/MIDI/Track.html +66 -66
- data/html/classes/MIDI/Track.src/M000075.html +9 -12
- data/html/classes/MIDI/Track.src/M000076.html +7 -4
- data/html/classes/MIDI/Track.src/M000077.html +12 -8
- data/html/classes/MIDI/Track.src/M000078.html +4 -11
- data/html/classes/MIDI/Track.src/M000079.html +8 -8
- data/html/classes/MIDI/Track.src/M000080.html +11 -12
- data/html/classes/MIDI/Track.src/M000081.html +8 -4
- data/html/classes/MIDI/Track.src/M000082.html +12 -5
- data/html/classes/MIDI/Track.src/M000083.html +18 -0
- data/html/classes/MIDI/Track.src/{M000073.html → M000084.html} +5 -9
- data/html/classes/MIDI/TuneRequest.html +15 -15
- data/html/classes/MIDI/TuneRequest.src/M000129.html +4 -4
- data/html/classes/MIDI/TuneRequest.src/{M000128.html → M000130.html} +2 -3
- data/html/classes/MIDI/TuneRequest.src/M000131.html +18 -0
- data/html/classes/MIDI/Utils.html +10 -10
- data/html/classes/MIDI/Utils.src/{M000191.html → M000193.html} +0 -0
- data/html/classes/MIDI/Utils.src/{M000192.html → M000194.html} +1 -1
- data/html/classes/MIDI.html +3 -3
- data/html/created.rid +1 -1
- data/html/files/{README.html → README_rdoc.html} +30 -11
- data/html/files/{TODO.html → TODO_rdoc.html} +14 -6
- data/html/files/lib/midilib/consts_rb.html +1 -1
- data/html/files/lib/midilib/event_rb.html +1 -1
- data/html/files/lib/midilib/info_rb.html +1 -1
- data/html/files/lib/midilib/io/midifile_rb.html +1 -1
- data/html/files/lib/midilib/io/seqreader_rb.html +1 -1
- data/html/files/lib/midilib/io/seqwriter_rb.html +1 -1
- data/html/files/lib/midilib/measure_rb.html +1 -1
- data/html/files/lib/midilib/sequence_rb.html +1 -1
- data/html/files/lib/midilib/track_rb.html +1 -1
- data/html/files/lib/midilib/utils_rb.html +1 -1
- data/html/files/lib/midilib_rb.html +2 -2
- data/html/fr_class_index.html +1 -0
- data/html/fr_file_index.html +2 -2
- data/html/fr_method_index.html +201 -199
- data/html/index.html +1 -1
- data/install.rb +1 -1
- data/lib/midilib/event.rb +16 -26
- data/lib/midilib/info.rb +3 -3
- data/lib/midilib/io/midifile.rb +43 -29
- data/lib/midilib/io/seqwriter.rb +19 -17
- data/lib/midilib/utils.rb +1 -1
- data/lib/midilib.rb +1 -1
- data/test/test_io.rb +2 -1
- data/test/test_midifile.rb +59 -0
- data/test/test_varlen.rb +4 -4
- metadata +83 -78
- data/TODO +0 -25
- data/html/classes/MIDI/ChannelPressure.src/M000090.html +0 -19
- data/html/classes/MIDI/Controller.src/M000135.html +0 -21
- data/html/classes/MIDI/Event.src/M000167.html +0 -30
- data/html/classes/MIDI/IO/MIDIFile.src/M000030.html +0 -24
- data/html/classes/MIDI/IO/SeqReader.src/M000001.html +0 -22
- data/html/classes/MIDI/IO/SeqWriter.src/M000020.html +0 -19
- data/html/classes/MIDI/KeySig.src/M000138.html +0 -19
- data/html/classes/MIDI/KeySig.src/M000139.html +0 -23
- data/html/classes/MIDI/Measure.src/M000148.html +0 -23
- data/html/classes/MIDI/Measures.src/M000106.html +0 -20
- data/html/classes/MIDI/MetaEvent.src/M000193.html +0 -21
- data/html/classes/MIDI/NoteEvent.src/M000093.html +0 -21
- data/html/classes/MIDI/NoteEvent.src/M000094.html +0 -20
- data/html/classes/MIDI/PitchBend.src/M000109.html +0 -19
- data/html/classes/MIDI/PolyPressure.src/M000196.html +0 -18
- data/html/classes/MIDI/ProgramChange.src/M000101.html +0 -20
- data/html/classes/MIDI/Realtime.src/M000085.html +0 -19
- data/html/classes/MIDI/Sequence.src/M000113.html +0 -28
- data/html/classes/MIDI/Sequence.src/M000119.html +0 -27
- data/html/classes/MIDI/SongPointer.src/M000160.html +0 -19
- data/html/classes/MIDI/SongSelect.src/M000132.html +0 -19
- data/html/classes/MIDI/SystemExclusive.src/M000163.html +0 -19
- data/html/classes/MIDI/Tempo.src/M000184.html +0 -18
- data/html/classes/MIDI/Tempo.src/M000185.html +0 -20
- data/html/classes/MIDI/TimeSig.src/M000151.html +0 -19
- data/html/classes/MIDI/Track.src/M000074.html +0 -21
- data/html/classes/MIDI/TuneRequest.src/M000127.html +0 -18
data/lib/midilib/event.rb
CHANGED
@@ -186,11 +186,10 @@ class NoteEvent < ChannelEvent
|
|
186
186
|
end
|
187
187
|
|
188
188
|
def data_as_bytes
|
189
|
-
data =
|
189
|
+
data = []
|
190
190
|
data << (@status + @channel)
|
191
191
|
data << @note
|
192
192
|
data << @velocity
|
193
|
-
return data
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
@@ -246,11 +245,10 @@ class Controller < ChannelEvent
|
|
246
245
|
end
|
247
246
|
|
248
247
|
def data_as_bytes
|
249
|
-
data =
|
248
|
+
data = []
|
250
249
|
data << (@status + @channel)
|
251
250
|
data << @controller
|
252
251
|
data << @value
|
253
|
-
return data
|
254
252
|
end
|
255
253
|
|
256
254
|
def to_s
|
@@ -268,10 +266,9 @@ class ProgramChange < ChannelEvent
|
|
268
266
|
end
|
269
267
|
|
270
268
|
def data_as_bytes
|
271
|
-
data =
|
269
|
+
data = []
|
272
270
|
data << (@status + @channel)
|
273
271
|
data << @program
|
274
|
-
return data
|
275
272
|
end
|
276
273
|
|
277
274
|
def to_s
|
@@ -288,10 +285,9 @@ class ChannelPressure < ChannelEvent
|
|
288
285
|
end
|
289
286
|
|
290
287
|
def data_as_bytes
|
291
|
-
data =
|
288
|
+
data = []
|
292
289
|
data << (@status + @channel)
|
293
290
|
data << @pressure
|
294
|
-
return data
|
295
291
|
end
|
296
292
|
|
297
293
|
def to_s
|
@@ -308,11 +304,10 @@ class PitchBend < ChannelEvent
|
|
308
304
|
end
|
309
305
|
|
310
306
|
def data_as_bytes
|
311
|
-
data =
|
307
|
+
data = []
|
312
308
|
data << (@status + @channel)
|
313
309
|
data << (@value & 0x7f) # lsb
|
314
310
|
data << ((@value >> 7) & 0x7f) # msb
|
315
|
-
return data
|
316
311
|
end
|
317
312
|
|
318
313
|
def to_s
|
@@ -336,12 +331,12 @@ class SystemExclusive < SystemCommon
|
|
336
331
|
end
|
337
332
|
|
338
333
|
def data_as_bytes
|
339
|
-
data =
|
334
|
+
data = []
|
340
335
|
data << @status
|
341
336
|
data << Utils.as_var_len(@data.length)
|
342
337
|
data << @data
|
343
338
|
data << EOX
|
344
|
-
|
339
|
+
data.flatten
|
345
340
|
end
|
346
341
|
|
347
342
|
def to_s
|
@@ -358,11 +353,10 @@ class SongPointer < SystemCommon
|
|
358
353
|
end
|
359
354
|
|
360
355
|
def data_as_bytes
|
361
|
-
data =
|
356
|
+
data = []
|
362
357
|
data << @status
|
363
358
|
data << ((@pointer >> 8) & 0xff)
|
364
359
|
data << (@pointer & 0xff)
|
365
|
-
return data
|
366
360
|
end
|
367
361
|
|
368
362
|
def to_s
|
@@ -379,10 +373,9 @@ class SongSelect < SystemCommon
|
|
379
373
|
end
|
380
374
|
|
381
375
|
def data_as_bytes
|
382
|
-
data =
|
376
|
+
data = []
|
383
377
|
data << @status
|
384
378
|
data << @song
|
385
|
-
return data
|
386
379
|
end
|
387
380
|
|
388
381
|
def to_s
|
@@ -396,9 +389,8 @@ class TuneRequest < SystemCommon
|
|
396
389
|
end
|
397
390
|
|
398
391
|
def data_as_bytes
|
399
|
-
data =
|
392
|
+
data = []
|
400
393
|
data << @status
|
401
|
-
return data
|
402
394
|
end
|
403
395
|
|
404
396
|
def to_s
|
@@ -413,9 +405,8 @@ class Realtime < Event
|
|
413
405
|
end
|
414
406
|
|
415
407
|
def data_as_bytes
|
416
|
-
data =
|
408
|
+
data = []
|
417
409
|
data << @status
|
418
|
-
return data
|
419
410
|
end
|
420
411
|
|
421
412
|
def to_s
|
@@ -490,12 +481,12 @@ class MetaEvent < Event
|
|
490
481
|
end
|
491
482
|
|
492
483
|
def data_as_bytes
|
493
|
-
data =
|
484
|
+
data = []
|
494
485
|
data << @status
|
495
486
|
data << @meta_type
|
496
487
|
data << (@data ? Utils.as_var_len(@data.length) : 0)
|
497
488
|
data << @data if @data
|
498
|
-
|
489
|
+
data.flatten
|
499
490
|
end
|
500
491
|
|
501
492
|
def to_s
|
@@ -573,14 +564,13 @@ class Tempo < MetaEvent
|
|
573
564
|
end
|
574
565
|
|
575
566
|
def data_as_bytes
|
576
|
-
data =
|
567
|
+
data = []
|
577
568
|
data << @status
|
578
569
|
data << @meta_type
|
579
570
|
data << 3
|
580
571
|
data << ((@data >> 16) & 0xff)
|
581
572
|
data << ((@data >> 8) & 0xff)
|
582
573
|
data << (@data & 0xff)
|
583
|
-
return data
|
584
574
|
end
|
585
575
|
|
586
576
|
def to_s
|
@@ -599,7 +589,7 @@ class TimeSig < MetaEvent
|
|
599
589
|
|
600
590
|
# Returns the complete event as stored in the sequence
|
601
591
|
def data_as_bytes
|
602
|
-
data =
|
592
|
+
data = []
|
603
593
|
data << @status
|
604
594
|
data << @meta_type
|
605
595
|
data << 4
|
@@ -649,7 +639,7 @@ class KeySig < MetaEvent
|
|
649
639
|
|
650
640
|
# Returns the complete event as stored in the sequence
|
651
641
|
def data_as_bytes
|
652
|
-
data =
|
642
|
+
data = []
|
653
643
|
data << @status
|
654
644
|
data << @meta_type
|
655
645
|
data << 2
|
data/lib/midilib/info.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module MIDI
|
2
2
|
|
3
3
|
VERSION_MAJOR = 1
|
4
|
-
VERSION_MINOR =
|
5
|
-
VERSION_TWEAK =
|
4
|
+
VERSION_MINOR = 2
|
5
|
+
VERSION_TWEAK = 0
|
6
6
|
Version = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_TWEAK}"
|
7
|
-
Copyright = 'Copyright (c) 2003-
|
7
|
+
Copyright = 'Copyright (c) 2003-2009 by Jim Menard <jimm@io.com>'
|
8
8
|
|
9
9
|
end
|
data/lib/midilib/io/midifile.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
require 'midilib/consts'
|
2
2
|
|
3
|
+
if RUBY_VERSION < '1.9'
|
4
|
+
class IO
|
5
|
+
def readbyte
|
6
|
+
c = getc()
|
7
|
+
raise 'unexpected EOF' unless c
|
8
|
+
c
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
module MIDI
|
4
14
|
|
5
15
|
module IO
|
@@ -13,6 +23,9 @@ module IO
|
|
13
23
|
# objects.
|
14
24
|
class MIDIFile
|
15
25
|
|
26
|
+
MThd_BYTE_ARRAY = [77, 84, 104, 100] # "MThd"
|
27
|
+
MTrk_BYTE_ARRAY = [77, 84, 114, 107] # "MTrk"
|
28
|
+
|
16
29
|
# This array is indexed by the high half of a status byte. Its
|
17
30
|
# value is either the number of bytes needed (1 or 2) for a channel
|
18
31
|
# message, or 0 if it's not a channel message.
|
@@ -53,18 +66,18 @@ class MIDIFile
|
|
53
66
|
ntrks.times { read_track() }
|
54
67
|
end
|
55
68
|
|
56
|
-
# This default getc implementation tries to read a single
|
69
|
+
# This default getc implementation tries to read a single byte
|
57
70
|
# from io and returns it as an integer.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
def getc
|
72
|
+
@bytes_to_be_read -= 1
|
73
|
+
@io.readbyte()
|
74
|
+
end
|
75
|
+
|
76
|
+
# Return the next +n+ bytes from @io as an array.
|
77
|
+
def get_bytes(n)
|
78
|
+
buf = []
|
79
|
+
n.times { buf << getc() }
|
80
|
+
buf
|
68
81
|
end
|
69
82
|
|
70
83
|
# The default error handler.
|
@@ -144,31 +157,31 @@ class MIDIFile
|
|
144
157
|
|
145
158
|
# Read through 'MThd' or 'MTrk' header string. If skip is true, attempt
|
146
159
|
# to skip initial trash. If there is an error, #error is called.
|
147
|
-
def read_mt_header_string(
|
148
|
-
b =
|
160
|
+
def read_mt_header_string(bytes, skip)
|
161
|
+
b = []
|
149
162
|
bytes_to_read = 4
|
150
163
|
while true
|
151
|
-
|
164
|
+
data = get_bytes(bytes_to_read)
|
165
|
+
b += data
|
152
166
|
if b.length < 4
|
153
167
|
error("unexpected EOF while trying to read header" +
|
154
168
|
" string #{s}")
|
155
169
|
end
|
156
|
-
@bytes_to_be_read -= bytes_to_read
|
157
170
|
|
158
|
-
# See if we found the
|
159
|
-
return if b ==
|
171
|
+
# See if we found the bytes we're looking for
|
172
|
+
return if b == bytes
|
160
173
|
|
161
174
|
if skip # Try again with the next char
|
162
|
-
i = b.index(
|
175
|
+
i = b[1..-1].index(bytes[0])
|
163
176
|
if i.nil?
|
164
|
-
b =
|
177
|
+
b = []
|
165
178
|
bytes_to_read = 4
|
166
179
|
else
|
167
180
|
b = b[i..-1]
|
168
181
|
bytes_to_read = 4 - i
|
169
182
|
end
|
170
183
|
else
|
171
|
-
error("header string #{
|
184
|
+
error("header string #{bytes.collect{|b| b.chr}.join} not found")
|
172
185
|
end
|
173
186
|
end
|
174
187
|
end
|
@@ -176,7 +189,7 @@ class MIDIFile
|
|
176
189
|
# Read a header chunk.
|
177
190
|
def read_header
|
178
191
|
@bytes_to_be_read = 0
|
179
|
-
read_mt_header_string(
|
192
|
+
read_mt_header_string(MThd_BYTE_ARRAY, @skip_init) # "MThd"
|
180
193
|
|
181
194
|
@bytes_to_be_read = read32()
|
182
195
|
format = read16()
|
@@ -187,7 +200,7 @@ class MIDIFile
|
|
187
200
|
|
188
201
|
# Flush any extra stuff, in case the length of the header is not 6
|
189
202
|
if @bytes_to_be_read > 0
|
190
|
-
|
203
|
+
get_bytes(@bytes_to_be_read)
|
191
204
|
@bytes_to_be_read = 0
|
192
205
|
end
|
193
206
|
|
@@ -202,7 +215,7 @@ class MIDIFile
|
|
202
215
|
status = 0 # (Possibly running) status byte
|
203
216
|
|
204
217
|
@bytes_to_be_read = 0
|
205
|
-
read_mt_header_string(
|
218
|
+
read_mt_header_string(MTrk_BYTE_ARRAY, false)
|
206
219
|
|
207
220
|
@bytes_to_be_read = read32()
|
208
221
|
@curr_ticks = @ticks_so_far = 0
|
@@ -287,11 +300,12 @@ class MIDIFile
|
|
287
300
|
m = msg() # Copy of internal message buffer
|
288
301
|
|
289
302
|
# Create raw data array
|
290
|
-
@raw_data =
|
303
|
+
@raw_data = []
|
291
304
|
@raw_data << META_EVENT
|
292
305
|
@raw_data << type
|
293
306
|
@raw_data << @raw_var_num_data
|
294
307
|
@raw_data << m
|
308
|
+
@raw_data.flatten!
|
295
309
|
|
296
310
|
case type
|
297
311
|
when META_SEQ_NUM
|
@@ -375,7 +389,7 @@ class MIDIFile
|
|
375
389
|
|
376
390
|
# Read a varlen value.
|
377
391
|
def read_var_len
|
378
|
-
@raw_var_num_data =
|
392
|
+
@raw_var_num_data = []
|
379
393
|
c = getc()
|
380
394
|
@raw_var_num_data << c
|
381
395
|
val = c
|
@@ -414,7 +428,7 @@ class MIDIFile
|
|
414
428
|
return
|
415
429
|
end
|
416
430
|
|
417
|
-
buf =
|
431
|
+
buf = []
|
418
432
|
|
419
433
|
buf << (val & 0x7f)
|
420
434
|
while (value >>= 7) > 0
|
@@ -432,14 +446,14 @@ class MIDIFile
|
|
432
446
|
# Read and add a number of bytes to the message buffer. Return
|
433
447
|
# the last byte (so we can see if it's an EOX or not).
|
434
448
|
def msg_read(n_bytes)
|
435
|
-
@msg_buf
|
436
|
-
@
|
449
|
+
@msg_buf += get_bytes(n_bytes)
|
450
|
+
@msg_buf.flatten!
|
437
451
|
return @msg_buf[-1]
|
438
452
|
end
|
439
453
|
|
440
454
|
# Initialize the internal message buffer.
|
441
455
|
def msg_init
|
442
|
-
@msg_buf =
|
456
|
+
@msg_buf = []
|
443
457
|
end
|
444
458
|
|
445
459
|
# Return a copy of the internal message buffer.
|
data/lib/midilib/io/seqwriter.rb
CHANGED
@@ -56,7 +56,7 @@ class SeqWriter
|
|
56
56
|
status = possibly_munge_due_to_running_status_byte(data,
|
57
57
|
prev_status)
|
58
58
|
|
59
|
-
@bytes_written +=
|
59
|
+
@bytes_written += write_bytes(data)
|
60
60
|
|
61
61
|
prev_event = event
|
62
62
|
prev_status = status
|
@@ -65,7 +65,7 @@ class SeqWriter
|
|
65
65
|
# Write track end event.
|
66
66
|
event = MetaEvent.new(META_TRACK_END)
|
67
67
|
write_var_len(0)
|
68
|
-
@bytes_written +=
|
68
|
+
@bytes_written += write_bytes(event.data_as_bytes())
|
69
69
|
|
70
70
|
# Go back to beginning of track data and write number of bytes,
|
71
71
|
# then come back here to end of file.
|
@@ -91,7 +91,7 @@ class SeqWriter
|
|
91
91
|
# exactly the same, the rest is trivial. If it's note on/note off,
|
92
92
|
# we can combine those further.
|
93
93
|
if status == prev_status
|
94
|
-
data[0] =
|
94
|
+
data[0,1] = nil # delete status byte from data
|
95
95
|
return status + chan
|
96
96
|
elsif status == NOTE_OFF && data[2] == 64
|
97
97
|
# If we see a note off and the velocity is 64, we can store
|
@@ -101,7 +101,7 @@ class SeqWriter
|
|
101
101
|
data[2] = 0 # set vel to 0; do before possible shrinking
|
102
102
|
status = NOTE_ON + chan
|
103
103
|
if prev_status == NOTE_ON
|
104
|
-
data[0] =
|
104
|
+
data[0,1] = [] # delete status byte
|
105
105
|
else
|
106
106
|
data[0] = status
|
107
107
|
end
|
@@ -116,34 +116,36 @@ class SeqWriter
|
|
116
116
|
event = MetaEvent.new(META_INSTRUMENT, instrument)
|
117
117
|
write_var_len(0)
|
118
118
|
data = event.data_as_bytes()
|
119
|
-
@bytes_written +=
|
119
|
+
@bytes_written += write_bytes(data)
|
120
120
|
end
|
121
121
|
|
122
122
|
def write_var_len(val)
|
123
123
|
buffer = Utils.as_var_len(val)
|
124
|
-
@bytes_written +=
|
124
|
+
@bytes_written += write_bytes(buffer)
|
125
125
|
end
|
126
126
|
|
127
127
|
def write16(val)
|
128
128
|
val = (-val | 0x8000) if val < 0
|
129
129
|
|
130
|
-
buffer =
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@bytes_written += @io.write(buffer)
|
130
|
+
buffer = []
|
131
|
+
@io.putc((val >> 8) & 0xff)
|
132
|
+
@io.putc(val & 0xff)
|
133
|
+
@bytes_written += 2
|
135
134
|
end
|
136
135
|
|
137
136
|
def write32(val)
|
138
137
|
val = (-val | 0x80000000) if val < 0
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
@io.putc((val >> 24) & 0xff)
|
140
|
+
@io.putc((val >> 16) & 0xff)
|
141
|
+
@io.putc((val >> 8) & 0xff)
|
142
|
+
@io.putc(val & 0xff)
|
143
|
+
@bytes_written += 4
|
144
|
+
end
|
145
145
|
|
146
|
-
|
146
|
+
def write_bytes(bytes)
|
147
|
+
bytes.each { |b| @io.putc(b) }
|
148
|
+
bytes.length
|
147
149
|
end
|
148
150
|
end
|
149
151
|
|
data/lib/midilib/utils.rb
CHANGED
data/lib/midilib.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# This is the top-level include file for midilib. You can require this
|
4
4
|
# file or require individual files from the midilib directory.
|
5
5
|
#
|
6
|
-
# See the README file or http://midilib.rubyforge.org for details.
|
6
|
+
# See the README.rdoc file or http://midilib.rubyforge.org for details.
|
7
7
|
|
8
8
|
require 'midilib/info'
|
9
9
|
require 'midilib/sequence'
|
data/test/test_io.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
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 'stringio'
|
8
|
+
require 'midilib'
|
9
|
+
|
10
|
+
class MIDI::IO::MIDIFile
|
11
|
+
def io=(io)
|
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
|
23
|
+
end
|
24
|
+
|
25
|
+
class MIDIFileTester < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@m = MIDI::IO::MIDIFile.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_msg_io
|
32
|
+
io = StringIO.new
|
33
|
+
io.write("abcdef")
|
34
|
+
io.rewind()
|
35
|
+
@m.io = io
|
36
|
+
@m.msg_init
|
37
|
+
@m.msg_read(6)
|
38
|
+
assert_equal [97, 98, 99, 100, 101, 102], @m.msg
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_read32
|
42
|
+
io = StringIO.new
|
43
|
+
io.write("\0\0\0\6")
|
44
|
+
io.rewind()
|
45
|
+
@m.io = io
|
46
|
+
assert_equal 6, @m.read32()
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_write32
|
50
|
+
io = StringIO.new
|
51
|
+
old_stdout = $stdout
|
52
|
+
$stdout = io
|
53
|
+
@m.write32(6)
|
54
|
+
$stdout = old_stdout
|
55
|
+
io.rewind()
|
56
|
+
assert_equal "\0\0\0\6", io.string
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/test/test_varlen.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'midilib'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
1
|
# Start looking for MIDI classes in the directory above this one.
|
5
2
|
# This forces us to use the local copy of MIDI, even if there is
|
6
3
|
# a previously installed version out there somewhere.
|
7
4
|
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
8
5
|
|
6
|
+
require 'test/unit'
|
7
|
+
require 'midilib'
|
8
|
+
|
9
9
|
class VarLenTester < Test::Unit::TestCase
|
10
10
|
|
11
11
|
VAR_LEN_TEST_DATA = {
|
@@ -25,7 +25,7 @@ class VarLenTester < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
def num_to_var_len(num, answer)
|
27
27
|
varlen = MIDI::Utils.as_var_len(num)
|
28
|
-
varlen.reverse.
|
28
|
+
varlen.reverse.each { | b |
|
29
29
|
assert_equal(answer & 0xff, b)
|
30
30
|
answer = answer >> 8
|
31
31
|
}
|