midi-eye 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/midi-eye.rb +1 -1
- data/lib/midi-eye/listener.rb +1 -1
- data/test/helper.rb +5 -11
- data/test/listener_test.rb +106 -90
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2b3e0af881e2a337de19d43af2ba0e0119e99c3
|
4
|
+
data.tar.gz: 60027129b318dbb0056535890bb43baa383d0080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c532eb1705410cfe8250f09730765d9e0fce8dd52548cdc3c233554b7fdb7a6435b17655b9230629050e322c7526311c84ac8cd15a7dc37429fcb0364396ce70
|
7
|
+
data.tar.gz: 84d9b10631497e3f14b176197b5b9008ee5a1778ec2bcc3a43904a13b4aec3c2dd9b69bb05976cf051c8443b09f9d299b7c08694c2e33cb8a54888c5718190bd
|
data/lib/midi-eye.rb
CHANGED
data/lib/midi-eye/listener.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
dir = File.dirname(File.expand_path(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(dir + "/../lib")
|
3
3
|
|
4
|
-
require "
|
4
|
+
require "minitest/autorun"
|
5
5
|
require "mocha/test_unit"
|
6
6
|
require "shoulda-context"
|
7
7
|
|
@@ -11,21 +11,15 @@ module TestHelper
|
|
11
11
|
|
12
12
|
extend self
|
13
13
|
|
14
|
+
attr_reader :device
|
15
|
+
|
14
16
|
def select_devices
|
15
|
-
|
17
|
+
@device ||= {}
|
16
18
|
{ :input => UniMIDI::Input, :output => UniMIDI::Output }.each do |type, klass|
|
17
|
-
|
19
|
+
@device[type] = klass.gets
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
def close_all(input, output, listener)
|
22
|
-
listener.close
|
23
|
-
input.clear_buffer
|
24
|
-
input.close
|
25
|
-
output.close
|
26
|
-
sleep(0.1)
|
27
|
-
end
|
28
|
-
|
29
23
|
end
|
30
24
|
|
31
25
|
TestHelper.select_devices
|
data/test/listener_test.rb
CHANGED
@@ -1,118 +1,138 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class ListenerTest < Test
|
3
|
+
class ListenerTest < Minitest::Test
|
4
4
|
|
5
5
|
context "Listener" do
|
6
6
|
|
7
7
|
setup do
|
8
8
|
sleep(0.2)
|
9
|
-
@output =
|
10
|
-
@input =
|
9
|
+
@output = TestHelper.device[:output]
|
10
|
+
@input = TestHelper.device[:input]
|
11
11
|
@listener = MIDIEye::Listener.new(@input)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
teardown do
|
15
|
+
@listener.close
|
16
|
+
@input.clear_buffer
|
17
|
+
@input.close
|
18
|
+
@output.close
|
19
|
+
sleep(0.5)
|
20
|
+
end
|
15
21
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
context "#listen_for" do
|
23
|
+
|
24
|
+
context "no filter" do
|
25
|
+
|
26
|
+
setup do
|
27
|
+
@i = 0
|
28
|
+
@listener.listen_for do |event|
|
29
|
+
@i += 1
|
30
|
+
end
|
31
|
+
@listener.start(:background => true)
|
32
|
+
sleep(0.5)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "receive messages" do
|
36
|
+
@output.puts(0x90, 0x40, 0x10)
|
37
|
+
sleep(0.2)
|
38
|
+
assert_equal 1, @i
|
22
39
|
end
|
23
|
-
@listener.start(:background => true)
|
24
|
-
sleep(0.5)
|
25
|
-
end
|
26
40
|
|
27
|
-
should "receive messages" do
|
28
|
-
@output.puts(0x90, 0x40, 0x10)
|
29
|
-
@listener.join
|
30
41
|
end
|
31
42
|
|
32
|
-
|
43
|
+
context "filter on control change" do
|
33
44
|
|
34
|
-
|
45
|
+
context "rapid messages" do
|
35
46
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
47
|
+
setup do
|
48
|
+
@i = 0
|
49
|
+
@listener.listen_for(:class => MIDIMessage::ControlChange) do |event|
|
50
|
+
@i += 1
|
51
|
+
end
|
52
|
+
@listener.start(:background => true)
|
53
|
+
sleep(0.5)
|
43
54
|
end
|
44
|
-
end
|
45
|
-
@listener.start(:background => true)
|
46
|
-
sleep(0.5)
|
47
|
-
end
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
should "receive messages" do
|
57
|
+
5.times do
|
58
|
+
126.times do |i|
|
59
|
+
@output.puts(176, 1, i+1)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
sleep(1)
|
63
|
+
assert_equal(5 * 126, @i)
|
53
64
|
end
|
65
|
+
|
54
66
|
end
|
55
|
-
@listener.join
|
56
|
-
end
|
57
67
|
|
58
|
-
|
68
|
+
context "normal messages" do
|
69
|
+
|
70
|
+
setup do
|
71
|
+
@event = nil
|
72
|
+
@listener.listen_for(:class => MIDIMessage::ControlChange) do |event|
|
73
|
+
@event = event
|
74
|
+
end
|
75
|
+
@listener.start(:background => true)
|
76
|
+
sleep(0.5)
|
77
|
+
@input.clear_buffer
|
78
|
+
end
|
59
79
|
|
60
|
-
|
80
|
+
should "receive messages" do
|
81
|
+
@output.puts(176, 1, 35)
|
82
|
+
sleep(0.2)
|
83
|
+
refute_nil @event
|
84
|
+
assert_equal(MIDIMessage::ControlChange, @event[:message].class)
|
85
|
+
assert_equal(1, @event[:message].index)
|
86
|
+
assert_equal(35, @event[:message].value)
|
87
|
+
assert_equal([176, 1, 35], @event[:message].to_bytes)
|
88
|
+
end
|
61
89
|
|
62
|
-
setup do
|
63
|
-
@listener.listen_for(:class => MIDIMessage::ControlChange) do |event|
|
64
|
-
assert_equal(MIDIMessage::ControlChange, event[:message].class)
|
65
|
-
assert_equal(1, event[:message].index)
|
66
|
-
assert_equal(35, event[:message].value)
|
67
|
-
assert_equal([176, 1, 35], event[:message].to_bytes)
|
68
|
-
TestHelper.close_all(@input, @output, @listener)
|
69
90
|
end
|
70
|
-
@listener.start(:background => true)
|
71
|
-
sleep(0.5)
|
72
|
-
end
|
73
91
|
|
74
|
-
should "receive messages" do
|
75
|
-
@output.puts(176, 1, 35)
|
76
|
-
@listener.join
|
77
92
|
end
|
78
|
-
end
|
79
93
|
|
80
|
-
|
94
|
+
context "filter on sysex" do
|
81
95
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
96
|
+
setup do
|
97
|
+
@event = nil
|
98
|
+
@listener.listen_for(:class => MIDIMessage::SystemExclusive::Command) do |event|
|
99
|
+
@event = event
|
100
|
+
end
|
101
|
+
@listener.start(:background => true)
|
102
|
+
sleep(0.5)
|
103
|
+
end
|
104
|
+
|
105
|
+
should "receive messages" do
|
106
|
+
@output.puts(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
107
|
+
sleep(0.2)
|
108
|
+
refute_nil @event
|
109
|
+
assert_equal(MIDIMessage::SystemExclusive::Command, @event[:message].class)
|
110
|
+
assert_equal([0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7], @event[:message].to_byte_array)
|
87
111
|
end
|
88
|
-
@listener.start(:background => true)
|
89
|
-
sleep(0.5)
|
90
|
-
end
|
91
112
|
|
92
|
-
should "receive messages" do
|
93
|
-
@output.puts(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
94
|
-
@listener.join
|
95
113
|
end
|
96
114
|
|
97
|
-
|
115
|
+
context "filter on note on" do
|
98
116
|
|
99
|
-
|
117
|
+
setup do
|
118
|
+
@event = nil
|
119
|
+
@listener.listen_for(:class => MIDIMessage::NoteOff) do |event|
|
120
|
+
@event = event
|
121
|
+
end
|
122
|
+
@listener.start(:background => true)
|
123
|
+
sleep(0.5)
|
124
|
+
end
|
100
125
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
assert_equal(
|
106
|
-
assert_equal(
|
107
|
-
|
126
|
+
should "receive messages" do
|
127
|
+
@output.puts(0x80, 0x50, 0x40)
|
128
|
+
sleep(0.2)
|
129
|
+
refute_nil @event
|
130
|
+
assert_equal(MIDIMessage::NoteOff, @event[:message].class)
|
131
|
+
assert_equal(0x50, @event[:message].note)
|
132
|
+
assert_equal(0x40, @event[:message].velocity)
|
133
|
+
assert_equal([0x80, 0x50, 0x40], @event[:message].to_bytes)
|
108
134
|
end
|
109
|
-
@listener.start(:background => true)
|
110
|
-
sleep(0.5)
|
111
|
-
end
|
112
135
|
|
113
|
-
should "receive messages" do
|
114
|
-
@output.puts(0x80, 0x50, 0x40)
|
115
|
-
@listener.join
|
116
136
|
end
|
117
137
|
|
118
138
|
end
|
@@ -120,19 +140,19 @@ class ListenerTest < Test::Unit::TestCase
|
|
120
140
|
context "#delete_event" do
|
121
141
|
|
122
142
|
setup do
|
143
|
+
@event = nil
|
123
144
|
@listener.listen_for(:listener_name => :test) do |event|
|
124
|
-
|
125
|
-
@listener.delete_event(:test)
|
126
|
-
assert_equal(0, @listener.event.count)
|
127
|
-
TestHelper.close_all(@input, @output, @listener)
|
145
|
+
@event = event
|
128
146
|
end
|
147
|
+
@output.puts(0x90, 0x70, 0x20)
|
129
148
|
@listener.start(:background => true)
|
130
149
|
sleep(0.5)
|
131
150
|
end
|
132
151
|
|
133
|
-
should "
|
134
|
-
|
135
|
-
@listener.
|
152
|
+
should "delete event" do
|
153
|
+
assert_equal(1, @listener.event.count)
|
154
|
+
@listener.delete_event(:test)
|
155
|
+
assert_equal(0, @listener.event.count)
|
136
156
|
end
|
137
157
|
|
138
158
|
end
|
@@ -170,17 +190,13 @@ class ListenerTest < Test::Unit::TestCase
|
|
170
190
|
context "#close" do
|
171
191
|
|
172
192
|
setup do
|
173
|
-
@listener.listen_for(:class => MIDIMessage::NoteOff) do |event|
|
174
|
-
TestHelper.close_all(@input, @output, @listener)
|
175
|
-
end
|
176
193
|
@listener.start(:background => true)
|
177
|
-
sleep(0.5)
|
178
194
|
@output.puts(0x80, 0x50, 0x40)
|
179
|
-
@listener.join
|
180
195
|
end
|
181
196
|
|
182
197
|
should "close" do
|
183
198
|
assert @listener.close
|
199
|
+
sleep(0.5)
|
184
200
|
refute @listener.running?
|
185
201
|
end
|
186
202
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midi-eye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: midi-message
|