midi-message 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = MIDI Message
2
2
 
3
- {pic}[http://images.treetrouble.net/images/mks80_small.jpg]
3
+ {pic}[http://img208.imageshack.us/img208/5623/mks80small.jpg]
4
4
 
5
5
  MIDI messages, objectified in Ruby
6
6
 
@@ -2,6 +2,22 @@
2
2
  #
3
3
 
4
4
  module MIDIMessage
5
+
6
+ #
7
+ # MIDI System message
8
+ #
9
+ module SystemMessage
10
+
11
+ # In the case of something like SystemCommon.new(0xF2, 0x00, 0x08), the first nibble F is redundant because
12
+ # all system messages start with 0xF and it can be assumed.
13
+ # However, the this method looks to see if this has occurred and strips the redundancy
14
+ # @param [Integer] byte The byte to strip of a redundant 0xF
15
+ # @return [Integer] The remaining nibble
16
+ def strip_redundant_nibble(byte)
17
+ byte > 0xF ? (byte & 0x0F) : byte
18
+ end
19
+
20
+ end
5
21
 
6
22
  #
7
23
  # MIDI System-Common message
@@ -9,6 +25,7 @@ module MIDIMessage
9
25
  class SystemCommon
10
26
 
11
27
  include ShortMessage
28
+ include SystemMessage
12
29
  use_display_name 'System Common'
13
30
 
14
31
  attr_reader :data
@@ -16,9 +33,10 @@ module MIDIMessage
16
33
  def initialize(*a)
17
34
  options = a.last.kind_of?(Hash) ? a.pop : {}
18
35
  @const = options[:const]
19
- @data = [a[1], a[2]]
20
- second_nibble = @const.nil? ? a[0] : @const.value
21
- initialize_short_message(0xF, second_nibble)
36
+ id = @const.nil? ? a.shift : @const.value
37
+ id = strip_redundant_nibble(id)
38
+ initialize_short_message(0xF, id)
39
+ @data = [a[0], a[1]]
22
40
  end
23
41
 
24
42
  end
@@ -29,12 +47,14 @@ module MIDIMessage
29
47
  class SystemRealtime
30
48
 
31
49
  include ShortMessage
50
+ include SystemMessage
32
51
  use_display_name 'System Realtime'
33
52
 
34
53
  def initialize(*a)
35
54
  options = a.last.kind_of?(Hash) ? a.pop : {}
36
55
  @const = options[:const]
37
56
  id = @const.nil? ? a[0] : @const.value
57
+ id = strip_redundant_nibble(id)
38
58
  initialize_short_message(0xF, id)
39
59
  end
40
60
 
data/lib/midi-message.rb CHANGED
@@ -11,7 +11,7 @@ module MIDIMessage
11
11
  module Process
12
12
  end
13
13
 
14
- VERSION = "0.3.1"
14
+ VERSION = "0.3.2"
15
15
 
16
16
  end
17
17
 
@@ -37,4 +37,4 @@ require "midi-message/process/processor"
37
37
  require "midi-message/event/note"
38
38
  require "midi-message/process/filter"
39
39
  require "midi-message/process/limit"
40
- require "midi-message/process/transpose"
40
+ require "midi-message/process/transpose"
data/lib/midi.yml CHANGED
@@ -110,6 +110,7 @@ Manufacturer:
110
110
 
111
111
  Emagic: [0x00, 0x20, 0x31]
112
112
  Behringer: [0x00, 0x20, 0x32]
113
+ Access: [0x00, 0x20, 0x33]
113
114
 
114
115
  Note:
115
116
  C-1: 0
@@ -120,4 +120,4 @@ class ShortMessageTest < Test::Unit::TestCase
120
120
  assert_equal("F8", msg.to_bytestr)
121
121
  end
122
122
 
123
- end
123
+ end
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'helper'
4
+
5
+ class SystemMessageTest < Test::Unit::TestCase
6
+
7
+ include MIDIMessage
8
+ include TestHelper
9
+
10
+ def test_system_common
11
+ msg = SystemCommon.new(0x2, 0x00, 0x08)
12
+ assert_equal("Song Position Pointer", msg.name)
13
+ assert_equal(0xF, msg.status[0])
14
+ assert_equal(0x2, msg.status[1])
15
+ assert_equal(0x00, msg.data[0])
16
+ assert_equal(0x08, msg.data[1])
17
+ assert_equal([0xF2, 0x00, 0x08], msg.to_a)
18
+ assert_equal("F20008", msg.to_bytestr)
19
+ end
20
+
21
+ def test_system_common_redundant
22
+ msg = SystemCommon.new(0xF2, 0x00, 0x08)
23
+ assert_equal("Song Position Pointer", msg.name)
24
+ assert_equal(0xF, msg.status[0])
25
+ assert_equal(0x2, msg.status[1])
26
+ assert_equal(0x00, msg.data[0])
27
+ assert_equal(0x08, msg.data[1])
28
+ assert_equal([0xF2, 0x00, 0x08], msg.to_a)
29
+ assert_equal("F20008", msg.to_bytestr)
30
+ end
31
+
32
+ def test_system_common_constant
33
+ msg = SystemCommon["Song Position Pointer"].new(0x00, 0x08)
34
+ assert_equal("Song Position Pointer", msg.name)
35
+ assert_equal(0xF, msg.status[0])
36
+ assert_equal(0x2, msg.status[1])
37
+ assert_equal(0x00, msg.data[0])
38
+ assert_equal(0x08, msg.data[1])
39
+ assert_equal([0xF2, 0x00, 0x08], msg.to_a)
40
+ assert_equal("F20008", msg.to_bytestr)
41
+ end
42
+
43
+ def test_system_realtime
44
+ msg = SystemRealtime.new(0x8)
45
+ assert_equal("Clock", msg.name)
46
+ assert_equal(0xF, msg.status[0])
47
+ assert_equal(0x8, msg.status[1])
48
+ assert_equal([0xF8], msg.to_a)
49
+ assert_equal("F8", msg.to_bytestr)
50
+ end
51
+
52
+ def test_system_realtime_redundant
53
+ msg = SystemRealtime.new(0xF8)
54
+ assert_equal("Clock", msg.name)
55
+ assert_equal(0xF, msg.status[0])
56
+ assert_equal(0x8, msg.status[1])
57
+ assert_equal([0xF8], msg.to_a)
58
+ assert_equal("F8", msg.to_bytestr)
59
+ end
60
+
61
+ def test_system_realtime_constant
62
+ msg = SystemRealtime["Clock"].new
63
+ assert_equal("Clock", msg.name)
64
+ assert_equal(0xF, msg.status[0])
65
+ assert_equal(0x8, msg.status[1])
66
+ assert_equal([0xF8], msg.to_a)
67
+ assert_equal("F8", msg.to_bytestr)
68
+ end
69
+
70
+ end
71
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midi-message
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
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: 2011-09-27 00:00:00.000000000Z
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: MIDI messages, objectified in Ruby
15
15
  email:
@@ -45,6 +45,7 @@ files:
45
45
  - test/test_processor.rb
46
46
  - test/test_short_message.rb
47
47
  - test/test_system_exclusive.rb
48
+ - test/test_system_message.rb
48
49
  - test/test_transpose.rb
49
50
  - LICENSE
50
51
  - README.rdoc
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  version: 1.3.6
70
71
  requirements: []
71
72
  rubyforge_project: midi-message
72
- rubygems_version: 1.8.6
73
+ rubygems_version: 1.8.23
73
74
  signing_key:
74
75
  specification_version: 3
75
76
  summary: MIDI messages, objectified in Ruby