midilib 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2 -0
- data/Credits +4 -0
- data/README +23 -6
- data/install.rb +1 -1
- data/lib/midilib/consts.rb +3 -0
- data/lib/midilib/event.rb +2 -2
- data/lib/midilib/info.rb +1 -1
- data/lib/midilib/io/seqreader.rb +1 -1
- data/lib/midilib/track.rb +11 -5
- data/test/test_event.rb +50 -0
- data/test/test_track.rb +9 -0
- metadata +3 -263
- data/html/classes/MIDI.html +0 -738
- data/html/classes/MIDI/ActiveSense.html +0 -156
- data/html/classes/MIDI/ActiveSense.src/M000136.html +0 -18
- data/html/classes/MIDI/ActiveSense.src/M000137.html +0 -18
- data/html/classes/MIDI/ChannelEvent.html +0 -179
- data/html/classes/MIDI/ChannelEvent.src/M000124.html +0 -20
- data/html/classes/MIDI/ChannelEvent.src/M000125.html +0 -18
- data/html/classes/MIDI/ChannelPressure.html +0 -184
- data/html/classes/MIDI/ChannelPressure.src/M000088.html +0 -19
- data/html/classes/MIDI/ChannelPressure.src/M000089.html +0 -21
- data/html/classes/MIDI/ChannelPressure.src/M000090.html +0 -18
- data/html/classes/MIDI/Clock.html +0 -156
- data/html/classes/MIDI/Clock.src/M000134.html +0 -18
- data/html/classes/MIDI/Clock.src/M000135.html +0 -18
- data/html/classes/MIDI/Continue.html +0 -156
- data/html/classes/MIDI/Continue.src/M000132.html +0 -18
- data/html/classes/MIDI/Continue.src/M000133.html +0 -18
- data/html/classes/MIDI/Controller.html +0 -189
- data/html/classes/MIDI/Controller.src/M000129.html +0 -21
- data/html/classes/MIDI/Controller.src/M000130.html +0 -22
- data/html/classes/MIDI/Controller.src/M000131.html +0 -18
- data/html/classes/MIDI/Event.html +0 -424
- data/html/classes/MIDI/Event.src/M000145.html +0 -27
- data/html/classes/MIDI/Event.src/M000146.html +0 -18
- data/html/classes/MIDI/Event.src/M000147.html +0 -18
- data/html/classes/MIDI/Event.src/M000148.html +0 -18
- data/html/classes/MIDI/Event.src/M000149.html +0 -18
- data/html/classes/MIDI/Event.src/M000150.html +0 -18
- data/html/classes/MIDI/Event.src/M000151.html +0 -18
- data/html/classes/MIDI/Event.src/M000152.html +0 -18
- data/html/classes/MIDI/Event.src/M000153.html +0 -18
- data/html/classes/MIDI/Event.src/M000154.html +0 -22
- data/html/classes/MIDI/Event.src/M000155.html +0 -18
- data/html/classes/MIDI/Event.src/M000156.html +0 -18
- data/html/classes/MIDI/Event.src/M000157.html +0 -18
- data/html/classes/MIDI/IO.html +0 -121
- data/html/classes/MIDI/IO/MIDIFile.html +0 -925
- data/html/classes/MIDI/IO/MIDIFile.src/M000028.html +0 -22
- data/html/classes/MIDI/IO/MIDIFile.src/M000029.html +0 -24
- data/html/classes/MIDI/IO/MIDIFile.src/M000030.html +0 -19
- data/html/classes/MIDI/IO/MIDIFile.src/M000031.html +0 -19
- data/html/classes/MIDI/IO/MIDIFile.src/M000032.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000033.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000034.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000035.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000036.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000037.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000038.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000039.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000040.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000041.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000042.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000043.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000044.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000045.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000046.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000047.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000048.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000049.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000050.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000051.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000052.html +0 -17
- data/html/classes/MIDI/IO/MIDIFile.src/M000053.html +0 -43
- data/html/classes/MIDI/IO/MIDIFile.src/M000054.html +0 -34
- data/html/classes/MIDI/IO/MIDIFile.src/M000055.html +0 -96
- data/html/classes/MIDI/IO/MIDIFile.src/M000056.html +0 -18
- data/html/classes/MIDI/IO/MIDIFile.src/M000057.html +0 -48
- data/html/classes/MIDI/IO/MIDIFile.src/M000058.html +0 -42
- data/html/classes/MIDI/IO/MIDIFile.src/M000059.html +0 -19
- data/html/classes/MIDI/IO/MIDIFile.src/M000060.html +0 -19
- data/html/classes/MIDI/IO/MIDIFile.src/M000061.html +0 -20
- data/html/classes/MIDI/IO/MIDIFile.src/M000062.html +0 -21
- data/html/classes/MIDI/IO/MIDIFile.src/M000063.html +0 -31
- data/html/classes/MIDI/IO/MIDIFile.src/M000064.html +0 -20
- data/html/classes/MIDI/IO/MIDIFile.src/M000065.html +0 -22
- data/html/classes/MIDI/IO/MIDIFile.src/M000066.html +0 -30
- data/html/classes/MIDI/IO/MIDIFile.src/M000067.html +0 -18
- data/html/classes/MIDI/IO/MIDIFile.src/M000068.html +0 -20
- data/html/classes/MIDI/IO/MIDIFile.src/M000069.html +0 -18
- data/html/classes/MIDI/IO/MIDIFile.src/M000070.html +0 -18
- data/html/classes/MIDI/IO/SeqReader.html +0 -460
- data/html/classes/MIDI/IO/SeqReader.src/M000001.html +0 -22
- data/html/classes/MIDI/IO/SeqReader.src/M000002.html +0 -22
- data/html/classes/MIDI/IO/SeqReader.src/M000003.html +0 -21
- data/html/classes/MIDI/IO/SeqReader.src/M000004.html +0 -34
- data/html/classes/MIDI/IO/SeqReader.src/M000005.html +0 -26
- data/html/classes/MIDI/IO/SeqReader.src/M000006.html +0 -28
- data/html/classes/MIDI/IO/SeqReader.src/M000007.html +0 -21
- data/html/classes/MIDI/IO/SeqReader.src/M000008.html +0 -19
- data/html/classes/MIDI/IO/SeqReader.src/M000009.html +0 -19
- data/html/classes/MIDI/IO/SeqReader.src/M000010.html +0 -19
- data/html/classes/MIDI/IO/SeqReader.src/M000011.html +0 -19
- data/html/classes/MIDI/IO/SeqReader.src/M000012.html +0 -19
- data/html/classes/MIDI/IO/SeqReader.src/M000013.html +0 -18
- data/html/classes/MIDI/IO/SeqReader.src/M000014.html +0 -18
- data/html/classes/MIDI/IO/SeqReader.src/M000015.html +0 -27
- data/html/classes/MIDI/IO/SeqReader.src/M000016.html +0 -18
- data/html/classes/MIDI/IO/SeqReader.src/M000017.html +0 -18
- data/html/classes/MIDI/IO/SeqReader.src/M000018.html +0 -18
- data/html/classes/MIDI/IO/SeqWriter.html +0 -267
- data/html/classes/MIDI/IO/SeqWriter.src/M000019.html +0 -19
- data/html/classes/MIDI/IO/SeqWriter.src/M000020.html +0 -25
- data/html/classes/MIDI/IO/SeqWriter.src/M000021.html +0 -22
- data/html/classes/MIDI/IO/SeqWriter.src/M000022.html +0 -54
- data/html/classes/MIDI/IO/SeqWriter.src/M000023.html +0 -49
- data/html/classes/MIDI/IO/SeqWriter.src/M000024.html +0 -21
- data/html/classes/MIDI/IO/SeqWriter.src/M000025.html +0 -19
- data/html/classes/MIDI/IO/SeqWriter.src/M000026.html +0 -24
- data/html/classes/MIDI/IO/SeqWriter.src/M000027.html +0 -26
- data/html/classes/MIDI/Marker.html +0 -139
- data/html/classes/MIDI/Marker.src/M000107.html +0 -18
- data/html/classes/MIDI/MetaEvent.html +0 -189
- data/html/classes/MIDI/MetaEvent.src/M000167.html +0 -21
- data/html/classes/MIDI/MetaEvent.src/M000168.html +0 -23
- data/html/classes/MIDI/MetaEvent.src/M000169.html +0 -53
- data/html/classes/MIDI/NoteEvent.html +0 -233
- data/html/classes/MIDI/NoteEvent.src/M000091.html +0 -21
- data/html/classes/MIDI/NoteEvent.src/M000092.html +0 -20
- data/html/classes/MIDI/NoteEvent.src/M000093.html +0 -18
- data/html/classes/MIDI/NoteEvent.src/M000094.html +0 -22
- data/html/classes/MIDI/NoteOffEvent.html +0 -169
- data/html/classes/MIDI/NoteOffEvent.src/M000086.html +0 -19
- data/html/classes/MIDI/NoteOffEvent.src/M000087.html +0 -19
- data/html/classes/MIDI/NoteOnEvent.html +0 -169
- data/html/classes/MIDI/NoteOnEvent.src/M000102.html +0 -19
- data/html/classes/MIDI/NoteOnEvent.src/M000103.html +0 -19
- data/html/classes/MIDI/PitchBend.html +0 -184
- data/html/classes/MIDI/PitchBend.src/M000104.html +0 -19
- data/html/classes/MIDI/PitchBend.src/M000105.html +0 -22
- data/html/classes/MIDI/PitchBend.src/M000106.html +0 -18
- data/html/classes/MIDI/PolyPressure.html +0 -186
- data/html/classes/MIDI/PolyPressure.src/M000170.html +0 -18
- data/html/classes/MIDI/PolyPressure.src/M000171.html +0 -18
- data/html/classes/MIDI/PolyPressure.src/M000172.html +0 -18
- data/html/classes/MIDI/PolyPressure.src/M000173.html +0 -19
- data/html/classes/MIDI/ProgramChange.html +0 -184
- data/html/classes/MIDI/ProgramChange.src/M000099.html +0 -19
- data/html/classes/MIDI/ProgramChange.src/M000100.html +0 -21
- data/html/classes/MIDI/ProgramChange.src/M000101.html +0 -18
- data/html/classes/MIDI/Realtime.html +0 -171
- data/html/classes/MIDI/Realtime.src/M000083.html +0 -19
- data/html/classes/MIDI/Realtime.src/M000084.html +0 -20
- data/html/classes/MIDI/Realtime.src/M000085.html +0 -18
- data/html/classes/MIDI/Sequence.html +0 -469
- data/html/classes/MIDI/Sequence.src/M000108.html +0 -28
- data/html/classes/MIDI/Sequence.src/M000109.html +0 -21
- data/html/classes/MIDI/Sequence.src/M000110.html +0 -22
- data/html/classes/MIDI/Sequence.src/M000113.html +0 -18
- data/html/classes/MIDI/Sequence.src/M000114.html +0 -27
- data/html/classes/MIDI/Sequence.src/M000115.html +0 -18
- data/html/classes/MIDI/Sequence.src/M000116.html +0 -19
- data/html/classes/MIDI/Sequence.src/M000117.html +0 -19
- data/html/classes/MIDI/Sequence.src/M000118.html +0 -20
- data/html/classes/MIDI/Sequence.src/M000119.html +0 -19
- data/html/classes/MIDI/Sequence.src/M000120.html +0 -18
- data/html/classes/MIDI/SongPointer.html +0 -184
- data/html/classes/MIDI/SongPointer.src/M000138.html +0 -19
- data/html/classes/MIDI/SongPointer.src/M000139.html +0 -22
- data/html/classes/MIDI/SongPointer.src/M000140.html +0 -18
- data/html/classes/MIDI/SongSelect.html +0 -184
- data/html/classes/MIDI/SongSelect.src/M000126.html +0 -19
- data/html/classes/MIDI/SongSelect.src/M000127.html +0 -21
- data/html/classes/MIDI/SongSelect.src/M000128.html +0 -18
- data/html/classes/MIDI/Start.html +0 -156
- data/html/classes/MIDI/Start.src/M000097.html +0 -18
- data/html/classes/MIDI/Start.src/M000098.html +0 -18
- data/html/classes/MIDI/Stop.html +0 -156
- data/html/classes/MIDI/Stop.src/M000095.html +0 -18
- data/html/classes/MIDI/Stop.src/M000096.html +0 -18
- data/html/classes/MIDI/SystemCommon.html +0 -139
- data/html/classes/MIDI/SystemCommon.src/M000144.html +0 -19
- data/html/classes/MIDI/SystemExclusive.html +0 -184
- data/html/classes/MIDI/SystemExclusive.src/M000141.html +0 -19
- data/html/classes/MIDI/SystemExclusive.src/M000142.html +0 -23
- data/html/classes/MIDI/SystemExclusive.src/M000143.html +0 -18
- data/html/classes/MIDI/SystemReset.html +0 -156
- data/html/classes/MIDI/SystemReset.src/M000081.html +0 -18
- data/html/classes/MIDI/SystemReset.src/M000082.html +0 -18
- data/html/classes/MIDI/Tempo.html +0 -250
- data/html/classes/MIDI/Tempo.src/M000158.html +0 -18
- data/html/classes/MIDI/Tempo.src/M000159.html +0 -18
- data/html/classes/MIDI/Tempo.src/M000160.html +0 -18
- data/html/classes/MIDI/Tempo.src/M000161.html +0 -18
- data/html/classes/MIDI/Tempo.src/M000162.html +0 -18
- data/html/classes/MIDI/Tempo.src/M000163.html +0 -25
- data/html/classes/MIDI/Tempo.src/M000164.html +0 -18
- data/html/classes/MIDI/Track.html +0 -380
- data/html/classes/MIDI/Track.src/M000071.html +0 -23
- data/html/classes/MIDI/Track.src/M000072.html +0 -21
- data/html/classes/MIDI/Track.src/M000073.html +0 -26
- data/html/classes/MIDI/Track.src/M000074.html +0 -18
- data/html/classes/MIDI/Track.src/M000075.html +0 -22
- data/html/classes/MIDI/Track.src/M000076.html +0 -20
- data/html/classes/MIDI/Track.src/M000077.html +0 -22
- data/html/classes/MIDI/Track.src/M000078.html +0 -22
- data/html/classes/MIDI/Track.src/M000079.html +0 -18
- data/html/classes/MIDI/Track.src/M000080.html +0 -19
- data/html/classes/MIDI/TuneRequest.html +0 -171
- data/html/classes/MIDI/TuneRequest.src/M000121.html +0 -18
- data/html/classes/MIDI/TuneRequest.src/M000122.html +0 -20
- data/html/classes/MIDI/TuneRequest.src/M000123.html +0 -18
- data/html/classes/MIDI/Utils.html +0 -190
- data/html/classes/MIDI/Utils.src/M000165.html +0 -20
- data/html/classes/MIDI/Utils.src/M000166.html +0 -25
- data/html/created.rid +0 -1
- data/html/files/README.html +0 -599
- data/html/files/TODO.html +0 -142
- data/html/files/lib/midilib/consts_rb.html +0 -107
- data/html/files/lib/midilib/event_rb.html +0 -109
- data/html/files/lib/midilib/info_rb.html +0 -101
- data/html/files/lib/midilib/io/midifile_rb.html +0 -108
- data/html/files/lib/midilib/io/seqreader_rb.html +0 -110
- data/html/files/lib/midilib/io/seqwriter_rb.html +0 -115
- data/html/files/lib/midilib/sequence_rb.html +0 -109
- data/html/files/lib/midilib/track_rb.html +0 -108
- data/html/files/lib/midilib/utils_rb.html +0 -101
- data/html/files/lib/midilib_rb.html +0 -124
- data/html/fr_class_index.html +0 -59
- data/html/fr_file_index.html +0 -38
- data/html/fr_method_index.html +0 -199
- data/html/index.html +0 -24
- data/html/rdoc-style.css +0 -208
@@ -1,190 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: MIDI::Utils</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">MIDI::Utils</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/midilib/utils_rb.html">
|
59
|
-
lib/midilib/utils.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
Utility methods.
|
84
|
-
</p>
|
85
|
-
|
86
|
-
</div>
|
87
|
-
|
88
|
-
|
89
|
-
</div>
|
90
|
-
|
91
|
-
<div id="method-list">
|
92
|
-
<h3 class="section-bar">Methods</h3>
|
93
|
-
|
94
|
-
<div class="name-list">
|
95
|
-
<a href="#M000166">as_var_len</a>
|
96
|
-
<a href="#M000165">note_to_s</a>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
</div>
|
101
|
-
|
102
|
-
|
103
|
-
<!-- if includes -->
|
104
|
-
|
105
|
-
<div id="section">
|
106
|
-
|
107
|
-
|
108
|
-
<div id="constants-list">
|
109
|
-
<h3 class="section-bar">Constants</h3>
|
110
|
-
|
111
|
-
<div class="name-list">
|
112
|
-
<table summary="Constants">
|
113
|
-
<tr class="top-aligned-row context-row">
|
114
|
-
<td class="context-item-name">NOTE_NAMES</td>
|
115
|
-
<td>=</td>
|
116
|
-
<td class="context-item-value">[ 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'</td>
|
117
|
-
<td width="3em"> </td>
|
118
|
-
<td class="context-item-desc">
|
119
|
-
<a href="../MIDI.html">MIDI</a> note names. NOTE_NAMES[0] is
|
120
|
-
‘C’, NOTE_NAMES[1] is ‘C#’, etc.
|
121
|
-
|
122
|
-
</td>
|
123
|
-
</tr>
|
124
|
-
</table>
|
125
|
-
</div>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
<!-- if method_list -->
|
134
|
-
<div id="methods">
|
135
|
-
<h3 class="section-bar">Public Class methods</h3>
|
136
|
-
|
137
|
-
<div id="method-M000166" class="method-detail">
|
138
|
-
<a name="M000166"></a>
|
139
|
-
|
140
|
-
<div class="method-heading">
|
141
|
-
<a href="Utils.src/M000166.html" target="Code" class="method-signature"
|
142
|
-
onclick="popupCode('Utils.src/M000166.html');return false;">
|
143
|
-
<span class="method-name">as_var_len</span><span class="method-args">(val)</span>
|
144
|
-
</a>
|
145
|
-
</div>
|
146
|
-
|
147
|
-
<div class="method-description">
|
148
|
-
<p>
|
149
|
-
Given an integer, returns it as a variable length array of bytes (the
|
150
|
-
format used by <a href="../MIDI.html">MIDI</a> files).
|
151
|
-
</p>
|
152
|
-
<p>
|
153
|
-
The converse operation—converting a var len into a
|
154
|
-
number—requires input from a stream of bytes. Therefore we
|
155
|
-
don’t supply it here. That is a part of the MIDIFile class.
|
156
|
-
</p>
|
157
|
-
</div>
|
158
|
-
</div>
|
159
|
-
|
160
|
-
<div id="method-M000165" class="method-detail">
|
161
|
-
<a name="M000165"></a>
|
162
|
-
|
163
|
-
<div class="method-heading">
|
164
|
-
<a href="Utils.src/M000165.html" target="Code" class="method-signature"
|
165
|
-
onclick="popupCode('Utils.src/M000165.html');return false;">
|
166
|
-
<span class="method-name">note_to_s</span><span class="method-args">(num)</span>
|
167
|
-
</a>
|
168
|
-
</div>
|
169
|
-
|
170
|
-
<div class="method-description">
|
171
|
-
<p>
|
172
|
-
Given a <a href="../MIDI.html">MIDI</a> note number, return the name and
|
173
|
-
octave as a string.
|
174
|
-
</p>
|
175
|
-
</div>
|
176
|
-
</div>
|
177
|
-
|
178
|
-
|
179
|
-
</div>
|
180
|
-
|
181
|
-
|
182
|
-
</div>
|
183
|
-
|
184
|
-
|
185
|
-
<div id="validator-badges">
|
186
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
187
|
-
</div>
|
188
|
-
|
189
|
-
</body>
|
190
|
-
</html>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>note_to_s (MIDI::Utils)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/midilib/utils.rb, line 12</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">note_to_s</span>(<span class="ruby-identifier">num</span>)
|
15
|
-
<span class="ruby-identifier">note</span> = <span class="ruby-identifier">num</span> <span class="ruby-operator">%</span> <span class="ruby-value">12</span>
|
16
|
-
<span class="ruby-identifier">octave</span> = <span class="ruby-identifier">num</span> <span class="ruby-operator">/</span> <span class="ruby-value">12</span>
|
17
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{NOTE_NAMES[note]}#{octave - 1}"</span>
|
18
|
-
<span class="ruby-keyword kw">end</span></pre>
|
19
|
-
</body>
|
20
|
-
</html>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>as_var_len (MIDI::Utils)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/midilib/utils.rb, line 24</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">as_var_len</span>(<span class="ruby-identifier">val</span>)
|
15
|
-
<span class="ruby-identifier">buffer</span> = <span class="ruby-value str">''</span>
|
16
|
-
<span class="ruby-identifier">buffer</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">val</span> <span class="ruby-operator">&</span> <span class="ruby-value">0x7f</span>)
|
17
|
-
<span class="ruby-identifier">val</span> = (<span class="ruby-identifier">val</span> <span class="ruby-operator">>></span> <span class="ruby-value">7</span>)
|
18
|
-
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
19
|
-
<span class="ruby-identifier">buffer</span> <span class="ruby-operator"><<</span> (<span class="ruby-value">0x80</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">val</span> <span class="ruby-operator">&</span> <span class="ruby-value">0x7f</span>))
|
20
|
-
<span class="ruby-identifier">val</span> = (<span class="ruby-identifier">val</span> <span class="ruby-operator">>></span> <span class="ruby-value">7</span>)
|
21
|
-
<span class="ruby-keyword kw">end</span>
|
22
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">reverse!</span>
|
23
|
-
<span class="ruby-keyword kw">end</span></pre>
|
24
|
-
</body>
|
25
|
-
</html>
|
data/html/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Mon Mar 21 21:17:47 EST 2005
|
data/html/files/README.html
DELETED
@@ -1,599 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: README</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>README</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>README
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Mon Mar 21 21:17:03 EST 2005</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
<div id="description">
|
72
|
-
<h1>midilib</h1>
|
73
|
-
<p>
|
74
|
-
midilib is a pure Ruby <a href="../classes/MIDI.html">MIDI</a> library
|
75
|
-
useful for reading and writing standard <a
|
76
|
-
href="../classes/MIDI.html">MIDI</a> files and manipulating <a
|
77
|
-
href="../classes/MIDI.html">MIDI</a> event data. Classes include <a
|
78
|
-
href="../classes/MIDI/Sequence.html">MIDI::Sequence</a>, <a
|
79
|
-
href="../classes/MIDI/Track.html">MIDI::Track</a>, <a
|
80
|
-
href="../classes/MIDI/Event.html">MIDI::Event</a>, and <a
|
81
|
-
href="../classes/MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a> and its
|
82
|
-
subclasses <a
|
83
|
-
href="../classes/MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a> and <a
|
84
|
-
href="../classes/MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a>.
|
85
|
-
</p>
|
86
|
-
<p>
|
87
|
-
The Web site of midilib is (<a
|
88
|
-
href="http://midilib.rubyforge.org">midilib.rubyforge.org</a>). The
|
89
|
-
RubyForge project page is <a
|
90
|
-
href="http://rubyforge.org/projects/midilib">rubyforge.org/projects/midilib</a>,
|
91
|
-
where the latest version of midilib may be downloaded. midilib is also
|
92
|
-
available as a RubyGem.
|
93
|
-
</p>
|
94
|
-
<h3>Recent Changes</h3>
|
95
|
-
<h4>Changes for 0.8.4:</h4>
|
96
|
-
<ul>
|
97
|
-
<li>Realtime status bytes now set @is_realtime to true and return true when
|
98
|
-
realtime? is called.
|
99
|
-
|
100
|
-
</li>
|
101
|
-
<li>All system common events now set @is_system to true and return true when
|
102
|
-
system? is called, not just system exclusive events.
|
103
|
-
|
104
|
-
</li>
|
105
|
-
<li>Added examples/from_scratch.rb, which shows how to create a sequence
|
106
|
-
manually.
|
107
|
-
|
108
|
-
</li>
|
109
|
-
<li>New <a href="../classes/MIDI/Sequence.html">MIDI::Sequence</a> methods that
|
110
|
-
turn note length names like "32nd", "dotted quarter",
|
111
|
-
and "16th triplet" into delta times. See the docs below and
|
112
|
-
MIDI::Sequence::length_to_delta, MIDI::Sequence::note_to_length, and
|
113
|
-
MIDI::Sequence::note_to_delta.
|
114
|
-
|
115
|
-
</li>
|
116
|
-
</ul>
|
117
|
-
<h4>Changes for 0.8.3:</h4>
|
118
|
-
<ul>
|
119
|
-
<li>Added <a
|
120
|
-
href="../classes/MIDI/NoteEvent.html#M000093">MIDI::NoteEvent.note_to_s</a>,
|
121
|
-
which returns note name as a string like "C4" or "F#6".
|
122
|
-
|
123
|
-
</li>
|
124
|
-
<li>Added new boolean attributes to <a
|
125
|
-
href="../classes/MIDI/Event.html">MIDI::Event</a>: @print_decimal_numbers
|
126
|
-
and @print_note_names. These are used by all Event to_s methods. See
|
127
|
-
examples/seq2text.rb for an example.
|
128
|
-
|
129
|
-
</li>
|
130
|
-
</ul>
|
131
|
-
<h4>Changes for 0.8.2:</h4>
|
132
|
-
<ul>
|
133
|
-
<li>Changed MIDI::MetaEvent.type to MIDI::MetaEvent.event_type to avoid runtime
|
134
|
-
complaints about Object#type calls.
|
135
|
-
|
136
|
-
</li>
|
137
|
-
<li>Added ‘b’ binary flag to file open modes for Windows.
|
138
|
-
|
139
|
-
</li>
|
140
|
-
<li>Fixed $LOAD_PATH in example files.
|
141
|
-
|
142
|
-
</li>
|
143
|
-
<li>Fixed read and write block arguments.
|
144
|
-
|
145
|
-
</li>
|
146
|
-
<li>Fixed other example script bugs.
|
147
|
-
|
148
|
-
</li>
|
149
|
-
</ul>
|
150
|
-
<h4>Changes for 0.8.1:</h4>
|
151
|
-
<ul>
|
152
|
-
<li>Fixed track sorting.
|
153
|
-
|
154
|
-
</li>
|
155
|
-
<li>Fixed track’s recalc_delta_from_times method.
|
156
|
-
|
157
|
-
</li>
|
158
|
-
<li>Fixed event quantization.
|
159
|
-
|
160
|
-
</li>
|
161
|
-
<li>More tests and documentation.
|
162
|
-
|
163
|
-
</li>
|
164
|
-
</ul>
|
165
|
-
<h2>Dependencies</h2>
|
166
|
-
<p>
|
167
|
-
midilib does not require any other packages. The test suite in the tests
|
168
|
-
directory requires the testing framework TestUnit, which comes with Ruby
|
169
|
-
1.8 and later and can also be found in the Ruby Application Archive (<a
|
170
|
-
href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>).
|
171
|
-
</p>
|
172
|
-
<p>
|
173
|
-
To rebuild the gem or RDocs or run the tests easily, you can use the
|
174
|
-
Rakefile which requires Rake (<a
|
175
|
-
href="http://rake.rubyforge.org">rake.rubyforge.org</a>).
|
176
|
-
</p>
|
177
|
-
<h2>Installation</h2>
|
178
|
-
<h3>RubyGems Installation</h3>
|
179
|
-
<p>
|
180
|
-
To install midilib as a gem, type
|
181
|
-
</p>
|
182
|
-
<pre>
|
183
|
-
% gem install midilib
|
184
|
-
</pre>
|
185
|
-
<p>
|
186
|
-
You may need root privileges to install the gem.
|
187
|
-
</p>
|
188
|
-
<h3>Manual Installation</h3>
|
189
|
-
<p>
|
190
|
-
After downloading and expanding the archive, you can install midilib with
|
191
|
-
the command
|
192
|
-
</p>
|
193
|
-
<pre>
|
194
|
-
% ruby install.rb
|
195
|
-
</pre>
|
196
|
-
<p>
|
197
|
-
(or)
|
198
|
-
</p>
|
199
|
-
<pre>
|
200
|
-
% ruby install.rb --install-dir=my_directory
|
201
|
-
</pre>
|
202
|
-
<p>
|
203
|
-
You may need root privileges to install.
|
204
|
-
</p>
|
205
|
-
<h2>Testing</h2>
|
206
|
-
<pre>
|
207
|
-
% rake test
|
208
|
-
</pre>
|
209
|
-
<p>
|
210
|
-
runs all of the tests in the test directory.
|
211
|
-
</p>
|
212
|
-
<h2>Overview</h2>
|
213
|
-
<p>
|
214
|
-
<a href="../classes/MIDI.html">MIDI</a> file IO only understands <a
|
215
|
-
href="../classes/MIDI.html">MIDI</a> file format 1, where a sequence is
|
216
|
-
made up of multiple tracks. It doesn’t yet understand format 0 (a
|
217
|
-
single track containing all events) or format 2 (a collection of format 0
|
218
|
-
files in one file).
|
219
|
-
</p>
|
220
|
-
<h3><a href="../classes/MIDI/Sequence.html">MIDI::Sequence</a></h3>
|
221
|
-
<p>
|
222
|
-
A sequence contains a collection of tracks and global information like the
|
223
|
-
sequence’s pulses per quarter note (ppqn) and time signature.
|
224
|
-
</p>
|
225
|
-
<p>
|
226
|
-
The first track in a sequence is special; it holds meta-events like tempo
|
227
|
-
and sequence name. Don‘t put any notes in this track.
|
228
|
-
</p>
|
229
|
-
<p>
|
230
|
-
<a href="../classes/MIDI/Sequence.html">MIDI::Sequence</a> also contains
|
231
|
-
some convenience methods that let you set and retrieve the sequence’s
|
232
|
-
name, the time signature, and to retrieve the first tempo event’s
|
233
|
-
beats-per-minute value.
|
234
|
-
</p>
|
235
|
-
<p>
|
236
|
-
Normally instances of <a
|
237
|
-
href="../classes/MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a> and <a
|
238
|
-
href="../classes/MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a> are used
|
239
|
-
when a sequence reads itself from or writes itself to a <a
|
240
|
-
href="../classes/MIDI.html">MIDI</a> file. You can change that by setting a
|
241
|
-
sequence’s reader_class or writer_class attributes. Instances of the
|
242
|
-
classes contained in those attributes are created and used whenever the
|
243
|
-
sequence reads or writes itself.
|
244
|
-
</p>
|
245
|
-
<h3><a href="../classes/MIDI/Track.html">MIDI::Track</a></h3>
|
246
|
-
<p>
|
247
|
-
A track contains an array of events.
|
248
|
-
</p>
|
249
|
-
<p>
|
250
|
-
When you modify the <tt>events</tt> array, make sure to call recalc_times
|
251
|
-
so each event gets its <tt>time_from_start</tt> recalculated. You
|
252
|
-
don’t have to do that after every event you add; just remember to do
|
253
|
-
so before using the track in a way that expects the list of events to be
|
254
|
-
ordered correctly.
|
255
|
-
</p>
|
256
|
-
<p>
|
257
|
-
A Track also holds a bit mask that specifies the channels used by the
|
258
|
-
track. This bit mask is set when the track is read from the <a
|
259
|
-
href="../classes/MIDI.html">MIDI</a> file by a SeqReader but is
|
260
|
-
<em>not</em> kept up to date by any other methods. Specifically, if you add
|
261
|
-
events to a track at any other time, the bit mask will not be updated.
|
262
|
-
</p>
|
263
|
-
<h3><a href="../classes/MIDI/Event.html">MIDI::Event</a></h3>
|
264
|
-
<p>
|
265
|
-
Each event holds not only its delta time but also its time from the start
|
266
|
-
of the track. The track is responsible for recalculating its events’
|
267
|
-
start times. You can call <a
|
268
|
-
href="../classes/MIDI/Track.html#M000077">MIDI::Track#recalc_times</a> to
|
269
|
-
do so.
|
270
|
-
</p>
|
271
|
-
<p>
|
272
|
-
Events have a number of boolean methods that identify their types, like
|
273
|
-
channel?, note?, note_on?, note_off?, meta?, system?, and realtime?.
|
274
|
-
</p>
|
275
|
-
<p>
|
276
|
-
Subclasses of <a href="../classes/MIDI/Event.html">MIDI::Event</a>
|
277
|
-
implement the various <a href="../classes/MIDI.html">MIDI</a> messages such
|
278
|
-
as note on and off, controller values, system exclusive data, and realtime
|
279
|
-
bytes.
|
280
|
-
</p>
|
281
|
-
<p>
|
282
|
-
<a href="../classes/MIDI/Realtime.html">MIDI::Realtime</a> events have
|
283
|
-
delta values and start times, just like all the other midilib event types
|
284
|
-
do. (<a href="../classes/MIDI.html">MIDI</a> real time status bytes
|
285
|
-
don’t have delta times, but this way we can record when in a track
|
286
|
-
the realtime byte was received and should be sent. This is useful for
|
287
|
-
start/continue/stop events that control other devices, for example.) Note
|
288
|
-
that when a <a href="../classes/MIDI/Realtime.html">MIDI::Realtime</a>
|
289
|
-
event is written out to a <a href="../classes/MIDI.html">MIDI</a> file, the
|
290
|
-
delta time is not written.
|
291
|
-
</p>
|
292
|
-
<h2>How To Use</h2>
|
293
|
-
<p>
|
294
|
-
The following examples show you how to use midilib to read, write, and
|
295
|
-
manipulate <a href="../classes/MIDI.html">MIDI</a> files and modify track
|
296
|
-
events. See also the files in the examples directory, which are described
|
297
|
-
below.
|
298
|
-
</p>
|
299
|
-
<h3>Reading a <a href="../classes/MIDI.html">MIDI</a> File</h3>
|
300
|
-
<p>
|
301
|
-
To read a <a href="../classes/MIDI.html">MIDI</a> file, create a <a
|
302
|
-
href="../classes/MIDI/Sequence.html">MIDI::Sequence</a> object and call its
|
303
|
-
read method, passing in an IO object.
|
304
|
-
</p>
|
305
|
-
<p>
|
306
|
-
The read method takes an optional block. If present, the block is called
|
307
|
-
once after each track has finished being read. Each time, it is passed the
|
308
|
-
total number of tracks and the number of the current track that has just
|
309
|
-
been read. This is useful for notifying the user of progress, for example
|
310
|
-
by updating a GUI progress bar.
|
311
|
-
</p>
|
312
|
-
<pre>
|
313
|
-
require 'midi/io/seqreader'
|
314
|
-
|
315
|
-
# Create a new, empty sequence.
|
316
|
-
seq = MIDI::Sequence.new()
|
317
|
-
|
318
|
-
# Read the contents of a MIDI file into the sequence.
|
319
|
-
File.open('my_midi_file.mid', 'rb') { | file |
|
320
|
-
seq.read(file) { | num_tracks, i |
|
321
|
-
# Print something when each track is read.
|
322
|
-
puts "read track #{i} of #{num_tracks}"
|
323
|
-
}
|
324
|
-
}
|
325
|
-
</pre>
|
326
|
-
<h3>Writing a <a href="../classes/MIDI.html">MIDI</a> File</h3>
|
327
|
-
<p>
|
328
|
-
To write a <a href="../classes/MIDI.html">MIDI</a> file, call the write
|
329
|
-
method, passing in an IO object.
|
330
|
-
</p>
|
331
|
-
<pre>
|
332
|
-
require 'midi/io/seqwriter'
|
333
|
-
|
334
|
-
# Start with a sequence that has something worth saving.
|
335
|
-
seq = read_or_create_seq_we_care_not_how()
|
336
|
-
|
337
|
-
# Write the sequence to a MIDI file.
|
338
|
-
File.open('my_output_file.mid', 'wb') { | file | seq.write(file) }
|
339
|
-
</pre>
|
340
|
-
<h3>Editing a <a href="../classes/MIDI.html">MIDI</a> File</h3>
|
341
|
-
<p>
|
342
|
-
Combining the last two examples, here is a script that reads a <a
|
343
|
-
href="../classes/MIDI.html">MIDI</a> file, transposes some events, and
|
344
|
-
writes the sequence out to a different file. This is a useful template for
|
345
|
-
programatically manipulating <a href="../classes/MIDI.html">MIDI</a> data.
|
346
|
-
</p>
|
347
|
-
<p>
|
348
|
-
This code transposes all of the note events (note on, note off, and poly
|
349
|
-
pressure) on channel 5 down one octave. It’s easy to find events that
|
350
|
-
need to be transposed: the method note? returns true.
|
351
|
-
</p>
|
352
|
-
<h4>Transposing One Channel</h4>
|
353
|
-
<pre>
|
354
|
-
require 'midi/io/seqreader'
|
355
|
-
require 'midi/io/seqwriter'
|
356
|
-
|
357
|
-
# Create a new, empty sequence.
|
358
|
-
seq = MIDI::Sequence.new()
|
359
|
-
|
360
|
-
# Read the contents of a MIDI file into the sequence.
|
361
|
-
File.open('my_input_file.mid', 'rb') { | file |
|
362
|
-
seq.read(file) { | num_tracks, i |
|
363
|
-
# Print something when each track is read.
|
364
|
-
puts "read track #{i} of #{num_tracks}"
|
365
|
-
}
|
366
|
-
}
|
367
|
-
|
368
|
-
# Iterate over every event in every track.
|
369
|
-
seq.each { | track |
|
370
|
-
track.each { | event |
|
371
|
-
# If the event is a note event (note on, note off, or poly
|
372
|
-
# pressure) and it is on MIDI channel 5 (channels start at
|
373
|
-
# 0, so we use 4), then transpose the event down one octave.
|
374
|
-
if event.note? && event.channel == 4
|
375
|
-
event.note -= 12
|
376
|
-
end
|
377
|
-
}
|
378
|
-
}
|
379
|
-
|
380
|
-
# Write the sequence to a MIDI file.
|
381
|
-
File.open('my_output_file.mid', 'wb') { | file | seq.write(file) }
|
382
|
-
</pre>
|
383
|
-
<h3>Manipulating tracks</h3>
|
384
|
-
<p>
|
385
|
-
If you modify a track’s list of events directly, don’t forget
|
386
|
-
to call <a
|
387
|
-
href="../classes/MIDI/Track.html#M000077">MIDI::Track#recalc_times</a> when
|
388
|
-
you are done.
|
389
|
-
</p>
|
390
|
-
<pre>
|
391
|
-
track.events[42, 1] = array_of_events
|
392
|
-
track.events << an_event
|
393
|
-
track.merge(array_of_events)
|
394
|
-
track.recalc_times
|
395
|
-
</pre>
|
396
|
-
<h3>Calculating delta times</h3>
|
397
|
-
<p>
|
398
|
-
A few methods in <a href="../classes/MIDI/Sequence.html">MIDI::Sequence</a>
|
399
|
-
make it easier to calculate the delta times that represent note lengths. <a
|
400
|
-
href="../classes/MIDI/Sequence.html#M000115">MIDI::Sequence#length_to_delta</a>
|
401
|
-
takes a note length (a multiple of a quarter note) and returns the delta
|
402
|
-
time given the sequence’s current ppqn (pulses per quarter note)
|
403
|
-
setting. 1 is a quarter note, 1.0/32.0 is a 32nd note (use floating-point
|
404
|
-
numbers to avoid integer rounding), 1.5 is a dotted quarter, etc. See the
|
405
|
-
documentation for that method for more information.
|
406
|
-
</p>
|
407
|
-
<p>
|
408
|
-
MIDI::Sequence::note_to_length takes a note name and returns a length value
|
409
|
-
(again, as a multiple of a quarter note). Legal note names are those found
|
410
|
-
in MIDI::Sequence::NOTE_TO_LENGTH, and may begin with "dotted"
|
411
|
-
and/or end with "triplet". For example, "whole",
|
412
|
-
"sixteenth", "32nd", "quarter triplet",
|
413
|
-
"dotted 16th", and "dotted 8th triplet" are all legal
|
414
|
-
note names.
|
415
|
-
</p>
|
416
|
-
<p>
|
417
|
-
Finally, MIDI::Sequence::note_to_delta takes a note name and returns a
|
418
|
-
delta time.
|
419
|
-
</p>
|
420
|
-
<h3>Example Scripts</h3>
|
421
|
-
<p>
|
422
|
-
Here are short descriptions of each of the examples found in the examples
|
423
|
-
directory.
|
424
|
-
</p>
|
425
|
-
<ul>
|
426
|
-
<li>examples/from_scratch.rb shows you how to create a new sequence from
|
427
|
-
scratch and save it to a <a href="../classes/MIDI.html">MIDI</a> file. It
|
428
|
-
creates a file called ‘from_scratch.mid’.
|
429
|
-
|
430
|
-
</li>
|
431
|
-
<li>examples/seq2text.rb dumps a <a href="../classes/MIDI.html">MIDI</a> file
|
432
|
-
as text. It reads in a sequence and uses the to_s method of each event.
|
433
|
-
|
434
|
-
</li>
|
435
|
-
<li>examples/reader2text.rb dumps a <a href="../classes/MIDI.html">MIDI</a>
|
436
|
-
file as text. It subclasses MIDI::SeqReader instead of creating a sequence
|
437
|
-
containing tracks and events.
|
438
|
-
|
439
|
-
</li>
|
440
|
-
<li>examples/transpose.rb transposes all note events (note on, note off, poly
|
441
|
-
pressure) on a specified channel by a specified amount.
|
442
|
-
|
443
|
-
</li>
|
444
|
-
<li>There is also one <a href="../classes/MIDI.html">MIDI</a> file,
|
445
|
-
examples/NoFences.mid. It is a little pop ditty I wrote. The instruments in
|
446
|
-
this file use General <a href="../classes/MIDI.html">MIDI</a> patch numbers
|
447
|
-
and drum note assignments. Since I don’t normally use GM patches, the
|
448
|
-
sounds used here are at best approximations of the sounds I use.
|
449
|
-
|
450
|
-
</li>
|
451
|
-
</ul>
|
452
|
-
<h2>Resources</h2>
|
453
|
-
<p>
|
454
|
-
The Ruby Web site (<a
|
455
|
-
href="http://www.ruby-lang.org/en/index.html">www.ruby-lang.org/en/index.html</a>)
|
456
|
-
contains an introduction to Ruby, the Ruby Application Archive (RAA) at <a
|
457
|
-
href="http://raa.ruby-lang.org">raa.ruby-lang.org</a>, and pointers to more
|
458
|
-
information.
|
459
|
-
</p>
|
460
|
-
<p>
|
461
|
-
<em>Programming Ruby, The Pragmatic Programmer’s
|
462
|
-
Guide<em>, by David Thomas and Andrew Hunt, is a well-written and
|
463
|
-
practical introduction to Ruby. Its Web page at <a
|
464
|
-
href="http://www.rubycentral.com/book">www.rubycentral.com/book</a> also
|
465
|
-
contains a wealth of Ruby information. Though the book is available online,
|
466
|
-
I encourage you to purchase a copy.
|
467
|
-
</p>
|
468
|
-
<p>
|
469
|
-
A description of the <a href="../classes/MIDI.html">MIDI</a> file format
|
470
|
-
can be found in a few places such as <a
|
471
|
-
href="http://www.borg.com/~jglatt/tech/midifile.htm">www.borg.com/~jglatt/tech/midifile.htm</a>.
|
472
|
-
</p>
|
473
|
-
<p>
|
474
|
-
The <a href="../classes/MIDI.html">MIDI</a> message reference at <a
|
475
|
-
href="http://www.io.com/~jimm/midi_ref.html">www.io.com/~jimm/midi_ref.html</a>
|
476
|
-
describes the format of <a href="../classes/MIDI.html">MIDI</a> commands.
|
477
|
-
</p>
|
478
|
-
<h1>To Do</h1>
|
479
|
-
<h2>Bugs</h2>
|
480
|
-
<ul>
|
481
|
-
<li>None known.
|
482
|
-
|
483
|
-
</li>
|
484
|
-
</ul>
|
485
|
-
<h2>Features</h2>
|
486
|
-
<ul>
|
487
|
-
<li>Method to translate event’s time_from_start to number of milliseconds
|
488
|
-
from start.
|
489
|
-
|
490
|
-
</li>
|
491
|
-
<li>Swing quantizing. (Implied by list email from Carl Youngblood
|
492
|
-
<carl.youngblood@gmail.com>)
|
493
|
-
|
494
|
-
</li>
|
495
|
-
<li>Implement key signature in SeqReader.
|
496
|
-
|
497
|
-
</li>
|
498
|
-
<li>Format 0 files.
|
499
|
-
|
500
|
-
</li>
|
501
|
-
<li>Format 2 files(?).
|
502
|
-
|
503
|
-
</li>
|
504
|
-
</ul>
|
505
|
-
<h2>Documentation</h2>
|
506
|
-
<ul>
|
507
|
-
<li>Write better docs.
|
508
|
-
|
509
|
-
</li>
|
510
|
-
</ul>
|
511
|
-
<h2>Tests</h2>
|
512
|
-
<ul>
|
513
|
-
<li>More needed?
|
514
|
-
|
515
|
-
</li>
|
516
|
-
</ul>
|
517
|
-
<h1>Support</h1>
|
518
|
-
<ul>
|
519
|
-
<li>Visit the forums, bug list, and mailing list pages at <a
|
520
|
-
href="http://rubyforge.org/projects/midilib">rubyforge.org/projects/midilib</a>
|
521
|
-
|
522
|
-
</li>
|
523
|
-
<li>Send email to Jim Menard at <a href="mailto:jimm@io.com">jimm@io.com</a>
|
524
|
-
|
525
|
-
</li>
|
526
|
-
<li>Ask on the ruby-talk mailing list
|
527
|
-
|
528
|
-
</li>
|
529
|
-
</ul>
|
530
|
-
<h1>Administrivia</h1>
|
531
|
-
<table>
|
532
|
-
<tr><td valign="top">Author:</td><td>Jim Menard (<a href="mailto:jimm@io.com">jimm@io.com</a>)
|
533
|
-
|
534
|
-
</td></tr>
|
535
|
-
<tr><td valign="top">Copyright:</td><td>Copyright © 2003-2004 Jim Menard
|
536
|
-
|
537
|
-
</td></tr>
|
538
|
-
<tr><td valign="top">License:</td><td>Distributed under the same license as Ruby.
|
539
|
-
|
540
|
-
</td></tr>
|
541
|
-
</table>
|
542
|
-
<h2>Copying</h2>
|
543
|
-
<p>
|
544
|
-
midilib is copyrighted free software by Jim Menard and is released under
|
545
|
-
the same license as Ruby. See the Ruby license at <a
|
546
|
-
href="http://www.ruby-lang.org/en/LICENSE.txt">www.ruby-lang.org/en/LICENSE.txt</a>.
|
547
|
-
</p>
|
548
|
-
<p>
|
549
|
-
midilib may be freely copied in its entirety providing this notice, all
|
550
|
-
source code, all documentation, and all other files are included.
|
551
|
-
</p>
|
552
|
-
<p>
|
553
|
-
midilib is Copyright © 2003-2004 by Jim Menard.
|
554
|
-
</p>
|
555
|
-
<p>
|
556
|
-
The song "No Fences" contained in the <a
|
557
|
-
href="../classes/MIDI.html">MIDI</a> file examples/NoFences.mid is
|
558
|
-
Copyright © 1992 by Jim Menard (jimm@io.com). It may be freely used
|
559
|
-
for non-commercial purposes as long as the author is given credit.
|
560
|
-
</p>
|
561
|
-
<h2>Warranty</h2>
|
562
|
-
<p>
|
563
|
-
This software is provided "as is" and without any express or
|
564
|
-
implied warranties, including, without limitation, the implied warranties
|
565
|
-
of merchantability and fitness for a particular purpose.
|
566
|
-
</p>
|
567
|
-
|
568
|
-
</div>
|
569
|
-
|
570
|
-
|
571
|
-
</div>
|
572
|
-
|
573
|
-
|
574
|
-
</div>
|
575
|
-
|
576
|
-
|
577
|
-
<!-- if includes -->
|
578
|
-
|
579
|
-
<div id="section">
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
<!-- if method_list -->
|
589
|
-
|
590
|
-
|
591
|
-
</div>
|
592
|
-
|
593
|
-
|
594
|
-
<div id="validator-badges">
|
595
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
596
|
-
</div>
|
597
|
-
|
598
|
-
</body>
|
599
|
-
</html>
|