unimidi 0.1.5-i686-linux → 0.1.6-i686-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -0
- data/lib/unimidi.rb +4 -1
- data/lib/unimidi/adapter/alsa-rawmidi.rb +8 -13
- data/lib/unimidi/adapter/ffi-coremidi.rb +8 -13
- data/lib/unimidi/adapter/midi-jruby.rb +8 -13
- data/lib/unimidi/adapter/midi-winmm.rb +8 -13
- data/lib/unimidi/congruous_api_adapter.rb +140 -118
- data/lib/unimidi/platform.rb +22 -22
- data/lib/unimidi/type_conversion.rb +15 -0
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -37,6 +37,10 @@ A couple of notes about JRuby only:
|
|
37
37
|
|
38
38
|
* please see {test/config.rb}[http://github.com/arirusso/unimidi/blob/master/test/config.rb] before running tests
|
39
39
|
|
40
|
+
For testing with JRuby, use
|
41
|
+
|
42
|
+
jruby --1.9 -S rake test
|
43
|
+
|
40
44
|
== Documentation
|
41
45
|
|
42
46
|
* {rdoc}[http://rdoc.info/gems/unimidi]
|
data/lib/unimidi.rb
CHANGED
@@ -6,12 +6,15 @@
|
|
6
6
|
|
7
7
|
module UniMIDI
|
8
8
|
|
9
|
-
VERSION = "0.1.
|
9
|
+
VERSION = "0.1.6"
|
10
10
|
|
11
11
|
end
|
12
12
|
|
13
|
+
require 'forwardable'
|
14
|
+
|
13
15
|
require 'unimidi/congruous_api_adapter'
|
14
16
|
require 'unimidi/platform'
|
17
|
+
require 'unimidi/type_conversion'
|
15
18
|
|
16
19
|
module UniMIDI
|
17
20
|
extend(Platform.instance.interface)
|
@@ -7,23 +7,18 @@ module UniMIDI
|
|
7
7
|
|
8
8
|
module AlsaRawMIDIAdapter
|
9
9
|
|
10
|
-
class Input
|
11
|
-
|
12
|
-
include CongruousApiAdapter::Input
|
13
|
-
DeferToClass = AlsaRawMIDI::Input
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to AlsaRawMIDI::Input
|
14
12
|
end
|
15
13
|
|
16
|
-
class Output
|
17
|
-
|
18
|
-
include CongruousApiAdapter::Output
|
19
|
-
DeferToClass = AlsaRawMIDI::Output
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to AlsaRawMIDI::Output
|
20
16
|
end
|
21
17
|
|
22
|
-
class Device
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
OutputClass = Output
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to AlsaRawMIDI::Device
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
27
22
|
end
|
28
23
|
|
29
24
|
end
|
@@ -7,23 +7,18 @@ module UniMIDI
|
|
7
7
|
|
8
8
|
module CoreMIDIAdapter
|
9
9
|
|
10
|
-
class Input
|
11
|
-
|
12
|
-
include CongruousApiAdapter::Input
|
13
|
-
DeferToClass = CoreMIDI::Input
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to CoreMIDI::Input
|
14
12
|
end
|
15
13
|
|
16
|
-
class Output
|
17
|
-
|
18
|
-
include CongruousApiAdapter::Output
|
19
|
-
DeferToClass = CoreMIDI::Output
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to CoreMIDI::Output
|
20
16
|
end
|
21
17
|
|
22
|
-
class Device
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
OutputClass = Output
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to CoreMIDI::Entity
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
27
22
|
end
|
28
23
|
|
29
24
|
end
|
@@ -7,23 +7,18 @@ module UniMIDI
|
|
7
7
|
|
8
8
|
module MIDIJRubyAdapter
|
9
9
|
|
10
|
-
class Input
|
11
|
-
|
12
|
-
include CongruousApiAdapter::Input
|
13
|
-
DeferToClass = MIDIJRuby::Input
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to MIDIJRuby::Input
|
14
12
|
end
|
15
13
|
|
16
|
-
class Output
|
17
|
-
|
18
|
-
include CongruousApiAdapter::Output
|
19
|
-
DeferToClass = MIDIJRuby::Output
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to MIDIJRuby::Output
|
20
16
|
end
|
21
17
|
|
22
|
-
class Device
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
OutputClass = Output
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to MIDIJRuby::Device
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
27
22
|
end
|
28
23
|
|
29
24
|
end
|
@@ -7,23 +7,18 @@ module UniMIDI
|
|
7
7
|
|
8
8
|
module MIDIWinMMAdapter
|
9
9
|
|
10
|
-
class Input
|
11
|
-
|
12
|
-
include CongruousApiAdapter::Input
|
13
|
-
DeferToClass = MIDIWinMM::Input
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to MIDIWinMM::Input
|
14
12
|
end
|
15
13
|
|
16
|
-
class Output
|
17
|
-
|
18
|
-
include CongruousApiAdapter::Output
|
19
|
-
DeferToClass = MIDIWinMM::Output
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to MIDIWinMM::Output
|
20
16
|
end
|
21
17
|
|
22
|
-
class Device
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
OutputClass = Output
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to MIDIWinMM::Device
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
27
22
|
end
|
28
23
|
|
29
24
|
end
|
@@ -12,7 +12,7 @@ module UniMIDI
|
|
12
12
|
@id = @device.id
|
13
13
|
@name = @device.name
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# enable the device for use, can be passed a block to which the device will be passed back
|
17
17
|
def open(*a, &block)
|
18
18
|
@device.open(*a)
|
@@ -23,165 +23,187 @@ module UniMIDI
|
|
23
23
|
close
|
24
24
|
end
|
25
25
|
else
|
26
|
-
|
26
|
+
self
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
# close the device
|
31
31
|
def close(*a)
|
32
32
|
@device.close(*a)
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.included(base)
|
36
|
-
#base.send(:attr_reader, :device)
|
37
36
|
base.send(:attr_reader, :name)
|
38
37
|
base.send(:attr_reader, :id)
|
39
38
|
end
|
40
39
|
|
41
40
|
module ClassMethods
|
42
41
|
|
43
|
-
|
44
|
-
|
42
|
+
# returns the first device for this class
|
43
|
+
def first(*a)
|
44
|
+
new(@deference[self].first(*a))
|
45
45
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
|
47
|
+
# returns the last device for this class
|
48
|
+
def last(*a)
|
49
|
+
new(@deference[self].last(*a))
|
49
50
|
end
|
50
|
-
|
51
|
+
|
52
|
+
# returns all devices in an array
|
51
53
|
def all
|
52
54
|
all_by_type.values.flatten
|
53
55
|
end
|
54
|
-
|
56
|
+
|
57
|
+
# returns all devices as a hash as such
|
58
|
+
# { :input => [input devices], :output => [output devices] }
|
55
59
|
def all_by_type
|
56
|
-
{
|
57
|
-
:input =>
|
58
|
-
:output =>
|
60
|
+
{
|
61
|
+
:input => @deference[self].all_by_type[:input].map { |d| @input_class.new(d) },
|
62
|
+
:output => @deference[self].all_by_type[:output].map { |d| @output_class.new(d) }
|
59
63
|
}
|
60
64
|
end
|
61
65
|
|
62
|
-
def
|
63
|
-
|
66
|
+
def defer_to(klass)
|
67
|
+
@deference ||= {}
|
68
|
+
@deference[self] = klass
|
64
69
|
end
|
65
70
|
|
66
|
-
def
|
67
|
-
|
71
|
+
def input_class(klass)
|
72
|
+
@input_class = klass
|
68
73
|
end
|
69
74
|
|
70
|
-
def
|
71
|
-
|
75
|
+
def output_class(klass)
|
76
|
+
@output_class = klass
|
72
77
|
end
|
73
78
|
|
74
79
|
end
|
75
80
|
|
76
81
|
end
|
77
82
|
|
78
|
-
|
79
|
-
|
80
|
-
def self.included(base)
|
81
|
-
base.extend(Device::ClassMethods)
|
82
|
-
base.extend(ClassMethods)
|
83
|
-
end
|
83
|
+
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
#
|
108
|
-
def gets_bytestr(*a)
|
109
|
-
@device.gets_bytestr(*a)
|
110
|
-
end
|
111
|
-
alias_method :gets_s, :gets_bytestr
|
112
|
-
alias_method :gets_hex, :gets_bytestr
|
113
|
-
|
114
|
-
#
|
115
|
-
# returns an array of data bytes such as
|
116
|
-
# [144, 60, 100, 128, 60, 100, 144, 40, 120]
|
117
|
-
#
|
118
|
-
def gets_data(*a)
|
119
|
-
arr = gets
|
120
|
-
arr.map { |msg| msg[:data] }.inject { |a,b| a + b }
|
121
|
-
end
|
85
|
+
class CongruousApiInput
|
86
|
+
|
87
|
+
include CongruousApiAdapter::Device
|
88
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
89
|
+
extend Forwardable
|
90
|
+
|
91
|
+
def_delegators :@device, :buffer
|
92
|
+
|
93
|
+
#
|
94
|
+
# returns an array of MIDI event hashes as such:
|
95
|
+
# [
|
96
|
+
# { :data => [144, 60, 100], :timestamp => 1024 },
|
97
|
+
# { :data => [128, 60, 100], :timestamp => 1100 },
|
98
|
+
# { :data => [144, 40, 120], :timestamp => 1200 }
|
99
|
+
# ]
|
100
|
+
#
|
101
|
+
# the data is an array of Numeric bytes
|
102
|
+
# the timestamp is the number of millis since this input was enabled
|
103
|
+
#
|
104
|
+
def gets(*a)
|
105
|
+
@device.gets(*a)
|
106
|
+
end
|
122
107
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
108
|
+
#
|
109
|
+
# same as gets but returns message data as string of hex digits as such:
|
110
|
+
# [
|
111
|
+
# { :data => "904060", :timestamp => 904 },
|
112
|
+
# { :data => "804060", :timestamp => 1150 },
|
113
|
+
# { :data => "90447F", :timestamp => 1300 }
|
114
|
+
# ]
|
115
|
+
#
|
116
|
+
def gets_s(*a)
|
117
|
+
@device.gets_s(*a)
|
118
|
+
end
|
119
|
+
alias_method :gets_bytestr, :gets_s
|
120
|
+
alias_method :gets_hex, :gets_s
|
121
|
+
|
122
|
+
#
|
123
|
+
# returns an array of data bytes such as
|
124
|
+
# [144, 60, 100, 128, 60, 100, 144, 40, 120]
|
125
|
+
#
|
126
|
+
def gets_data(*a)
|
127
|
+
arr = gets
|
128
|
+
arr.map { |msg| msg[:data] }.inject { |a,b| a + b }
|
129
|
+
end
|
130
|
+
|
131
|
+
#
|
132
|
+
# returns a string of data such as
|
133
|
+
# "90406080406090447F"
|
134
|
+
#
|
135
|
+
def gets_data_s(*a)
|
136
|
+
arr = gets_bytestr
|
137
|
+
arr.map { |msg| msg[:data] }.join
|
138
|
+
end
|
139
|
+
alias_method :gets_data_bytestr, :gets_data_s
|
140
|
+
alias_method :gets_data_hex, :gets_data_s
|
141
|
+
|
142
|
+
# clears the buffer
|
143
|
+
def clear_buffer
|
144
|
+
@device.buffer.clear
|
145
|
+
end
|
146
|
+
|
147
|
+
# gets any messages in the buffer in the same format as CongruousApiInput#gets
|
148
|
+
def gets_buffer(*a)
|
149
|
+
@device.buffer
|
150
|
+
end
|
151
|
+
|
152
|
+
# gets any messages in the buffer in the same format as CongruousApiInput#gets_s
|
153
|
+
def gets_buffer_s(*a)
|
154
|
+
@device.buffer.map { |msg| msg[:data] = TypeConversion.numeric_byte_array_to_hex_string(msg[:data]); msg }
|
155
|
+
end
|
156
|
+
|
157
|
+
# gets any messages in the buffer in the same format as CongruousApiInput#gets_data
|
158
|
+
def gets_buffer_data(*a)
|
159
|
+
@device.buffer.map { |msg| msg[:data] }
|
160
|
+
end
|
142
161
|
|
162
|
+
# returns all inputs
|
163
|
+
def self.all
|
164
|
+
@deference[self].all.map { |d| new(d) }
|
143
165
|
end
|
144
166
|
|
145
|
-
|
146
|
-
|
147
|
-
def self.included(base)
|
148
|
-
base.extend(Device::ClassMethods)
|
149
|
-
base.extend(ClassMethods)
|
150
|
-
end
|
151
|
-
|
152
|
-
# sends a message to the output. the message can be:
|
153
|
-
#
|
154
|
-
# bytes eg output.puts(0x90, 0x40, 0x40)
|
155
|
-
# an array of bytes eg output.puts([0x90, 0x40, 0x40])
|
156
|
-
# or a string eg output.puts("904040")
|
157
|
-
#
|
158
|
-
def puts(*a)
|
159
|
-
@device.puts(*a)
|
160
|
-
end
|
161
|
-
|
162
|
-
# sends a message to the output in a form of a string eg "904040". this method does not do
|
163
|
-
# type checking and therefore is more performant than puts
|
164
|
-
def puts_bytestr(*a)
|
165
|
-
@device.puts_bytestr(*a)
|
166
|
-
end
|
167
|
+
end
|
167
168
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
169
|
+
class CongruousApiOutput
|
170
|
+
|
171
|
+
include CongruousApiAdapter::Device
|
172
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
173
|
+
|
174
|
+
# sends a message to the output. the message can be:
|
175
|
+
#
|
176
|
+
# bytes eg output.puts(0x90, 0x40, 0x40)
|
177
|
+
# an array of bytes eg output.puts([0x90, 0x40, 0x40])
|
178
|
+
# or a string eg output.puts("904040")
|
179
|
+
#
|
180
|
+
def puts(*a)
|
181
|
+
@device.puts(*a)
|
182
|
+
end
|
183
|
+
|
184
|
+
# sends a message to the output in a form of a string eg "904040". this method does not do
|
185
|
+
# type checking and therefore is more performant than puts
|
186
|
+
def puts_s(*a)
|
187
|
+
@device.puts_s(*a)
|
188
|
+
end
|
189
|
+
alias_method :puts_bytestr, :puts_s
|
190
|
+
alias_method :puts_hex, :puts_s
|
182
191
|
|
192
|
+
# sends a message to the output in a form of bytes eg output.puts_bytes(0x90, 0x40, 0x40).
|
193
|
+
# this method does not do type checking and therefore is more performant than puts
|
194
|
+
def puts_bytes(*a)
|
195
|
+
@device.puts_bytes(*a)
|
183
196
|
end
|
184
197
|
|
198
|
+
# returns all outputs
|
199
|
+
def self.all
|
200
|
+
@deference[self].all.map { |d| new(d) }
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
class CongruousApiDevice
|
206
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
185
207
|
end
|
186
208
|
|
187
209
|
end
|
data/lib/unimidi/platform.rb
CHANGED
@@ -4,30 +4,30 @@
|
|
4
4
|
require 'singleton'
|
5
5
|
|
6
6
|
module UniMIDI
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
|
8
|
+
class Platform
|
9
|
+
|
10
|
+
include Singleton
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
12
|
+
attr_reader :interface
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
lib = case RUBY_PLATFORM
|
16
|
+
when /darwin/ then "ffi-coremidi"
|
17
|
+
when /java/ then "midi-jruby"
|
18
|
+
when /linux/ then "alsa-rawmidi"
|
19
|
+
when /mingw/ then "midi-winmm"
|
20
|
+
#when /win/ then "midi-winmm"
|
21
|
+
end
|
22
|
+
require("unimidi/adapter/#{lib}")
|
23
|
+
@interface = case RUBY_PLATFORM
|
24
|
+
when /darwin/ then CoreMIDIAdapter
|
25
|
+
when /java/ then MIDIJRubyAdapter
|
26
|
+
when /linux/ then AlsaRawMIDIAdapter
|
27
|
+
when /mingw/ then MIDIWinMMAdapter
|
28
|
+
#when /win/ then MIDIWinMMAdapter
|
30
29
|
end
|
30
|
+
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: unimidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.6
|
6
6
|
platform: i686-linux
|
7
7
|
authors:
|
8
8
|
- Ari Russo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-10 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/unimidi/adapter/midi-jruby.rb
|
42
42
|
- lib/unimidi/congruous_api_adapter.rb
|
43
43
|
- lib/unimidi/platform.rb
|
44
|
+
- lib/unimidi/type_conversion.rb
|
44
45
|
- LICENSE
|
45
46
|
- README.rdoc
|
46
47
|
has_rdoc: true
|