unimidi 0.2.2-i386-mingw32 → 0.2.3-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/unimidi.rb +1 -1
- data/lib/unimidi/adapter/alsa-rawmidi.rb +2 -0
- data/lib/unimidi/adapter/ffi-coremidi.rb +13 -2
- data/lib/unimidi/adapter/midi-jruby.rb +2 -0
- data/lib/unimidi/adapter/midi-winmm.rb +2 -0
- data/lib/unimidi/congruous_api_adapter.rb +41 -15
- data/test/helper.rb +12 -9
- data/test/test_input_buffer.rb +2 -0
- data/test/test_io.rb +6 -2
- data/test/test_platform.rb +1 -1
- data/test/test_selectors.rb +56 -0
- metadata +10 -9
data/lib/unimidi.rb
CHANGED
@@ -9,10 +9,12 @@ module UniMIDI
|
|
9
9
|
|
10
10
|
class Input < CongruousApiInput
|
11
11
|
defer_to AlsaRawMIDI::Input
|
12
|
+
device_class AlsaRawMIDI::Device
|
12
13
|
end
|
13
14
|
|
14
15
|
class Output < CongruousApiOutput
|
15
16
|
defer_to AlsaRawMIDI::Output
|
17
|
+
device_class AlsaRawMIDI::Device
|
16
18
|
end
|
17
19
|
|
18
20
|
class Device < CongruousApiDevice
|
@@ -8,17 +8,28 @@ module UniMIDI
|
|
8
8
|
module CoreMIDIAdapter
|
9
9
|
|
10
10
|
class Input < CongruousApiInput
|
11
|
-
defer_to CoreMIDI::
|
11
|
+
defer_to CoreMIDI::Source
|
12
|
+
device_class CoreMIDI::Endpoint
|
12
13
|
end
|
13
14
|
|
14
15
|
class Output < CongruousApiOutput
|
15
|
-
defer_to CoreMIDI::
|
16
|
+
defer_to CoreMIDI::Destination
|
17
|
+
device_class CoreMIDI::Endpoint
|
16
18
|
end
|
17
19
|
|
18
20
|
class Device < CongruousApiDevice
|
19
21
|
defer_to CoreMIDI::Endpoint
|
20
22
|
input_class Input
|
21
23
|
output_class Output
|
24
|
+
|
25
|
+
def self.populate
|
26
|
+
klass = @deference[self].respond_to?(:all_by_type) ? @deference[self] : @device_class
|
27
|
+
@devices = {
|
28
|
+
:input => klass.all_by_type[:source].map { |d| @input_class.new(d) },
|
29
|
+
:output => klass.all_by_type[:destination].map { |d| @output_class.new(d) }
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
22
33
|
end
|
23
34
|
|
24
35
|
end
|
@@ -9,10 +9,12 @@ module UniMIDI
|
|
9
9
|
|
10
10
|
class Input < CongruousApiInput
|
11
11
|
defer_to MIDIJRuby::Input
|
12
|
+
device_class MIDIJRuby::Device
|
12
13
|
end
|
13
14
|
|
14
15
|
class Output < CongruousApiOutput
|
15
16
|
defer_to MIDIJRuby::Output
|
17
|
+
device_class MIDIJRuby::Device
|
16
18
|
end
|
17
19
|
|
18
20
|
class Device < CongruousApiDevice
|
@@ -9,10 +9,12 @@ module UniMIDI
|
|
9
9
|
|
10
10
|
class Input < CongruousApiInput
|
11
11
|
defer_to MIDIWinMM::Input
|
12
|
+
device_class MIDIWinMM::Device
|
12
13
|
end
|
13
14
|
|
14
15
|
class Output < CongruousApiOutput
|
15
16
|
defer_to MIDIWinMM::Output
|
17
|
+
device_class MIDIWinMM::Device
|
16
18
|
end
|
17
19
|
|
18
20
|
class Device < CongruousApiDevice
|
@@ -13,6 +13,10 @@ module UniMIDI
|
|
13
13
|
@name = @device.name
|
14
14
|
@type = @device.type
|
15
15
|
end
|
16
|
+
|
17
|
+
def enabled?
|
18
|
+
@device.enabled
|
19
|
+
end
|
16
20
|
|
17
21
|
# enable the device for use, can be passed a block to which the device will be passed back
|
18
22
|
def open(*a, &block)
|
@@ -47,17 +51,13 @@ module UniMIDI
|
|
47
51
|
module ClassMethods
|
48
52
|
|
49
53
|
# returns the first device for this class
|
50
|
-
def first(
|
51
|
-
|
52
|
-
raise 'Device not found' if dev.nil?
|
53
|
-
new(dev)
|
54
|
+
def first(&block)
|
55
|
+
use_device(all.first, &block)
|
54
56
|
end
|
55
57
|
|
56
58
|
# returns the last device for this class
|
57
|
-
def last(
|
58
|
-
|
59
|
-
raise 'Device not found' if dev.nil?
|
60
|
-
new(dev)
|
59
|
+
def last(&block)
|
60
|
+
use_device(all.last, &block)
|
61
61
|
end
|
62
62
|
|
63
63
|
# returns all devices in an array
|
@@ -66,23 +66,29 @@ module UniMIDI
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# returns the device at <em>index</em>
|
69
|
+
def use(index, &block)
|
70
|
+
use_device(all[index], &block)
|
71
|
+
end
|
72
|
+
|
69
73
|
def [](index)
|
70
|
-
all[index]
|
74
|
+
all[index]
|
71
75
|
end
|
72
76
|
|
73
77
|
# returns all devices as a hash as such
|
74
78
|
# { :input => [input devices], :output => [output devices] }
|
75
79
|
def all_by_type
|
76
|
-
|
77
|
-
|
78
|
-
:output => @deference[self].all_by_type[:output].map { |d| @output_class.new(d) }
|
79
|
-
}
|
80
|
+
ensure_initialized
|
81
|
+
@devices
|
80
82
|
end
|
81
83
|
|
82
84
|
def defer_to(klass)
|
83
85
|
@deference ||= {}
|
84
86
|
@deference[self] = klass
|
85
87
|
end
|
88
|
+
|
89
|
+
def device_class(klass)
|
90
|
+
@device_class = klass
|
91
|
+
end
|
86
92
|
|
87
93
|
def input_class(klass)
|
88
94
|
@input_class = klass
|
@@ -91,6 +97,26 @@ module UniMIDI
|
|
91
97
|
def output_class(klass)
|
92
98
|
@output_class = klass
|
93
99
|
end
|
100
|
+
|
101
|
+
def populate
|
102
|
+
klass = @deference[self].respond_to?(:all_by_type) ? @deference[self] : @device_class
|
103
|
+
@devices = {
|
104
|
+
:input => klass.all_by_type[:input].map { |d| @input_class.new(d) },
|
105
|
+
:output => klass.all_by_type[:output].map { |d| @output_class.new(d) }
|
106
|
+
}
|
107
|
+
end
|
108
|
+
alias_method :refresh, :populate
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def ensure_initialized
|
113
|
+
populate if @devices.nil?
|
114
|
+
end
|
115
|
+
|
116
|
+
def use_device(device, &block)
|
117
|
+
device.open(&block) unless block.nil?
|
118
|
+
device
|
119
|
+
end
|
94
120
|
|
95
121
|
end
|
96
122
|
|
@@ -177,7 +203,7 @@ module UniMIDI
|
|
177
203
|
|
178
204
|
# returns all inputs
|
179
205
|
def self.all
|
180
|
-
|
206
|
+
UniMIDI::Device.all_by_type[:input]
|
181
207
|
end
|
182
208
|
|
183
209
|
end
|
@@ -225,7 +251,7 @@ module UniMIDI
|
|
225
251
|
|
226
252
|
# returns all outputs
|
227
253
|
def self.all
|
228
|
-
|
254
|
+
UniMIDI::Device.all_by_type[:output]
|
229
255
|
end
|
230
256
|
|
231
257
|
end
|
data/test/helper.rb
CHANGED
@@ -29,16 +29,19 @@ module TestHelper
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def platform_test(adapter, mod)
|
32
|
+
def platform_test(adapter, mod, device_class = nil, input_class = nil, output_class = nil)
|
33
|
+
device_class ||= mod::Device
|
34
|
+
input_class ||= mod::Input
|
35
|
+
output_class ||= mod::Output
|
33
36
|
assert_equal(adapter, UniMIDI::Platform.instance.interface)
|
34
|
-
assert_not_same(
|
35
|
-
assert_not_same(
|
36
|
-
assert_not_same(
|
37
|
-
assert_equal(
|
38
|
-
assert_equal(
|
39
|
-
assert_not_same(
|
40
|
-
assert_equal(
|
41
|
-
assert_equal(
|
37
|
+
assert_not_same(input_class, UniMIDI::Input)
|
38
|
+
assert_not_same(output_class, UniMIDI::Output)
|
39
|
+
assert_not_same(device_class, UniMIDI::Device)
|
40
|
+
assert_equal(input_class.first.name, UniMIDI::Input.first.name)
|
41
|
+
assert_equal(input_class.first.id, UniMIDI::Input.first.id)
|
42
|
+
assert_not_same(output_class.first, UniMIDI::Output.first)
|
43
|
+
assert_equal(output_class.first.name, UniMIDI::Output.first.name)
|
44
|
+
assert_equal(output_class.first.id, UniMIDI::Output.first.id)
|
42
45
|
end
|
43
46
|
|
44
47
|
def bytestrs_to_ints(arr)
|
data/test/test_input_buffer.rb
CHANGED
data/test/test_io.rb
CHANGED
@@ -16,7 +16,9 @@ class IoTest < Test::Unit::TestCase
|
|
16
16
|
pointer = 0
|
17
17
|
$test_device[:output].open do |output|
|
18
18
|
$test_device[:input].open do |input|
|
19
|
-
|
19
|
+
|
20
|
+
input.buffer.clear
|
21
|
+
|
20
22
|
messages.each do |msg|
|
21
23
|
|
22
24
|
$>.puts "sending: " + msg.inspect
|
@@ -87,7 +89,9 @@ class IoTest < Test::Unit::TestCase
|
|
87
89
|
pointer = 0
|
88
90
|
$test_device[:output].open do |output|
|
89
91
|
$test_device[:input].open do |input|
|
90
|
-
|
92
|
+
|
93
|
+
#input.buffer.clear
|
94
|
+
|
91
95
|
messages.each do |msg|
|
92
96
|
|
93
97
|
$>.puts "sending: " + msg.inspect
|
data/test/test_platform.rb
CHANGED
@@ -21,7 +21,7 @@ class PlatformTest < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_osx
|
23
23
|
if RUBY_PLATFORM.include?("darwin")
|
24
|
-
platform_test(CoreMIDIAdapter, CoreMIDI)
|
24
|
+
platform_test(CoreMIDIAdapter, CoreMIDI, CoreMIDI::Endpoint, CoreMIDI::Source, CoreMIDI::Destination)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
class SelectorTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include UniMIDI
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def test_first
|
11
|
+
i = Input.first
|
12
|
+
assert_equal(Input.all.first, i)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_last
|
16
|
+
i = Input.last
|
17
|
+
assert_equal(Input.all.last, i)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_first_with_block
|
21
|
+
sleep(1)
|
22
|
+
i = Input.first do |i|
|
23
|
+
assert_equal(true, i.enabled?)
|
24
|
+
end
|
25
|
+
assert_equal(Input.all.first, i)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_last_with_block
|
29
|
+
sleep(1)
|
30
|
+
i = Input.last do |i|
|
31
|
+
assert_equal(true, i.enabled?)
|
32
|
+
end
|
33
|
+
assert_equal(Input.all.last, i)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_brackets
|
37
|
+
i = Input[0]
|
38
|
+
assert_equal(Input.first, i)
|
39
|
+
assert_equal(Input.all.first, i)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_use_with_block
|
43
|
+
sleep(1)
|
44
|
+
i = Input.use(0) do |i|
|
45
|
+
assert_equal(true, i.enabled?)
|
46
|
+
end
|
47
|
+
assert_equal(Input.first, i)
|
48
|
+
assert_equal(Input.all.first, i)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_all
|
52
|
+
i = Input.all
|
53
|
+
assert_equal(Device.all_by_type[:input], Input.all)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unimidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: i386-mingw32
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: midi-winmm
|
16
|
-
requirement: &
|
16
|
+
requirement: &70148241611300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70148241611300
|
25
25
|
description: Platform Independent, realtime MIDI input and output for Ruby
|
26
26
|
email:
|
27
27
|
- ari.russo@gmail.com
|
@@ -31,18 +31,19 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- bin/unimidi
|
34
|
-
- lib/unimidi.rb
|
35
|
-
- lib/unimidi/adapter/ffi-coremidi.rb
|
36
|
-
- lib/unimidi/adapter/midi-winmm.rb
|
37
34
|
- lib/unimidi/adapter/alsa-rawmidi.rb
|
35
|
+
- lib/unimidi/adapter/ffi-coremidi.rb
|
38
36
|
- lib/unimidi/adapter/midi-jruby.rb
|
37
|
+
- lib/unimidi/adapter/midi-winmm.rb
|
39
38
|
- lib/unimidi/congruous_api_adapter.rb
|
40
39
|
- lib/unimidi/platform.rb
|
41
40
|
- lib/unimidi/type_conversion.rb
|
41
|
+
- lib/unimidi.rb
|
42
42
|
- test/helper.rb
|
43
|
-
- test/test_io.rb
|
44
43
|
- test/test_input_buffer.rb
|
44
|
+
- test/test_io.rb
|
45
45
|
- test/test_platform.rb
|
46
|
+
- test/test_selectors.rb
|
46
47
|
- LICENSE
|
47
48
|
- README.rdoc
|
48
49
|
homepage: http://github.com/arirusso/unimidi
|
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
66
|
version: 1.3.6
|
66
67
|
requirements: []
|
67
68
|
rubyforge_project: unimidi
|
68
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.6
|
69
70
|
signing_key:
|
70
71
|
specification_version: 3
|
71
72
|
summary: Realtime MIDI input and output for Ruby
|