midilib 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/ChangeLog +3 -1
  2. data/Credits +6 -1
  3. data/README.rdoc +41 -15
  4. data/Rakefile +3 -11
  5. data/TODO.rdoc +4 -7
  6. data/examples/from_scratch.rb +2 -2
  7. data/examples/measures_mbt.rb +1 -1
  8. data/examples/print_program_changes.rb +1 -1
  9. data/examples/strings.rb +1 -1
  10. data/examples/transpose.rb +1 -1
  11. data/html/Array.html +382 -0
  12. data/html/IO.html +277 -0
  13. data/html/MIDI.html +829 -0
  14. data/html/MIDI/ActiveSense.html +317 -0
  15. data/html/MIDI/ChannelEvent.html +347 -0
  16. data/html/MIDI/ChannelPressure.html +379 -0
  17. data/html/MIDI/Clock.html +317 -0
  18. data/html/MIDI/Continue.html +317 -0
  19. data/html/MIDI/Controller.html +398 -0
  20. data/html/MIDI/Event.html +659 -0
  21. data/html/MIDI/IO.html +238 -0
  22. data/html/MIDI/IO/MIDIFile.html +2269 -0
  23. data/html/MIDI/IO/SeqReader.html +1051 -0
  24. data/html/MIDI/IO/SeqWriter.html +706 -0
  25. data/html/MIDI/KeySig.html +487 -0
  26. data/html/MIDI/Marker.html +275 -0
  27. data/html/MIDI/Measure.html +479 -0
  28. data/html/MIDI/Measures.html +416 -0
  29. data/html/MIDI/MetaEvent.html +617 -0
  30. data/html/MIDI/NoteEvent.html +459 -0
  31. data/html/MIDI/NoteOff.html +341 -0
  32. data/html/MIDI/NoteOn.html +341 -0
  33. data/html/MIDI/PitchBend.html +380 -0
  34. data/html/MIDI/PolyPressure.html +390 -0
  35. data/html/MIDI/ProgramChange.html +379 -0
  36. data/html/MIDI/Realtime.html +354 -0
  37. data/html/MIDI/Sequence.html +1063 -0
  38. data/html/MIDI/SongPointer.html +380 -0
  39. data/html/MIDI/SongSelect.html +379 -0
  40. data/html/MIDI/Start.html +317 -0
  41. data/html/MIDI/Stop.html +317 -0
  42. data/html/MIDI/SystemCommon.html +275 -0
  43. data/html/MIDI/SystemExclusive.html +382 -0
  44. data/html/MIDI/SystemReset.html +317 -0
  45. data/html/MIDI/Tempo.html +519 -0
  46. data/html/MIDI/TimeSig.html +524 -0
  47. data/html/MIDI/Track.html +859 -0
  48. data/html/MIDI/TuneRequest.html +354 -0
  49. data/html/MIDI/Utils.html +350 -0
  50. data/html/README_rdoc.html +882 -0
  51. data/html/TODO_rdoc.html +215 -0
  52. data/html/created.rid +14 -0
  53. data/html/images/brick.png +0 -0
  54. data/html/images/brick_link.png +0 -0
  55. data/html/images/bug.png +0 -0
  56. data/html/images/bullet_black.png +0 -0
  57. data/html/images/bullet_toggle_minus.png +0 -0
  58. data/html/images/bullet_toggle_plus.png +0 -0
  59. data/html/images/date.png +0 -0
  60. data/html/images/find.png +0 -0
  61. data/html/images/loadingAnimation.gif +0 -0
  62. data/html/images/macFFBgHack.png +0 -0
  63. data/html/images/package.png +0 -0
  64. data/html/images/page_green.png +0 -0
  65. data/html/images/page_white_text.png +0 -0
  66. data/html/images/page_white_width.png +0 -0
  67. data/html/images/plugin.png +0 -0
  68. data/html/images/ruby.png +0 -0
  69. data/html/images/tag_green.png +0 -0
  70. data/html/images/wrench.png +0 -0
  71. data/html/images/wrench_orange.png +0 -0
  72. data/html/images/zoom.png +0 -0
  73. data/html/index.html +1266 -0
  74. data/html/js/darkfish.js +116 -0
  75. data/html/js/jquery.js +32 -0
  76. data/html/js/quicksearch.js +114 -0
  77. data/html/js/thickbox-compressed.js +10 -0
  78. data/html/lib/midilib/consts_rb.html +55 -0
  79. data/html/lib/midilib/event_rb.html +56 -0
  80. data/html/lib/midilib/info_rb.html +52 -0
  81. data/html/lib/midilib/io/midifile_rb.html +54 -0
  82. data/html/lib/midilib/io/seqreader_rb.html +58 -0
  83. data/html/lib/midilib/io/seqwriter_rb.html +59 -0
  84. data/html/lib/midilib/measure_rb.html +54 -0
  85. data/html/lib/midilib/sequence_rb.html +58 -0
  86. data/html/lib/midilib/track_rb.html +54 -0
  87. data/html/lib/midilib/utils_rb.html +52 -0
  88. data/html/lib/midilib_rb.html +71 -0
  89. data/html/rdoc.css +706 -0
  90. data/install.rb +1 -1
  91. data/lib/midilib/event.rb +11 -77
  92. data/lib/midilib/info.rb +4 -4
  93. data/lib/midilib/io/seqreader.rb +2 -2
  94. data/lib/midilib/io/seqwriter.rb +1 -1
  95. data/lib/midilib/sequence.rb +1 -1
  96. data/lib/midilib/track.rb +54 -8
  97. data/test/test_event.rb +4 -62
  98. data/test/test_sequence.rb +1 -1
  99. data/test/test_track.rb +39 -5
  100. metadata +102 -9
data/ChangeLog CHANGED
@@ -1,3 +1,5 @@
1
+ For any further change descriptions, see the Git logs.
2
+
1
3
  2007-12-11 Jim Menard <jim@iamplify.com>
2
4
 
3
5
  * lib/midilib/io/seqreader.rb: Fixed text method and added default
@@ -25,7 +27,7 @@
25
27
 
26
28
  * Version 1.0.0 released. I will no longer be maintaining this
27
29
  change log; the Subversion comments should be sufficient.
28
-
30
+
29
31
  2006-08-20 Jim Menard <jimm@io.com>
30
32
 
31
33
  * lib/midilib/event.rb (PolyPressure::initialize): Fixed the
data/Credits CHANGED
@@ -26,7 +26,7 @@ Jari Williamsson <jari.williamsson@mailbox.swipnet.se>
26
26
  Added get_measures to Sequence. Added default implementation of
27
27
  key_signature in SeqReader. Contributed the measures_mbt.rb example.
28
28
 
29
- Noah Thorp <noah@rixiform.com>
29
+ Noah Thorp
30
30
 
31
31
  Found a bug in the code intended to make midilib work under Ruby 1.9.
32
32
  Found another bug in KeySing.data_as_bytes.
@@ -35,3 +35,8 @@ Zach Chadwick (zachad on Github)
35
35
 
36
36
  Reported a problem that led to a fix in the way that strings and byte
37
37
  arrays are handled and output in meta events.
38
+
39
+ Adam Murray (adamjmurray on Github)
40
+
41
+ Found problem with Track#recalc_delta_from_times sorting, and wrote the
42
+ fix that is incorporated there.
@@ -5,9 +5,12 @@ MIDI files and manipulating MIDI event data. Classes include MIDI::Sequence,
5
5
  MIDI::Track, MIDI::Event, and MIDI::IO::MIDIFile and its subclasses
6
6
  MIDI::IO::SeqReader and MIDI::IO::SeqWriter.
7
7
 
8
- The Web site of midilib is (http://midilib.rubyforge.org). The RubyForge
9
- project page is http://rubyforge.org/projects/midilib, where the latest
10
- version of midilib may be downloaded. midilib is also available as a RubyGem.
8
+ The GitHub project page and Web site of midilib is
9
+ http://github.com/jimm/midilib and the RubyGems.org page is
10
+ http://rubygems.org/gems/midilib, where you can also find all the RDoc
11
+ documentation.
12
+
13
+ midilib is compatible with both Ruby 1.8.x and 1.9.x.
11
14
 
12
15
 
13
16
  == Dependencies
@@ -160,7 +163,7 @@ number of tracks and the number of the current track that has just been read.
160
163
  This is useful for notifying the user of progress, for example by updating a
161
164
  GUI progress bar.
162
165
 
163
- require 'midi/io/seqreader'
166
+ require 'midilib/io/seqreader'
164
167
 
165
168
  # Create a new, empty sequence.
166
169
  seq = MIDI::Sequence.new()
@@ -179,7 +182,7 @@ GUI progress bar.
179
182
  To write a MIDI file, call the write method, passing in an IO object.
180
183
 
181
184
 
182
- require 'midi/io/seqwriter'
185
+ require 'midilib/io/seqwriter'
183
186
 
184
187
  # Start with a sequence that has something worth saving.
185
188
  seq = read_or_create_seq_we_care_not_how()
@@ -201,8 +204,8 @@ be transposed: the method #note? returns true.
201
204
 
202
205
  ==== Transposing One Channel
203
206
 
204
- require 'midi/io/seqreader'
205
- require 'midi/io/seqwriter'
207
+ require 'midilib/io/seqreader'
208
+ require 'midilib/io/seqwriter'
206
209
 
207
210
  # Create a new, empty sequence.
208
211
  seq = MIDI::Sequence.new()
@@ -323,7 +326,7 @@ the format of MIDI commands.
323
326
  = Administrivia
324
327
 
325
328
  Author:: Jim Menard (mailto:jimm@io.com)
326
- Copyright:: Copyright (c) 2003-2009 Jim Menard
329
+ Copyright:: Copyright (c) 2003-2010 Jim Menard
327
330
  License:: Distributed under the same license as Ruby.
328
331
 
329
332
 
@@ -336,7 +339,7 @@ http://www.ruby-lang.org/en/LICENSE.txt.
336
339
  midilib may be freely copied in its entirety providing this notice, all
337
340
  source code, all documentation, and all other files are included.
338
341
 
339
- midilib is Copyright (c) 2003-2009 by Jim Menard.
342
+ midilib is Copyright (c) 2003-2010 by Jim Menard.
340
343
 
341
344
  The song "No Fences" contained in the MIDI file examples/NoFences.mid is
342
345
  Copyright (c) 1992 by Jim Menard (jimm@io.com). It may be freely used for
@@ -345,6 +348,35 @@ non-commercial purposes as long as the author is given credit.
345
348
 
346
349
  === Recent Changes
347
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::NoteOn
363
+ do_this()
364
+ when MIDI::NoteOff
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
+
348
380
  ==== Changes for 1.2.0:
349
381
 
350
382
  Use byte arrays instead of strings for passing around data. All tests now pass
@@ -450,9 +482,3 @@ The midilib code is now hosted at Github (http://github.com/jimm/midilib).
450
482
  This software is provided "as is" and without any express or implied
451
483
  warranties, including, without limitation, the implied warranties of
452
484
  merchantability and fitness for a particular purpose.
453
-
454
- --
455
- # Local Variables:
456
- # mode:rdoc
457
- # End:
458
- ++
data/Rakefile CHANGED
@@ -2,11 +2,9 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/rdoctask'
4
4
  require 'rake/gempackagetask'
5
- require 'rake/contrib/rubyforgepublisher'
6
5
  require 'rake/runtest'
7
6
 
8
7
  PROJECT_NAME = 'midilib'
9
- RUBYFORGE_USER = 'jimm'
10
8
  RDOC_DIR = 'html'
11
9
 
12
10
  PKG_FILES = FileList[ 'ChangeLog', 'Credits', 'Rakefile',
@@ -26,7 +24,6 @@ spec = Gem::Specification.new do |s|
26
24
  s.requirements << 'none'
27
25
 
28
26
  s.require_path = 'lib'
29
- s.autorequire = PROJECT_NAME
30
27
 
31
28
  s.files = PKG_FILES.to_a
32
29
 
@@ -36,7 +33,7 @@ spec = Gem::Specification.new do |s|
36
33
 
37
34
  s.author = 'Jim Menard'
38
35
  s.email = 'jimm@io.com'
39
- s.homepage = 'http://midilib.rubyforge.org'
36
+ s.homepage = 'http://github.com/jimm/midilib'
40
37
  s.rubyforge_project = PROJECT_NAME
41
38
 
42
39
  s.summary = "MIDI file and event manipulation library"
@@ -60,13 +57,8 @@ Rake::RDocTask.new do | rd |
60
57
  rd.rdoc_files.include('README.rdoc', 'TODO.rdoc', 'lib/**/*.rb')
61
58
  end
62
59
 
63
- task :rubyforge => [:rdoc] do
64
- Rake::RubyForgePublisher.new(PROJECT_NAME, RUBYFORGE_USER).upload
65
- end
66
-
67
- desc "Publish html docs to midilib.rubyforge.org"
68
- task :publish => [:rdoc] do
69
- system "scp -rC html/* jimm@rubyforge.org:/var/www/gforge-projects/midilib"
60
+ task :publish => [:rdoc, :package] do
61
+ system "gem push"
70
62
  end
71
63
 
72
64
  task :test do
data/TODO.rdoc CHANGED
@@ -1,13 +1,12 @@
1
1
  == Bugs
2
2
 
3
- * Track#recalc_delta_from_times needs to use a stable sorting algorithm. See
4
- Adam's notes at http://github.com/adamjmurray/cosy/wikis/midilib-notes and
5
- solution at
6
- http://github.com/adamjmurray/cosy/tree/master/lib/cosy/renderer/midi_file_renderer.rb.
7
- Adam has given me permission to include his fix.
3
+ No known bugs. (If that's not a challenge, I don't know what is.)
8
4
 
9
5
  == Features
10
6
 
7
+ * =print_decimal_numbers= and =print_channel_numbers_from_one= should be
8
+ associated with sequence, or perhaps track, not event.
9
+
11
10
  * Method to translate event's time_from_start to number of milliseconds from
12
11
  start.
13
12
 
@@ -26,6 +25,4 @@
26
25
 
27
26
  == Tests
28
27
 
29
- * Tests for Adam's stable sorting algorithm.
30
-
31
28
  * Tests for Noah Thorp's midilib bug fixes.
@@ -41,8 +41,8 @@ track.events << Controller.new(0, CC_VOLUME, 127)
41
41
  track.events << ProgramChange.new(0, 1, 0)
42
42
  quarter_note_length = seq.note_to_delta('quarter')
43
43
  [0, 2, 4, 5, 7, 9, 11, 12].each { | offset |
44
- track.events << NoteOnEvent.new(0, 64 + offset, 127, 0)
45
- track.events << NoteOffEvent.new(0, 64 + offset, 127, quarter_note_length)
44
+ track.events << NoteOn.new(0, 64 + offset, 127, 0)
45
+ track.events << NoteOff.new(0, 64 + offset, 127, quarter_note_length)
46
46
  }
47
47
 
48
48
  # Calling recalc_times is not necessary, because that only sets the events'
@@ -21,7 +21,7 @@ measures = seq.get_measures
21
21
 
22
22
  seq.each { | track |
23
23
  track.each { | e |
24
- if e.note_on? then
24
+ if e.kind_of?(MIDI::NoteOn) then
25
25
  # Print out start of notes
26
26
  e.print_note_names = true
27
27
  puts measures.to_mbt(e) + " ch #{e.channel}: #{e.note_to_s}"
@@ -23,6 +23,6 @@ seq.each { | track |
23
23
  track.each { | e |
24
24
  e.print_decimal_numbers = true
25
25
  e.print_channel_numbers_from_one = true
26
- puts e if e.program_change?
26
+ puts e if e.kind_of?(MIDI::ProgramChange)
27
27
  }
28
28
  }
@@ -27,7 +27,7 @@ File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb') { | file |
27
27
  include MIDI
28
28
  seq.each { | track |
29
29
  track.each { | event |
30
- puts event.data if event.meta? &&
30
+ puts event.data if event.kind_of?(MIDI::MetaEvent) &&
31
31
  [META_TEXT, META_COPYRIGHT, META_SEQ_NAME, META_INSTRUMENT,
32
32
  META_LYRIC, META_CUE, META_MARKER].include?(event.meta_type)
33
33
  }
@@ -58,7 +58,7 @@ File.open(ARGV[0], 'rb') { | file |
58
58
 
59
59
  seq.each { | track |
60
60
  track.each { | event |
61
- if event.note? && event.channel == channel
61
+ if event.kind_of?(MIDI::NoteEvent) && event.channel == channel
62
62
  val = event.note + transpose
63
63
  if val < 0 || val > 127
64
64
  $stderr.puts "transposition out of range; ignored"
@@ -0,0 +1,382 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: Array</title>
9
+
10
+ <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="./js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="./js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="./js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="./lib/midilib/track_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/midilib/track.rb">lib/midilib/track.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link">Object</p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-i-merge">#merge</a></li>
73
+
74
+ <li><a href="#method-i-mergesort">#mergesort</a></li>
75
+
76
+ <li><a href="#method-i-split">#split</a></li>
77
+
78
+ </ul>
79
+ </div>
80
+
81
+
82
+ <!-- Included Modules -->
83
+
84
+ </div>
85
+
86
+ <div id="project-metadata">
87
+
88
+
89
+ <div id="fileindex-section" class="section project-section">
90
+ <h3 class="section-header">Files</h3>
91
+ <ul>
92
+
93
+ <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
94
+
95
+ <li class="file"><a href="./TODO_rdoc.html">TODO.rdoc</a></li>
96
+
97
+ </ul>
98
+ </div>
99
+
100
+
101
+ <div id="classindex-section" class="section project-section">
102
+ <h3 class="section-header">Class Index
103
+ <span class="search-toggle"><img src="./images/find.png"
104
+ height="16" width="16" alt="[+]"
105
+ title="show/hide quicksearch" /></span></h3>
106
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
107
+ <fieldset>
108
+ <legend>Quicksearch</legend>
109
+ <input type="text" name="quicksearch" value=""
110
+ class="quicksearch-field" />
111
+ </fieldset>
112
+ </form>
113
+
114
+ <ul class="link-list">
115
+
116
+ <li><a href="./MIDI.html">MIDI</a></li>
117
+
118
+ <li><a href="./MIDI/ActiveSense.html">MIDI::ActiveSense</a></li>
119
+
120
+ <li><a href="./MIDI/ChannelEvent.html">MIDI::ChannelEvent</a></li>
121
+
122
+ <li><a href="./MIDI/ChannelPressure.html">MIDI::ChannelPressure</a></li>
123
+
124
+ <li><a href="./MIDI/Clock.html">MIDI::Clock</a></li>
125
+
126
+ <li><a href="./MIDI/Continue.html">MIDI::Continue</a></li>
127
+
128
+ <li><a href="./MIDI/Controller.html">MIDI::Controller</a></li>
129
+
130
+ <li><a href="./MIDI/Event.html">MIDI::Event</a></li>
131
+
132
+ <li><a href="./MIDI/IO.html">MIDI::IO</a></li>
133
+
134
+ <li><a href="./MIDI/IO/MIDIFile.html">MIDI::IO::MIDIFile</a></li>
135
+
136
+ <li><a href="./MIDI/IO/SeqReader.html">MIDI::IO::SeqReader</a></li>
137
+
138
+ <li><a href="./MIDI/IO/SeqWriter.html">MIDI::IO::SeqWriter</a></li>
139
+
140
+ <li><a href="./MIDI/KeySig.html">MIDI::KeySig</a></li>
141
+
142
+ <li><a href="./MIDI/Marker.html">MIDI::Marker</a></li>
143
+
144
+ <li><a href="./MIDI/Measure.html">MIDI::Measure</a></li>
145
+
146
+ <li><a href="./MIDI/Measures.html">MIDI::Measures</a></li>
147
+
148
+ <li><a href="./MIDI/MetaEvent.html">MIDI::MetaEvent</a></li>
149
+
150
+ <li><a href="./MIDI/NoteEvent.html">MIDI::NoteEvent</a></li>
151
+
152
+ <li><a href="./MIDI/NoteOff.html">MIDI::NoteOff</a></li>
153
+
154
+ <li><a href="./MIDI/NoteOff.html">MIDI::NoteOff</a></li>
155
+
156
+ <li><a href="./MIDI/NoteOn.html">MIDI::NoteOn</a></li>
157
+
158
+ <li><a href="./MIDI/NoteOn.html">MIDI::NoteOn</a></li>
159
+
160
+ <li><a href="./MIDI/PitchBend.html">MIDI::PitchBend</a></li>
161
+
162
+ <li><a href="./MIDI/PolyPressure.html">MIDI::PolyPressure</a></li>
163
+
164
+ <li><a href="./MIDI/ProgramChange.html">MIDI::ProgramChange</a></li>
165
+
166
+ <li><a href="./MIDI/Realtime.html">MIDI::Realtime</a></li>
167
+
168
+ <li><a href="./MIDI/Sequence.html">MIDI::Sequence</a></li>
169
+
170
+ <li><a href="./MIDI/SongPointer.html">MIDI::SongPointer</a></li>
171
+
172
+ <li><a href="./MIDI/SongSelect.html">MIDI::SongSelect</a></li>
173
+
174
+ <li><a href="./MIDI/Start.html">MIDI::Start</a></li>
175
+
176
+ <li><a href="./MIDI/Stop.html">MIDI::Stop</a></li>
177
+
178
+ <li><a href="./MIDI/SystemCommon.html">MIDI::SystemCommon</a></li>
179
+
180
+ <li><a href="./MIDI/SystemExclusive.html">MIDI::SystemExclusive</a></li>
181
+
182
+ <li><a href="./MIDI/SystemReset.html">MIDI::SystemReset</a></li>
183
+
184
+ <li><a href="./MIDI/Tempo.html">MIDI::Tempo</a></li>
185
+
186
+ <li><a href="./MIDI/TimeSig.html">MIDI::TimeSig</a></li>
187
+
188
+ <li><a href="./MIDI/Track.html">MIDI::Track</a></li>
189
+
190
+ <li><a href="./MIDI/TuneRequest.html">MIDI::TuneRequest</a></li>
191
+
192
+ <li><a href="./MIDI/Utils.html">MIDI::Utils</a></li>
193
+
194
+ <li><a href="./Array.html">Array</a></li>
195
+
196
+ <li><a href="./IO.html">IO</a></li>
197
+
198
+ </ul>
199
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
200
+ </div>
201
+
202
+
203
+ </div>
204
+ </div>
205
+
206
+ <div id="documentation">
207
+ <h1 class="class">Array</h1>
208
+
209
+ <div id="description">
210
+ <p>
211
+ This is taken from <a
212
+ href="http://github.com/adamjmurray/cosy/blob/master/lib/cosy/helper/midi_file_renderer_helper.rb">github.com/adamjmurray/cosy/blob/master/lib/cosy/helper/midi_file_renderer_helper.rb</a>
213
+ with permission from Adam Murray, who originally suggested this fix. See <a
214
+ href="http://wiki.github.com/adamjmurray/cosy/midilib-notes">wiki.github.com/adamjmurray/cosy/midilib-notes</a>
215
+ for details. First we need to add some API infrastructure:
216
+ </p>
217
+
218
+ </div>
219
+
220
+ <!-- Constants -->
221
+
222
+
223
+ <!-- Attributes -->
224
+
225
+
226
+ <!-- Methods -->
227
+
228
+ <div id="public-instance-method-details" class="method-section section">
229
+ <h3 class="section-header">Public Instance Methods</h3>
230
+
231
+
232
+ <div id="mergesort-method" class="method-detail ">
233
+ <a name="method-i-mergesort"></a>
234
+
235
+ <div class="method-heading">
236
+
237
+ <span class="method-name">mergesort</span><span
238
+ class="method-args">(&cmp)</span>
239
+ <span class="method-click-advice">click to toggle source</span>
240
+
241
+ </div>
242
+
243
+ <div class="method-description">
244
+
245
+ <p>
246
+ A stable sorting algorithm that maintains the relative order of equal
247
+ elements
248
+ </p>
249
+
250
+
251
+
252
+ <div class="method-source-code"
253
+ id="mergesort-source">
254
+ <pre>
255
+ <span class="ruby-comment cmt"># File lib/midilib/track.rb, line 12</span>
256
+ 12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mergesort</span>(&amp;<span class="ruby-identifier">cmp</span>)
257
+ 13: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmp</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
258
+ 14: <span class="ruby-identifier">cmp</span> = <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">b</span> }
259
+ 15: <span class="ruby-keyword kw">end</span>
260
+ 16: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">1</span>
261
+ 17: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
262
+ 18: <span class="ruby-keyword kw">else</span>
263
+ 19: <span class="ruby-identifier">halves</span> = <span class="ruby-identifier">split</span>.<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">half</span><span class="ruby-operator">|</span>
264
+ 20: <span class="ruby-identifier">half</span>.<span class="ruby-identifier">mergesort</span>(&amp;<span class="ruby-identifier">cmp</span>)
265
+ 21: }
266
+ 22: <span class="ruby-identifier">merge</span>(*<span class="ruby-identifier">halves</span>, &amp;<span class="ruby-identifier">cmp</span>)
267
+ 23: <span class="ruby-keyword kw">end</span>
268
+ 24: <span class="ruby-keyword kw">end</span></pre>
269
+ </div>
270
+
271
+ </div>
272
+
273
+
274
+
275
+
276
+ </div>
277
+
278
+
279
+ </div>
280
+
281
+ <div id="protected-instance-method-details" class="method-section section">
282
+ <h3 class="section-header">Protected Instance Methods</h3>
283
+
284
+
285
+ <div id="merge-method" class="method-detail ">
286
+ <a name="method-i-merge"></a>
287
+
288
+ <div class="method-heading">
289
+
290
+ <span class="method-name">merge</span><span
291
+ class="method-args">(first, second, &predicate)</span>
292
+ <span class="method-click-advice">click to toggle source</span>
293
+
294
+ </div>
295
+
296
+ <div class="method-description">
297
+
298
+
299
+
300
+
301
+
302
+ <div class="method-source-code"
303
+ id="merge-source">
304
+ <pre>
305
+ <span class="ruby-comment cmt"># File lib/midilib/track.rb, line 32</span>
306
+ 32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">first</span>, <span class="ruby-identifier">second</span>, &amp;<span class="ruby-identifier">predicate</span>)
307
+ 33: <span class="ruby-identifier">result</span> = []
308
+ 34: <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">first</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">second</span>.<span class="ruby-identifier">empty?</span>
309
+ 35: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">predicate</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">first</span>.<span class="ruby-identifier">first</span>, <span class="ruby-identifier">second</span>.<span class="ruby-identifier">first</span>) <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>
310
+ 36: <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">first</span>.<span class="ruby-identifier">shift</span>
311
+ 37: <span class="ruby-keyword kw">else</span>
312
+ 38: <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">second</span>.<span class="ruby-identifier">shift</span>
313
+ 39: <span class="ruby-keyword kw">end</span>
314
+ 40: <span class="ruby-keyword kw">end</span>
315
+ 41: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">first</span>).<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">second</span>)
316
+ 42: <span class="ruby-keyword kw">end</span></pre>
317
+ </div>
318
+
319
+ </div>
320
+
321
+
322
+
323
+
324
+ </div>
325
+
326
+
327
+ <div id="split-method" class="method-detail ">
328
+ <a name="method-i-split"></a>
329
+
330
+ <div class="method-heading">
331
+
332
+ <span class="method-name">split</span><span
333
+ class="method-args">()</span>
334
+ <span class="method-click-advice">click to toggle source</span>
335
+
336
+ </div>
337
+
338
+ <div class="method-description">
339
+
340
+
341
+
342
+
343
+
344
+ <div class="method-source-code"
345
+ id="split-source">
346
+ <pre>
347
+ <span class="ruby-comment cmt"># File lib/midilib/track.rb, line 27</span>
348
+ 27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">split</span>
349
+ 28: <span class="ruby-identifier">n</span> = (<span class="ruby-identifier">length</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span>).<span class="ruby-identifier">floor</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
350
+ 29: [<span class="ruby-keyword kw">self</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span>], <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">n</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">1</span>]]
351
+ 30: <span class="ruby-keyword kw">end</span></pre>
352
+ </div>
353
+
354
+ </div>
355
+
356
+
357
+
358
+
359
+ </div>
360
+
361
+
362
+ </div>
363
+
364
+
365
+ </div>
366
+
367
+
368
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
369
+
370
+ <p>Disabled; run with --debug to generate this.</p>
371
+
372
+ </div>
373
+
374
+ <div id="validator-badges">
375
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
376
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
377
+ Rdoc Generator</a> 1.1.6</small>.</p>
378
+ </div>
379
+
380
+ </body>
381
+ </html>
382
+