unimidi 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/unimidi.rb +1 -1
- data/lib/unimidi/device.rb +13 -11
- data/lib/unimidi/output.rb +1 -1
- data/test/adapter_test.rb +11 -15
- data/test/class_methods_test.rb +19 -23
- data/test/functional_test.rb +45 -60
- data/test/helper.rb +44 -56
- data/test/input_test.rb +21 -23
- data/test/platform_test.rb +5 -5
- data/test/type_conversion_test.rb +2 -2
- metadata +38 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa827114029d69f1567ba44b38c9ba4247849722
|
4
|
+
data.tar.gz: a6f6e46bcf1f1a6b8bd6fc3d01c668b73c65c5e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb35485c5cd885ef8f58bad93adb17a94079885ac3b4b0bed8801c77059025d6e7078589f05a0bea85f8284c59f96bbfeef7c01d17e4f1e6e4a50cfa4fddc40b
|
7
|
+
data.tar.gz: b084ffb6e4829d4fb08b33169c03247dd9f4e8ec2e8ed22341194bc2f91fd24f56507e0b02a1fa69006d085383db9eae4e6aebe8d71ad10a826e87dfcfe0d5dd
|
data/lib/unimidi.rb
CHANGED
data/lib/unimidi/device.rb
CHANGED
@@ -105,21 +105,16 @@ module UniMIDI
|
|
105
105
|
populate_from_device
|
106
106
|
end
|
107
107
|
|
108
|
-
# Is this device ready for io?
|
109
|
-
# @return [Boolean]
|
110
|
-
def enabled?
|
111
|
-
@enabled = true if @device.enabled # keep the adapter in sync
|
112
|
-
@enabled
|
113
|
-
end
|
114
|
-
|
115
108
|
# Enable the device for use
|
116
109
|
# Params are passed to the underlying device object
|
117
110
|
# Can be passed a block to which the device will be passed in as the yieldparam
|
118
111
|
# @param [*Object] args
|
119
112
|
# @return [Input, Output] self
|
120
113
|
def open(*args, &block)
|
121
|
-
|
122
|
-
|
114
|
+
unless @enabled
|
115
|
+
@device.open(*args)
|
116
|
+
@enabled = true
|
117
|
+
end
|
123
118
|
if block_given?
|
124
119
|
begin
|
125
120
|
yield(self)
|
@@ -145,16 +140,23 @@ module UniMIDI
|
|
145
140
|
# @param [*Object] args
|
146
141
|
# @return [Boolean]
|
147
142
|
def close(*args)
|
148
|
-
@
|
149
|
-
|
143
|
+
if @enabled
|
144
|
+
@device.close(*args)
|
145
|
+
@enabled = false
|
146
|
+
true
|
147
|
+
else
|
148
|
+
false
|
149
|
+
end
|
150
150
|
end
|
151
151
|
|
152
152
|
# Add attributes for the device instance
|
153
153
|
# :direction, :id, :name
|
154
154
|
def self.included(base)
|
155
155
|
base.send(:attr_reader, :direction)
|
156
|
+
base.send(:attr_reader, :enabled)
|
156
157
|
base.send(:attr_reader, :id)
|
157
158
|
base.send(:attr_reader, :name)
|
159
|
+
base.send(:alias_method, :enabled?, :enabled)
|
158
160
|
base.send(:alias_method, :type, :direction)
|
159
161
|
end
|
160
162
|
|
data/lib/unimidi/output.rb
CHANGED
@@ -26,7 +26,7 @@ module UniMIDI
|
|
26
26
|
def puts(*messages)
|
27
27
|
message = messages.first
|
28
28
|
case message
|
29
|
-
when Array then
|
29
|
+
when Array then messages.each { |array| puts(*array.flatten) }
|
30
30
|
when Fixnum then puts_bytes(*messages)
|
31
31
|
when String then puts_s(*messages)
|
32
32
|
else
|
data/test/adapter_test.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class UniMIDI::AdapterTest <
|
3
|
+
class UniMIDI::AdapterTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
context "Adapter" do
|
6
6
|
|
7
|
-
setup do
|
8
|
-
TestDeviceHelper.setup
|
9
|
-
end
|
10
|
-
|
11
7
|
context "Device#type" do
|
12
8
|
|
13
9
|
should "be an input" do
|
14
|
-
input =
|
10
|
+
input = TestHelper.devices[:input]
|
15
11
|
assert_equal(:input, input.type)
|
16
12
|
end
|
17
13
|
|
18
14
|
should "be an output" do
|
19
|
-
output =
|
15
|
+
output = TestHelper.devices[:output]
|
20
16
|
assert_equal(:output, output.type)
|
21
17
|
end
|
22
18
|
|
@@ -25,11 +21,11 @@ class UniMIDI::AdapterTest < UniMIDI::TestCase
|
|
25
21
|
context "Device.count" do
|
26
22
|
|
27
23
|
setup do
|
28
|
-
@inputs = Input.all
|
24
|
+
@inputs = UniMIDI::Input.all
|
29
25
|
end
|
30
26
|
|
31
27
|
should "count all of the inputs" do
|
32
|
-
assert_equal @inputs.count, Input.count
|
28
|
+
assert_equal @inputs.count, UniMIDI::Input.count
|
33
29
|
end
|
34
30
|
|
35
31
|
end
|
@@ -37,12 +33,12 @@ class UniMIDI::AdapterTest < UniMIDI::TestCase
|
|
37
33
|
context "Device.find_by_name" do
|
38
34
|
|
39
35
|
setup do
|
40
|
-
index = rand(0..(Output.count-1))
|
41
|
-
@output = Output.all[index]
|
36
|
+
index = rand(0..(UniMIDI::Output.count-1))
|
37
|
+
@output = UniMIDI::Output.all[index]
|
42
38
|
end
|
43
39
|
|
44
40
|
should "select the correct input" do
|
45
|
-
result = Output.find_by_name(@output.name)
|
41
|
+
result = UniMIDI::Output.find_by_name(@output.name)
|
46
42
|
assert_equal @output, result
|
47
43
|
end
|
48
44
|
|
@@ -51,17 +47,17 @@ class UniMIDI::AdapterTest < UniMIDI::TestCase
|
|
51
47
|
context "Device.first" do
|
52
48
|
|
53
49
|
setup do
|
54
|
-
@output = Output.all.first
|
50
|
+
@output = UniMIDI::Output.all.first
|
55
51
|
end
|
56
52
|
|
57
53
|
should "open the output" do
|
58
54
|
@output.expects(:open)
|
59
|
-
output = Output.first
|
55
|
+
output = UniMIDI::Output.first
|
60
56
|
@output.unstub(:open)
|
61
57
|
end
|
62
58
|
|
63
59
|
should "return the correct output" do
|
64
|
-
output = Output.first
|
60
|
+
output = UniMIDI::Output.first
|
65
61
|
assert_equal @output, output
|
66
62
|
end
|
67
63
|
end
|
data/test/class_methods_test.rb
CHANGED
@@ -1,29 +1,25 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class UniMIDI::ClassMethodsTest <
|
3
|
+
class UniMIDI::ClassMethodsTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
context "ClassMethods" do
|
6
6
|
|
7
|
-
setup do
|
8
|
-
TestDeviceHelper.setup
|
9
|
-
end
|
10
|
-
|
11
7
|
context "#first" do
|
12
8
|
|
13
9
|
context "no block given" do
|
14
10
|
should "return first input" do
|
15
|
-
i = Input.first
|
16
|
-
assert_equal(Input.all.first, i)
|
11
|
+
i = UniMIDI::Input.first
|
12
|
+
assert_equal(UniMIDI::Input.all.first, i)
|
17
13
|
end
|
18
14
|
end
|
19
15
|
|
20
16
|
context "block given" do
|
21
17
|
should "pass and return first input" do
|
22
18
|
sleep(1)
|
23
|
-
i = Input.first do |i|
|
19
|
+
i = UniMIDI::Input.first do |i|
|
24
20
|
assert_equal(true, i.enabled?)
|
25
21
|
end
|
26
|
-
assert_equal(Input.all.first, i)
|
22
|
+
assert_equal(UniMIDI::Input.all.first, i)
|
27
23
|
end
|
28
24
|
|
29
25
|
end
|
@@ -33,18 +29,18 @@ class UniMIDI::ClassMethodsTest < UniMIDI::TestCase
|
|
33
29
|
|
34
30
|
context "no block given" do
|
35
31
|
should "return last input" do
|
36
|
-
i = Input.last
|
37
|
-
assert_equal(Input.all.last, i)
|
32
|
+
i = UniMIDI::Input.last
|
33
|
+
assert_equal(UniMIDI::Input.all.last, i)
|
38
34
|
end
|
39
35
|
end
|
40
36
|
|
41
37
|
context "block given" do
|
42
38
|
should "pass and return last input" do
|
43
39
|
sleep(1)
|
44
|
-
i = Input.last do |i|
|
40
|
+
i = UniMIDI::Input.last do |i|
|
45
41
|
assert_equal(true, i.enabled?)
|
46
42
|
end
|
47
|
-
assert_equal(Input.all.last, i)
|
43
|
+
assert_equal(UniMIDI::Input.all.last, i)
|
48
44
|
end
|
49
45
|
|
50
46
|
end
|
@@ -53,9 +49,9 @@ class UniMIDI::ClassMethodsTest < UniMIDI::TestCase
|
|
53
49
|
context "#[]" do
|
54
50
|
|
55
51
|
should "return correct input" do
|
56
|
-
i = Input[0]
|
57
|
-
assert_equal(Input.first, i)
|
58
|
-
assert_equal(Input.all.first, i)
|
52
|
+
i = UniMIDI::Input[0]
|
53
|
+
assert_equal(UniMIDI::Input.first, i)
|
54
|
+
assert_equal(UniMIDI::Input.all.first, i)
|
59
55
|
end
|
60
56
|
|
61
57
|
end
|
@@ -65,11 +61,11 @@ class UniMIDI::ClassMethodsTest < UniMIDI::TestCase
|
|
65
61
|
context "block given" do
|
66
62
|
should "return and enable an input" do
|
67
63
|
sleep(1)
|
68
|
-
i = Input.use(0) do |i|
|
64
|
+
i = UniMIDI::Input.use(0) do |i|
|
69
65
|
assert_equal(true, i.enabled?)
|
70
66
|
end
|
71
|
-
assert_equal(Input.first, i)
|
72
|
-
assert_equal(Input.all.first, i)
|
67
|
+
assert_equal(UniMIDI::Input.first, i)
|
68
|
+
assert_equal(UniMIDI::Input.all.first, i)
|
73
69
|
end
|
74
70
|
|
75
71
|
end
|
@@ -78,10 +74,10 @@ class UniMIDI::ClassMethodsTest < UniMIDI::TestCase
|
|
78
74
|
|
79
75
|
should "return an enabled input" do
|
80
76
|
sleep(1)
|
81
|
-
input = Input.use(:first)
|
77
|
+
input = UniMIDI::Input.use(:first)
|
82
78
|
assert_equal(true, input.enabled?)
|
83
|
-
assert_equal(Input.first, input)
|
84
|
-
assert_equal(Input.all.first, input)
|
79
|
+
assert_equal(UniMIDI::Input.first, input)
|
80
|
+
assert_equal(UniMIDI::Input.all.first, input)
|
85
81
|
end
|
86
82
|
|
87
83
|
end
|
@@ -90,7 +86,7 @@ class UniMIDI::ClassMethodsTest < UniMIDI::TestCase
|
|
90
86
|
|
91
87
|
context "#all" do
|
92
88
|
should "return all devices" do
|
93
|
-
assert_equal(Loader.devices(:direction => :input), Input.all)
|
89
|
+
assert_equal(UniMIDI::Loader.devices(:direction => :input), UniMIDI::Input.all)
|
94
90
|
end
|
95
91
|
end
|
96
92
|
|
data/test/functional_test.rb
CHANGED
@@ -1,84 +1,75 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class UniMIDI::FunctionalTest <
|
3
|
+
class UniMIDI::FunctionalTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
# ** these tests assume that TestOutput is connected to TestInput
|
6
6
|
context "UniMIDI" do
|
7
7
|
|
8
8
|
setup do
|
9
|
-
|
10
|
-
|
9
|
+
@input = TestHelper.devices[:input].open
|
10
|
+
@output = TestHelper.devices[:output].open
|
11
|
+
end
|
12
|
+
|
13
|
+
teardown do
|
14
|
+
@input.close
|
15
|
+
@output.close
|
11
16
|
end
|
12
17
|
|
13
18
|
context "full IO" do
|
14
19
|
|
15
|
-
context "using
|
20
|
+
context "using numeric bytes" do
|
16
21
|
|
17
22
|
setup do
|
18
|
-
@messages =
|
19
|
-
@messages_arr = @messages.inject
|
23
|
+
@messages = TestHelper.numeric_messages
|
24
|
+
@messages_arr = @messages.inject(&:+).flatten
|
20
25
|
@received_arr = []
|
21
26
|
@pointer = 0
|
22
27
|
end
|
23
28
|
|
24
29
|
should "do IO" do
|
25
|
-
TestDeviceHelper.devices[:output].open do |output|
|
26
|
-
TestDeviceHelper.devices[:input].open do |input|
|
27
|
-
|
28
|
-
input.buffer.clear
|
29
30
|
|
30
|
-
|
31
|
+
@messages.each do |message|
|
32
|
+
p "sending: #{message}"
|
31
33
|
|
32
|
-
|
34
|
+
@output.puts(message)
|
35
|
+
sleep(1)
|
36
|
+
received = @input.gets.map { |m| m[:data] }.flatten
|
33
37
|
|
34
|
-
|
35
|
-
sleep(1)
|
36
|
-
received = input.gets.map { |m| m[:data] }.flatten
|
38
|
+
p "received: #{received}"
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@pointer += received.length
|
42
|
-
@received_arr += received
|
43
|
-
end
|
44
|
-
assert_equal(@messages_arr.length, @received_arr.length)
|
45
|
-
end
|
40
|
+
assert_equal(@messages_arr.slice(@pointer, received.length), received)
|
41
|
+
@pointer += received.length
|
42
|
+
@received_arr += received
|
46
43
|
end
|
47
|
-
|
44
|
+
assert_equal(@messages_arr.length, @received_arr.length)
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
51
48
|
context "using byte Strings" do
|
52
49
|
|
53
50
|
setup do
|
54
|
-
@messages =
|
51
|
+
@messages = TestHelper.string_messages
|
55
52
|
@messages_str = @messages.join
|
56
53
|
@received_str = ""
|
57
54
|
@pointer = 0
|
58
55
|
end
|
59
56
|
|
60
57
|
should "do IO" do
|
61
|
-
TestDeviceHelper.devices[:output].open do |output|
|
62
|
-
TestDeviceHelper.devices[:input].open do |input|
|
63
58
|
|
64
|
-
|
59
|
+
@messages.each do |message|
|
65
60
|
|
66
|
-
|
61
|
+
p "sending: #{message}"
|
67
62
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
@output.puts(message)
|
64
|
+
sleep(1)
|
65
|
+
received = @input.gets_bytestr.map { |m| m[:data] }.flatten.join
|
66
|
+
p "received: #{received}"
|
72
67
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
assert_equal(@messages_str, @received_str)
|
78
|
-
|
79
|
-
end
|
68
|
+
assert_equal(@messages_str.slice(@pointer, received.length), received)
|
69
|
+
@pointer += received.length
|
70
|
+
@received_str += received
|
80
71
|
end
|
81
|
-
|
72
|
+
assert_equal(@messages_str, @received_str)
|
82
73
|
|
83
74
|
end
|
84
75
|
|
@@ -87,36 +78,30 @@ class UniMIDI::FunctionalTest < UniMIDI::TestCase
|
|
87
78
|
context "using MIDIMessages" do
|
88
79
|
|
89
80
|
setup do
|
90
|
-
@messages =
|
91
|
-
@messages_arr = @messages.map
|
81
|
+
@messages = TestHelper.message_objects
|
82
|
+
@messages_arr = @messages.map(&:to_bytes).flatten
|
92
83
|
@received_arr = []
|
93
84
|
@pointer = 0
|
94
85
|
end
|
95
86
|
|
96
87
|
should "do IO" do
|
97
|
-
TestDeviceHelper.devices[:output].open do |output|
|
98
|
-
TestDeviceHelper.devices[:input].open do |input|
|
99
|
-
|
100
|
-
#input.buffer.clear
|
101
88
|
|
102
|
-
|
89
|
+
@messages.each do |message|
|
103
90
|
|
104
|
-
|
91
|
+
p "sending: #{message}"
|
105
92
|
|
106
|
-
|
107
|
-
|
108
|
-
|
93
|
+
@output.puts(message)
|
94
|
+
sleep(1)
|
95
|
+
received = @input.gets.map { |m| m[:data] }.flatten
|
109
96
|
|
110
|
-
|
97
|
+
p "received: #{received}"
|
111
98
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
-
assert_equal(@messages_arr.length, @received_arr.length)
|
117
|
-
|
118
|
-
end
|
99
|
+
assert_equal(@messages_arr.slice(@pointer, received.length), received)
|
100
|
+
@pointer += received.length
|
101
|
+
@received_arr += received
|
119
102
|
end
|
103
|
+
assert_equal(@messages_arr.length, @received_arr.length)
|
104
|
+
|
120
105
|
end
|
121
106
|
|
122
107
|
end
|
data/test/helper.rb
CHANGED
@@ -6,81 +6,69 @@ require "mocha/test_unit"
|
|
6
6
|
require "shoulda-context"
|
7
7
|
require "unimidi"
|
8
8
|
|
9
|
-
module
|
9
|
+
module TestHelper
|
10
10
|
|
11
|
-
|
11
|
+
extend self
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def sysex_ok?
|
14
|
+
ENV["_system_name"] != "OSX" || !RUBY_PLATFORM.include?("java")
|
15
|
+
end
|
16
|
+
|
17
|
+
def devices
|
18
|
+
if @devices.nil?
|
19
|
+
@devices = {}
|
20
|
+
{ :input => UniMIDI::Input, :output => UniMIDI::Output }.each do |type, klass|
|
21
|
+
@devices[type] = klass.gets
|
19
22
|
end
|
20
23
|
end
|
24
|
+
@devices
|
25
|
+
end
|
21
26
|
|
22
|
-
|
23
|
-
|
27
|
+
def bytestrs_to_ints(arr)
|
28
|
+
data = arr.map { |m| m[:data] }.join
|
29
|
+
output = []
|
30
|
+
until (bytestr = data.slice!(0,2)).eql?("")
|
31
|
+
output << bytestr.hex
|
24
32
|
end
|
25
|
-
|
33
|
+
output
|
26
34
|
end
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def bytestrs_to_ints(arr)
|
33
|
-
data = arr.map { |m| m[:data] }.join
|
34
|
-
output = []
|
35
|
-
until (bytestr = data.slice!(0,2)).eql?("")
|
36
|
-
output << bytestr.hex
|
37
|
-
end
|
38
|
-
output
|
36
|
+
class MIDIObj
|
37
|
+
def initialize(*bytes)
|
38
|
+
@bytes = bytes
|
39
39
|
end
|
40
|
+
def to_bytes
|
41
|
+
@bytes
|
42
|
+
end
|
43
|
+
end
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
def to_bytes
|
46
|
-
@bytes
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# some MIDI messages
|
51
|
-
VariousMIDIObjects = [
|
52
|
-
TestSysex ? MIDIObj.new(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7) : nil, # SysEx
|
53
|
-
MIDIObj.new(0x90, 100, 100), # note on
|
54
|
-
MIDIObj.new(0x90, 43, 100), # note on
|
55
|
-
MIDIObj.new(0x90, 76, 100), # note on
|
56
|
-
MIDIObj.new(0x90, 60, 100), # note on
|
57
|
-
MIDIObj.new(0x80, 100, 100) # note off
|
58
|
-
].compact
|
45
|
+
def message_objects
|
46
|
+
numeric_messages.map { |message| MIDIObj.new(*message) }
|
47
|
+
end
|
59
48
|
|
60
|
-
|
61
|
-
|
62
|
-
TestSysex ? [0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7] : nil, # SysEx
|
49
|
+
def numeric_messages
|
50
|
+
messages = [
|
63
51
|
[0x90, 100, 100], # note on
|
64
52
|
[0x90, 43, 100], # note on
|
65
53
|
[0x90, 76, 100], # note on
|
66
54
|
[0x90, 60, 100], # note on
|
67
55
|
[0x80, 100, 100] # note off
|
68
|
-
]
|
56
|
+
]
|
57
|
+
if sysex_ok?
|
58
|
+
messages << [0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7]
|
59
|
+
end
|
60
|
+
messages
|
61
|
+
end
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
TestSysex ? "F04110421240007F0041F7" : nil, # SysEx
|
63
|
+
def string_messages
|
64
|
+
messages = [
|
73
65
|
"906440", # note on
|
74
66
|
"804340" # note off
|
75
|
-
]
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
include UniMIDI
|
82
|
-
include TestHelper
|
83
|
-
|
67
|
+
]
|
68
|
+
if sysex_ok?
|
69
|
+
messages << "F04110421240007F0041F7"
|
70
|
+
end
|
71
|
+
messages
|
84
72
|
end
|
85
73
|
|
86
74
|
end
|
data/test/input_test.rb
CHANGED
@@ -1,44 +1,42 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class UniMIDI::
|
3
|
+
class UniMIDI::InputTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
context "Input" do
|
6
6
|
|
7
|
-
setup do
|
8
|
-
TestDeviceHelper.setup
|
9
|
-
end
|
10
|
-
|
11
7
|
context "#buffer" do
|
12
8
|
|
13
9
|
setup do
|
14
|
-
sleep(1)
|
15
|
-
@
|
10
|
+
sleep(1)
|
11
|
+
@input = TestHelper.devices[:input].open
|
12
|
+
@output = TestHelper.devices[:output].open
|
13
|
+
@messages = TestHelper.numeric_messages
|
16
14
|
@bytes = []
|
17
15
|
end
|
18
16
|
|
19
|
-
|
17
|
+
teardown do
|
18
|
+
@input.close
|
19
|
+
@output.close
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
TestDeviceHelper.devices[:input].open do |input|
|
22
|
+
should "add received messages to the buffer" do
|
23
23
|
|
24
|
-
|
24
|
+
@input.buffer.clear
|
25
25
|
|
26
|
-
|
26
|
+
@messages.each do |message|
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
p "sending: #{message}"
|
29
|
+
@output.puts(message)
|
30
|
+
@bytes += message
|
31
|
+
sleep(1)
|
32
|
+
buffer = @input.buffer.map { |m| m[:data] }.flatten
|
33
|
+
p "received: #{buffer}"
|
34
|
+
assert_equal(@bytes, buffer)
|
35
35
|
|
36
|
-
|
36
|
+
end
|
37
37
|
|
38
|
-
|
38
|
+
assert_equal(@bytes.length, @input.buffer.map { |m| m[:data] }.flatten.length)
|
39
39
|
|
40
|
-
end
|
41
|
-
end
|
42
40
|
end
|
43
41
|
|
44
42
|
end
|
data/test/platform_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class UniMIDI::PlatformTest <
|
3
|
+
class UniMIDI::PlatformTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def platform_test(adapter, mod, device_class = nil, input_class = nil, output_class = nil)
|
6
6
|
device_class ||= mod::Device
|
@@ -20,25 +20,25 @@ class UniMIDI::PlatformTest < UniMIDI::TestCase
|
|
20
20
|
|
21
21
|
should "recognize java" do
|
22
22
|
if RUBY_PLATFORM.include?("java")
|
23
|
-
platform_test(Adapter::MIDIJRuby, ::MIDIJRuby)
|
23
|
+
platform_test(UniMIDI::Adapter::MIDIJRuby, ::MIDIJRuby)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
should "recognize linux" do
|
28
28
|
if RUBY_PLATFORM.include?("linux")
|
29
|
-
platform_test(Adapter::AlsaRawMIDI, ::AlsaRawMIDI)
|
29
|
+
platform_test(UniMIDI::Adapter::AlsaRawMIDI, ::AlsaRawMIDI)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
should "recognize osx" do
|
34
34
|
if RUBY_PLATFORM.include?("darwin")
|
35
|
-
platform_test(Adapter::CoreMIDI, ::CoreMIDI, ::CoreMIDI::Endpoint, ::CoreMIDI::Source, ::CoreMIDI::Destination)
|
35
|
+
platform_test(UniMIDI::Adapter::CoreMIDI, ::CoreMIDI, ::CoreMIDI::Endpoint, ::CoreMIDI::Source, ::CoreMIDI::Destination)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
should "recognize windows" do
|
40
40
|
if RUBY_PLATFORM.include?("mingw")
|
41
|
-
platform_test(Adapter::MIDIWinMM, ::MIDIWinMM)
|
41
|
+
platform_test(UniMIDI::Adapter::MIDIWinMM, ::MIDIWinMM)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class UniMIDI::TypeConversionTest <
|
3
|
+
class UniMIDI::TypeConversionTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
context "TypeConversion" do
|
6
6
|
|
7
7
|
context "#numeric_byte_array_to_hex_string" do
|
8
8
|
|
9
9
|
should "convert byte array to hex string" do
|
10
|
-
result = TypeConversion.numeric_byte_array_to_hex_string([0x90, 0x40, 0x40])
|
10
|
+
result = UniMIDI::TypeConversion.numeric_byte_array_to_hex_string([0x90, 0x40, 0x40])
|
11
11
|
assert "904040", result
|
12
12
|
end
|
13
13
|
|
metadata
CHANGED
@@ -1,85 +1,79 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unimidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alsa-rawmidi
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
15
20
|
requirement: !ruby/object:Gem::Requirement
|
16
21
|
requirements:
|
17
|
-
- -
|
22
|
+
- - ~>
|
18
23
|
- !ruby/object:Gem::Version
|
19
24
|
version: '0'
|
20
|
-
type: :runtime
|
21
25
|
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ffi-coremidi
|
22
29
|
version_requirements: !ruby/object:Gem::Requirement
|
23
30
|
requirements:
|
24
|
-
- -
|
31
|
+
- - ~>
|
25
32
|
- !ruby/object:Gem::Version
|
26
33
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ffi-coremidi
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
30
35
|
requirements:
|
31
|
-
- -
|
36
|
+
- - ~>
|
32
37
|
- !ruby/object:Gem::Version
|
33
38
|
version: '0'
|
34
|
-
type: :runtime
|
35
39
|
prerelease: false
|
40
|
+
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: midi-jruby
|
36
43
|
version_requirements: !ruby/object:Gem::Requirement
|
37
44
|
requirements:
|
38
|
-
- -
|
45
|
+
- - ~>
|
39
46
|
- !ruby/object:Gem::Version
|
40
47
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: midi-jruby
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
44
49
|
requirements:
|
45
|
-
- -
|
50
|
+
- - ~>
|
46
51
|
- !ruby/object:Gem::Version
|
47
52
|
version: '0'
|
48
|
-
type: :runtime
|
49
53
|
prerelease: false
|
54
|
+
type: :runtime
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: midi-winmm
|
50
57
|
version_requirements: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: midi-winmm
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
58
63
|
requirements:
|
59
|
-
- -
|
64
|
+
- - ~>
|
60
65
|
- !ruby/object:Gem::Version
|
61
66
|
version: '0'
|
62
|
-
type: :runtime
|
63
67
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description: Platform Independent, realtime MIDI input and output for Ruby
|
68
|
+
type: :runtime
|
69
|
+
description: Platform independent realtime MIDI input and output for Ruby
|
70
70
|
email:
|
71
71
|
- ari.russo@gmail.com
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- LICENSE
|
77
|
-
- README.md
|
78
76
|
- lib/unimidi.rb
|
79
|
-
- lib/unimidi/adapter/alsa-rawmidi.rb
|
80
|
-
- lib/unimidi/adapter/ffi-coremidi.rb
|
81
|
-
- lib/unimidi/adapter/midi-jruby.rb
|
82
|
-
- lib/unimidi/adapter/midi-winmm.rb
|
83
77
|
- lib/unimidi/command.rb
|
84
78
|
- lib/unimidi/device.rb
|
85
79
|
- lib/unimidi/input.rb
|
@@ -87,6 +81,10 @@ files:
|
|
87
81
|
- lib/unimidi/output.rb
|
88
82
|
- lib/unimidi/platform.rb
|
89
83
|
- lib/unimidi/type_conversion.rb
|
84
|
+
- lib/unimidi/adapter/alsa-rawmidi.rb
|
85
|
+
- lib/unimidi/adapter/ffi-coremidi.rb
|
86
|
+
- lib/unimidi/adapter/midi-jruby.rb
|
87
|
+
- lib/unimidi/adapter/midi-winmm.rb
|
90
88
|
- test/adapter_test.rb
|
91
89
|
- test/class_methods_test.rb
|
92
90
|
- test/functional_test.rb
|
@@ -94,28 +92,30 @@ files:
|
|
94
92
|
- test/input_test.rb
|
95
93
|
- test/platform_test.rb
|
96
94
|
- test/type_conversion_test.rb
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
97
|
homepage: http://github.com/arirusso/unimidi
|
98
98
|
licenses:
|
99
99
|
- Apache 2.0
|
100
100
|
metadata: {}
|
101
|
-
post_install_message:
|
101
|
+
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|
104
104
|
- lib
|
105
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - '>='
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 1.3.6
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project: unimidi
|
117
|
-
rubygems_version: 2.
|
118
|
-
signing_key:
|
117
|
+
rubygems_version: 2.1.9
|
118
|
+
signing_key:
|
119
119
|
specification_version: 4
|
120
|
-
summary: Realtime MIDI
|
120
|
+
summary: Realtime MIDI IO for Ruby
|
121
121
|
test_files: []
|