midilib 2.0.2 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/Credits +5 -0
  2. data/README.rdoc +35 -30
  3. data/examples/reader2text.rb +1 -0
  4. data/html/IO.html +259 -0
  5. data/html/MIDI.html +665 -0
  6. data/html/MIDI/ActiveSense.html +295 -0
  7. data/html/MIDI/ChannelEvent.html +319 -0
  8. data/html/MIDI/ChannelPressure.html +350 -0
  9. data/html/MIDI/Clock.html +295 -0
  10. data/html/MIDI/Continue.html +295 -0
  11. data/html/MIDI/Controller.html +365 -0
  12. data/html/MIDI/Event.html +573 -0
  13. data/html/MIDI/IO.html +207 -0
  14. data/html/MIDI/IO/MIDIFile.html +1996 -0
  15. data/html/MIDI/IO/SeqReader.html +946 -0
  16. data/html/MIDI/IO/SeqWriter.html +648 -0
  17. data/html/MIDI/KeySig.html +435 -0
  18. data/html/MIDI/MIDI.html +204 -0
  19. data/html/MIDI/MIDI/MIDI.html +204 -0
  20. data/html/MIDI/MIDI/MIDI/Array.html +353 -0
  21. data/html/MIDI/Marker.html +257 -0
  22. data/html/MIDI/Measure.html +423 -0
  23. data/html/MIDI/Measures.html +375 -0
  24. data/html/MIDI/MetaEvent.html +534 -0
  25. data/html/MIDI/NoteEvent.html +417 -0
  26. data/html/MIDI/NoteOff.html +316 -0
  27. data/html/MIDI/NoteOn.html +316 -0
  28. data/html/MIDI/PitchBend.html +351 -0
  29. data/html/MIDI/PolyPressure.html +360 -0
  30. data/html/MIDI/ProgramChange.html +350 -0
  31. data/html/MIDI/Realtime.html +328 -0
  32. data/html/MIDI/Sequence.html +961 -0
  33. data/html/MIDI/SongPointer.html +351 -0
  34. data/html/MIDI/SongSelect.html +350 -0
  35. data/html/MIDI/Start.html +295 -0
  36. data/html/MIDI/Stop.html +295 -0
  37. data/html/MIDI/SystemCommon.html +257 -0
  38. data/html/MIDI/SystemExclusive.html +353 -0
  39. data/html/MIDI/SystemReset.html +295 -0
  40. data/html/MIDI/Tempo.html +474 -0
  41. data/html/MIDI/TimeSig.html +467 -0
  42. data/html/MIDI/Track.html +769 -0
  43. data/html/MIDI/TuneRequest.html +328 -0
  44. data/html/MIDI/Utils.html +320 -0
  45. data/html/README_rdoc.html +751 -0
  46. data/html/TODO_rdoc.html +200 -0
  47. data/html/created.rid +14 -0
  48. data/html/images/add.png +0 -0
  49. data/html/images/brick.png +0 -0
  50. data/html/images/brick_link.png +0 -0
  51. data/html/images/bug.png +0 -0
  52. data/html/images/bullet_black.png +0 -0
  53. data/html/images/bullet_toggle_minus.png +0 -0
  54. data/html/images/bullet_toggle_plus.png +0 -0
  55. data/html/images/date.png +0 -0
  56. data/html/images/delete.png +0 -0
  57. data/html/images/find.png +0 -0
  58. data/html/images/loadingAnimation.gif +0 -0
  59. data/html/images/macFFBgHack.png +0 -0
  60. data/html/images/package.png +0 -0
  61. data/html/images/page_green.png +0 -0
  62. data/html/images/page_white_text.png +0 -0
  63. data/html/images/page_white_width.png +0 -0
  64. data/html/images/plugin.png +0 -0
  65. data/html/images/ruby.png +0 -0
  66. data/html/images/tag_blue.png +0 -0
  67. data/html/images/tag_green.png +0 -0
  68. data/html/images/transparent.png +0 -0
  69. data/html/images/wrench.png +0 -0
  70. data/html/images/wrench_orange.png +0 -0
  71. data/html/images/zoom.png +0 -0
  72. data/html/index.html +750 -0
  73. data/html/js/darkfish.js +153 -0
  74. data/html/js/jquery.js +18 -0
  75. data/html/js/navigation.js +142 -0
  76. data/html/js/search.js +94 -0
  77. data/html/js/search_index.js +1 -0
  78. data/html/js/searcher.js +228 -0
  79. data/html/rdoc.css +543 -0
  80. data/html/table_of_contents.html +652 -0
  81. data/lib/midilib/info.rb +1 -1
  82. data/lib/midilib/io/seqreader.rb +1 -1
  83. data/lib/midilib/sequence.rb +7 -0
  84. data/test/test_sequence.rb +11 -0
  85. metadata +80 -3
@@ -2,7 +2,7 @@ module MIDI
2
2
 
3
3
  VERSION_MAJOR = 2
4
4
  VERSION_MINOR = 0
5
- VERSION_TWEAK = 2
5
+ VERSION_TWEAK = 4
6
6
  Version = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_TWEAK}"
7
7
  Copyright = 'Copyright (c) 2003-2012 by Jim Menard <jim@jimmenard.com>'
8
8
 
@@ -112,7 +112,7 @@ class SeqReader < MIDIFile
112
112
  track_uses_channel(chan)
113
113
  end
114
114
 
115
- def pitch_bend(chan, msb, lsb)
115
+ def pitch_bend(chan, lsb, msb)
116
116
  @track.events << PitchBend.new(chan, (msb << 7) + lsb, @curr_ticks)
117
117
  track_uses_channel(chan)
118
118
  end
@@ -75,6 +75,13 @@ class Sequence
75
75
  alias_method :bpm, :beats_per_minute
76
76
  alias_method :tempo, :beats_per_minute
77
77
 
78
+ # Pulses (also called ticks) are the units of delta times and event
79
+ # time_from_start values. This method converts a number of pulses to a
80
+ # float value that is a time in seconds.
81
+ def pulses_to_seconds(pulses)
82
+ (pulses.to_f / @ppqn.to_f / beats_per_minute()) * 60.0
83
+ end
84
+
78
85
  # Given a note length name like "whole", "dotted quarter", or "8th
79
86
  # triplet", return the length of that note in quarter notes as a delta
80
87
  # time.
@@ -23,6 +23,17 @@ class SequenceTester < Test::Unit::TestCase
23
23
  assert_equal(MIDI::Sequence::DEFAULT_TEMPO, @seq.bpm)
24
24
  end
25
25
 
26
+ def test_pulses_to_seconds
27
+ # At a tempo of 120 BPM 480 pulses (one quarter note) should take 0.5 seconds
28
+ assert_in_delta 0.5, @seq.pulses_to_seconds(480), 0.00001
29
+
30
+ # A half note should take one second
31
+ assert_in_delta 1.0, @seq.pulses_to_seconds(480*2), 0.00001
32
+
33
+ # An eight note should take 0.25 seconds
34
+ assert_in_delta 0.25, @seq.pulses_to_seconds(480/2), 0.00001
35
+ end
36
+
26
37
  def test_length_to_delta
27
38
  assert_equal(480, @seq.ppqn)
28
39
  assert_equal(480, @seq.length_to_delta(1))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midilib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'midilib is a pure Ruby MIDI library useful for reading and
15
15
 
@@ -38,6 +38,83 @@ files:
38
38
  - examples/split.rb
39
39
  - examples/strings.rb
40
40
  - examples/transpose.rb
41
+ - html/created.rid
42
+ - html/images/add.png
43
+ - html/images/brick.png
44
+ - html/images/brick_link.png
45
+ - html/images/bug.png
46
+ - html/images/bullet_black.png
47
+ - html/images/bullet_toggle_minus.png
48
+ - html/images/bullet_toggle_plus.png
49
+ - html/images/date.png
50
+ - html/images/delete.png
51
+ - html/images/find.png
52
+ - html/images/loadingAnimation.gif
53
+ - html/images/macFFBgHack.png
54
+ - html/images/package.png
55
+ - html/images/page_green.png
56
+ - html/images/page_white_text.png
57
+ - html/images/page_white_width.png
58
+ - html/images/plugin.png
59
+ - html/images/ruby.png
60
+ - html/images/tag_blue.png
61
+ - html/images/tag_green.png
62
+ - html/images/transparent.png
63
+ - html/images/wrench.png
64
+ - html/images/wrench_orange.png
65
+ - html/images/zoom.png
66
+ - html/index.html
67
+ - html/IO.html
68
+ - html/js/darkfish.js
69
+ - html/js/jquery.js
70
+ - html/js/navigation.js
71
+ - html/js/search.js
72
+ - html/js/search_index.js
73
+ - html/js/searcher.js
74
+ - html/MIDI/ActiveSense.html
75
+ - html/MIDI/ChannelEvent.html
76
+ - html/MIDI/ChannelPressure.html
77
+ - html/MIDI/Clock.html
78
+ - html/MIDI/Continue.html
79
+ - html/MIDI/Controller.html
80
+ - html/MIDI/Event.html
81
+ - html/MIDI/IO/MIDIFile.html
82
+ - html/MIDI/IO/SeqReader.html
83
+ - html/MIDI/IO/SeqWriter.html
84
+ - html/MIDI/IO.html
85
+ - html/MIDI/KeySig.html
86
+ - html/MIDI/Marker.html
87
+ - html/MIDI/Measure.html
88
+ - html/MIDI/Measures.html
89
+ - html/MIDI/MetaEvent.html
90
+ - html/MIDI/MIDI/MIDI/Array.html
91
+ - html/MIDI/MIDI/MIDI.html
92
+ - html/MIDI/MIDI.html
93
+ - html/MIDI/NoteEvent.html
94
+ - html/MIDI/NoteOff.html
95
+ - html/MIDI/NoteOn.html
96
+ - html/MIDI/PitchBend.html
97
+ - html/MIDI/PolyPressure.html
98
+ - html/MIDI/ProgramChange.html
99
+ - html/MIDI/Realtime.html
100
+ - html/MIDI/Sequence.html
101
+ - html/MIDI/SongPointer.html
102
+ - html/MIDI/SongSelect.html
103
+ - html/MIDI/Start.html
104
+ - html/MIDI/Stop.html
105
+ - html/MIDI/SystemCommon.html
106
+ - html/MIDI/SystemExclusive.html
107
+ - html/MIDI/SystemReset.html
108
+ - html/MIDI/Tempo.html
109
+ - html/MIDI/TimeSig.html
110
+ - html/MIDI/Track.html
111
+ - html/MIDI/TuneRequest.html
112
+ - html/MIDI/Utils.html
113
+ - html/MIDI.html
114
+ - html/rdoc.css
115
+ - html/README_rdoc.html
116
+ - html/table_of_contents.html
117
+ - html/TODO_rdoc.html
41
118
  - install.rb
42
119
  - lib/midilib/consts.rb
43
120
  - lib/midilib/event.rb
@@ -81,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
158
  requirements:
82
159
  - none
83
160
  rubyforge_project: midilib
84
- rubygems_version: 1.8.23
161
+ rubygems_version: 1.8.12
85
162
  signing_key:
86
163
  specification_version: 3
87
164
  summary: MIDI file and event manipulation library