unimidi 0.1.6-i386-mingw32 → 0.1.10-i386-mingw32
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/LICENSE +12 -12
- data/README.rdoc +59 -55
- data/bin/unimidi +10 -0
- data/lib/unimidi.rb +31 -22
- data/lib/unimidi/adapter/alsa-rawmidi.rb +25 -25
- data/lib/unimidi/adapter/ffi-coremidi.rb +25 -25
- data/lib/unimidi/adapter/midi-jruby.rb +25 -25
- data/lib/unimidi/adapter/midi-winmm.rb +25 -25
- data/lib/unimidi/congruous_api_adapter.rb +214 -212
- data/lib/unimidi/platform.rb +35 -35
- data/lib/unimidi/type_conversion.rb +14 -14
- metadata +10 -8
data/LICENSE
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
Copyright 2010-2011 Ari Russo
|
2
|
-
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
you may not use this file except in compliance with the License.
|
5
|
-
You may obtain a copy of the License at
|
6
|
-
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
See the License for the specific language governing permissions and
|
1
|
+
Copyright 2010-2011 Ari Russo
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
13
|
limitations under the License.
|
data/README.rdoc
CHANGED
@@ -1,55 +1,59 @@
|
|
1
|
-
= UniMIDI
|
2
|
-
|
3
|
-
== Summary
|
4
|
-
|
5
|
-
Platform independent realtime MIDI input and output for Ruby.
|
6
|
-
|
7
|
-
== Features
|
8
|
-
|
9
|
-
* Supports Linux, JRuby, OSX, Windows and Cygwin
|
10
|
-
* Both input and output to and from multiple devices concurrently
|
11
|
-
* Agnostically handle different MIDI and SysEx Message types
|
12
|
-
|
13
|
-
== Requirements
|
14
|
-
|
15
|
-
Platform
|
16
|
-
|
17
|
-
* JRuby: {midi-jruby}[http://github.com/arirusso/midi-jruby]
|
18
|
-
* Linux: {alsa-rawmidi}[http://github.com/arirusso/alsa-rawmidi]
|
19
|
-
* OSX: {ffi-coremidi}[http://github.com/arirusso/ffi-coremidi]
|
20
|
-
* Windows/Cygwin: {midi-winmm}[http://github.com/arirusso/midi-winmm]
|
21
|
-
|
22
|
-
== Install
|
23
|
-
|
24
|
-
gem install unimidi
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
==
|
36
|
-
|
37
|
-
* {
|
38
|
-
|
39
|
-
==
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
==
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
1
|
+
= UniMIDI
|
2
|
+
|
3
|
+
== Summary
|
4
|
+
|
5
|
+
Platform independent realtime MIDI input and output for Ruby.
|
6
|
+
|
7
|
+
== Features
|
8
|
+
|
9
|
+
* Supports Linux, JRuby, OSX, Windows and Cygwin
|
10
|
+
* Both input and output to and from multiple devices concurrently
|
11
|
+
* Agnostically handle different MIDI and SysEx Message types
|
12
|
+
|
13
|
+
== Requirements
|
14
|
+
|
15
|
+
Platform
|
16
|
+
|
17
|
+
* JRuby: {midi-jruby}[http://github.com/arirusso/midi-jruby]
|
18
|
+
* Linux: {alsa-rawmidi}[http://github.com/arirusso/alsa-rawmidi]
|
19
|
+
* OSX: {ffi-coremidi}[http://github.com/arirusso/ffi-coremidi]
|
20
|
+
* Windows/Cygwin: {midi-winmm}[http://github.com/arirusso/midi-winmm]
|
21
|
+
|
22
|
+
== Install
|
23
|
+
|
24
|
+
gem install unimidi
|
25
|
+
|
26
|
+
No compilation required
|
27
|
+
|
28
|
+
== Examples
|
29
|
+
|
30
|
+
* {input}[http://github.com/arirusso/unimidi/blob/master/examples/input.rb]
|
31
|
+
* {output}[http://github.com/arirusso/unimidi/blob/master/examples/output.rb]
|
32
|
+
|
33
|
+
{more}[http://github.com/arirusso/unimidi/blob/master/examples]
|
34
|
+
|
35
|
+
== Tests
|
36
|
+
|
37
|
+
* please see {test/config.rb}[http://github.com/arirusso/unimidi/blob/master/test/config.rb] before running tests
|
38
|
+
|
39
|
+
== Documentation
|
40
|
+
|
41
|
+
* {rdoc}[http://rdoc.info/gems/unimidi]
|
42
|
+
|
43
|
+
== If you are using JRuby
|
44
|
+
|
45
|
+
A couple of notes
|
46
|
+
|
47
|
+
* You must be in 1.9 mode. This is normally accomplished by passing --1.9 to JRuby at the command line. For testing in 1.9 mode, use
|
48
|
+
jruby --1.9 -S rake test
|
49
|
+
* javax.sound has some documented issues with SysEx messages in some versions OSX Snow Leopard which do affect this library.
|
50
|
+
|
51
|
+
== Author
|
52
|
+
|
53
|
+
{Ari Russo}[http://github.com/arirusso] <ari.russo at gmail.com>
|
54
|
+
|
55
|
+
== License
|
56
|
+
|
57
|
+
Apache 2.0, See the file LICENSE
|
58
|
+
|
59
|
+
Copyright (c) 2010-2011 Ari Russo
|
data/bin/unimidi
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
|
4
|
+
require 'unimidi'
|
5
|
+
|
6
|
+
opts = ARGV.length > 1 ? ARGV.slice(1, ARGV.length-1) : {}
|
7
|
+
|
8
|
+
raise "No command specified" if ARGV.first.nil?
|
9
|
+
|
10
|
+
UniMIDI.command(ARGV.first.to_sym, opts)
|
data/lib/unimidi.rb
CHANGED
@@ -1,22 +1,31 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# A realtime MIDI interface for Ruby
|
4
|
-
# (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
|
5
|
-
#
|
6
|
-
|
7
|
-
module UniMIDI
|
8
|
-
|
9
|
-
VERSION = "0.1.
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'forwardable'
|
14
|
-
|
15
|
-
require 'unimidi/congruous_api_adapter'
|
16
|
-
require 'unimidi/platform'
|
17
|
-
require 'unimidi/type_conversion'
|
18
|
-
|
19
|
-
module UniMIDI
|
20
|
-
extend(Platform.instance.interface)
|
21
|
-
include(Platform.instance.interface)
|
22
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# A realtime MIDI interface for Ruby
|
4
|
+
# (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
|
5
|
+
#
|
6
|
+
|
7
|
+
module UniMIDI
|
8
|
+
|
9
|
+
VERSION = "0.1.10"
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'forwardable'
|
14
|
+
|
15
|
+
require 'unimidi/congruous_api_adapter'
|
16
|
+
require 'unimidi/platform'
|
17
|
+
require 'unimidi/type_conversion'
|
18
|
+
|
19
|
+
module UniMIDI
|
20
|
+
extend(Platform.instance.interface)
|
21
|
+
include(Platform.instance.interface)
|
22
|
+
|
23
|
+
def self.command(command, options = {})
|
24
|
+
if [:l, :list, :list_devices].include?(command)
|
25
|
+
require 'pp'
|
26
|
+
pp Device::all
|
27
|
+
else
|
28
|
+
raise "Command #{command.to_s} not found"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'alsa-rawmidi'
|
5
|
-
|
6
|
-
module UniMIDI
|
7
|
-
|
8
|
-
module AlsaRawMIDIAdapter
|
9
|
-
|
10
|
-
class Input < CongruousApiInput
|
11
|
-
defer_to AlsaRawMIDI::Input
|
12
|
-
end
|
13
|
-
|
14
|
-
class Output < CongruousApiOutput
|
15
|
-
defer_to AlsaRawMIDI::Output
|
16
|
-
end
|
17
|
-
|
18
|
-
class Device < CongruousApiDevice
|
19
|
-
defer_to AlsaRawMIDI::Device
|
20
|
-
input_class Input
|
21
|
-
output_class Output
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'alsa-rawmidi'
|
5
|
+
|
6
|
+
module UniMIDI
|
7
|
+
|
8
|
+
module AlsaRawMIDIAdapter
|
9
|
+
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to AlsaRawMIDI::Input
|
12
|
+
end
|
13
|
+
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to AlsaRawMIDI::Output
|
16
|
+
end
|
17
|
+
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to AlsaRawMIDI::Device
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
26
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'coremidi'
|
5
|
-
|
6
|
-
module UniMIDI
|
7
|
-
|
8
|
-
module CoreMIDIAdapter
|
9
|
-
|
10
|
-
class Input < CongruousApiInput
|
11
|
-
defer_to CoreMIDI::Input
|
12
|
-
end
|
13
|
-
|
14
|
-
class Output < CongruousApiOutput
|
15
|
-
defer_to CoreMIDI::Output
|
16
|
-
end
|
17
|
-
|
18
|
-
class Device < CongruousApiDevice
|
19
|
-
defer_to CoreMIDI::Entity
|
20
|
-
input_class Input
|
21
|
-
output_class Output
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'coremidi'
|
5
|
+
|
6
|
+
module UniMIDI
|
7
|
+
|
8
|
+
module CoreMIDIAdapter
|
9
|
+
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to CoreMIDI::Input
|
12
|
+
end
|
13
|
+
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to CoreMIDI::Output
|
16
|
+
end
|
17
|
+
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to CoreMIDI::Entity
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
26
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'midi-jruby'
|
5
|
-
|
6
|
-
module UniMIDI
|
7
|
-
|
8
|
-
module MIDIJRubyAdapter
|
9
|
-
|
10
|
-
class Input < CongruousApiInput
|
11
|
-
defer_to MIDIJRuby::Input
|
12
|
-
end
|
13
|
-
|
14
|
-
class Output < CongruousApiOutput
|
15
|
-
defer_to MIDIJRuby::Output
|
16
|
-
end
|
17
|
-
|
18
|
-
class Device < CongruousApiDevice
|
19
|
-
defer_to MIDIJRuby::Device
|
20
|
-
input_class Input
|
21
|
-
output_class Output
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'midi-jruby'
|
5
|
+
|
6
|
+
module UniMIDI
|
7
|
+
|
8
|
+
module MIDIJRubyAdapter
|
9
|
+
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to MIDIJRuby::Input
|
12
|
+
end
|
13
|
+
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to MIDIJRuby::Output
|
16
|
+
end
|
17
|
+
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to MIDIJRuby::Device
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
26
|
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'midi-winmm'
|
5
|
-
|
6
|
-
module UniMIDI
|
7
|
-
|
8
|
-
module MIDIWinMMAdapter
|
9
|
-
|
10
|
-
class Input < CongruousApiInput
|
11
|
-
defer_to MIDIWinMM::Input
|
12
|
-
end
|
13
|
-
|
14
|
-
class Output < CongruousApiOutput
|
15
|
-
defer_to MIDIWinMM::Output
|
16
|
-
end
|
17
|
-
|
18
|
-
class Device < CongruousApiDevice
|
19
|
-
defer_to MIDIWinMM::Device
|
20
|
-
input_class Input
|
21
|
-
output_class Output
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'midi-winmm'
|
5
|
+
|
6
|
+
module UniMIDI
|
7
|
+
|
8
|
+
module MIDIWinMMAdapter
|
9
|
+
|
10
|
+
class Input < CongruousApiInput
|
11
|
+
defer_to MIDIWinMM::Input
|
12
|
+
end
|
13
|
+
|
14
|
+
class Output < CongruousApiOutput
|
15
|
+
defer_to MIDIWinMM::Output
|
16
|
+
end
|
17
|
+
|
18
|
+
class Device < CongruousApiDevice
|
19
|
+
defer_to MIDIWinMM::Device
|
20
|
+
input_class Input
|
21
|
+
output_class Output
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
26
|
end
|
@@ -1,213 +1,215 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
module UniMIDI
|
5
|
-
|
6
|
-
module CongruousApiAdapter
|
7
|
-
|
8
|
-
module Device
|
9
|
-
|
10
|
-
def initialize(device_obj)
|
11
|
-
@device = device_obj
|
12
|
-
@id = @device.id
|
13
|
-
@name = @device.name
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
base.send(:attr_reader, :
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
# { :data => [144,
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
# { :data => "
|
118
|
-
#
|
119
|
-
#
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
#
|
129
|
-
#
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
#
|
138
|
-
#
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
module UniMIDI
|
5
|
+
|
6
|
+
module CongruousApiAdapter
|
7
|
+
|
8
|
+
module Device
|
9
|
+
|
10
|
+
def initialize(device_obj)
|
11
|
+
@device = device_obj
|
12
|
+
@id = @device.id
|
13
|
+
@name = @device.name
|
14
|
+
@type = @device.type
|
15
|
+
end
|
16
|
+
|
17
|
+
# enable the device for use, can be passed a block to which the device will be passed back
|
18
|
+
def open(*a, &block)
|
19
|
+
@device.open(*a)
|
20
|
+
unless block.nil?
|
21
|
+
begin
|
22
|
+
yield(self)
|
23
|
+
ensure
|
24
|
+
close
|
25
|
+
end
|
26
|
+
else
|
27
|
+
self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# close the device
|
32
|
+
def close(*a)
|
33
|
+
@device.close(*a)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.included(base)
|
37
|
+
base.send(:attr_reader, :name)
|
38
|
+
base.send(:attr_reader, :id)
|
39
|
+
base.send(:attr_reader, :type)
|
40
|
+
end
|
41
|
+
|
42
|
+
module ClassMethods
|
43
|
+
|
44
|
+
# returns the first device for this class
|
45
|
+
def first(*a)
|
46
|
+
dev = @deference[self].first(*a)
|
47
|
+
raise 'Device not found' if dev.nil?
|
48
|
+
new(dev)
|
49
|
+
end
|
50
|
+
|
51
|
+
# returns the last device for this class
|
52
|
+
def last(*a)
|
53
|
+
dev = @deference[self].last(*a)
|
54
|
+
raise 'Device not found' if dev.nil?
|
55
|
+
new(dev)
|
56
|
+
end
|
57
|
+
|
58
|
+
# returns all devices in an array
|
59
|
+
def all
|
60
|
+
all_by_type.values.flatten
|
61
|
+
end
|
62
|
+
|
63
|
+
# returns all devices as a hash as such
|
64
|
+
# { :input => [input devices], :output => [output devices] }
|
65
|
+
def all_by_type
|
66
|
+
{
|
67
|
+
:input => @deference[self].all_by_type[:input].map { |d| @input_class.new(d) },
|
68
|
+
:output => @deference[self].all_by_type[:output].map { |d| @output_class.new(d) }
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def defer_to(klass)
|
73
|
+
@deference ||= {}
|
74
|
+
@deference[self] = klass
|
75
|
+
end
|
76
|
+
|
77
|
+
def input_class(klass)
|
78
|
+
@input_class = klass
|
79
|
+
end
|
80
|
+
|
81
|
+
def output_class(klass)
|
82
|
+
@output_class = klass
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
class CongruousApiInput
|
92
|
+
|
93
|
+
include CongruousApiAdapter::Device
|
94
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
95
|
+
extend Forwardable
|
96
|
+
|
97
|
+
def_delegators :@device, :buffer
|
98
|
+
|
99
|
+
#
|
100
|
+
# returns an array of MIDI event hashes as such:
|
101
|
+
# [
|
102
|
+
# { :data => [144, 60, 100], :timestamp => 1024 },
|
103
|
+
# { :data => [128, 60, 100], :timestamp => 1100 },
|
104
|
+
# { :data => [144, 40, 120], :timestamp => 1200 }
|
105
|
+
# ]
|
106
|
+
#
|
107
|
+
# the data is an array of Numeric bytes
|
108
|
+
# the timestamp is the number of millis since this input was enabled
|
109
|
+
#
|
110
|
+
def gets(*a)
|
111
|
+
@device.gets(*a)
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
115
|
+
# same as gets but returns message data as string of hex digits as such:
|
116
|
+
# [
|
117
|
+
# { :data => "904060", :timestamp => 904 },
|
118
|
+
# { :data => "804060", :timestamp => 1150 },
|
119
|
+
# { :data => "90447F", :timestamp => 1300 }
|
120
|
+
# ]
|
121
|
+
#
|
122
|
+
def gets_s(*a)
|
123
|
+
@device.gets_s(*a)
|
124
|
+
end
|
125
|
+
alias_method :gets_bytestr, :gets_s
|
126
|
+
alias_method :gets_hex, :gets_s
|
127
|
+
|
128
|
+
#
|
129
|
+
# returns an array of data bytes such as
|
130
|
+
# [144, 60, 100, 128, 60, 100, 144, 40, 120]
|
131
|
+
#
|
132
|
+
def gets_data(*a)
|
133
|
+
arr = gets
|
134
|
+
arr.map { |msg| msg[:data] }.inject { |a,b| a + b }
|
135
|
+
end
|
136
|
+
|
137
|
+
#
|
138
|
+
# returns a string of data such as
|
139
|
+
# "90406080406090447F"
|
140
|
+
#
|
141
|
+
def gets_data_s(*a)
|
142
|
+
arr = gets_bytestr
|
143
|
+
arr.map { |msg| msg[:data] }.join
|
144
|
+
end
|
145
|
+
alias_method :gets_data_bytestr, :gets_data_s
|
146
|
+
alias_method :gets_data_hex, :gets_data_s
|
147
|
+
|
148
|
+
# clears the buffer
|
149
|
+
def clear_buffer
|
150
|
+
@device.buffer.clear
|
151
|
+
end
|
152
|
+
|
153
|
+
# gets any messages in the buffer in the same format as CongruousApiInput#gets
|
154
|
+
def gets_buffer(*a)
|
155
|
+
@device.buffer
|
156
|
+
end
|
157
|
+
|
158
|
+
# gets any messages in the buffer in the same format as CongruousApiInput#gets_s
|
159
|
+
def gets_buffer_s(*a)
|
160
|
+
@device.buffer.map { |msg| msg[:data] = TypeConversion.numeric_byte_array_to_hex_string(msg[:data]); msg }
|
161
|
+
end
|
162
|
+
|
163
|
+
# gets any messages in the buffer in the same format as CongruousApiInput#gets_data
|
164
|
+
def gets_buffer_data(*a)
|
165
|
+
@device.buffer.map { |msg| msg[:data] }
|
166
|
+
end
|
167
|
+
|
168
|
+
# returns all inputs
|
169
|
+
def self.all
|
170
|
+
@deference[self].all.map { |d| new(d) }
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
class CongruousApiOutput
|
176
|
+
|
177
|
+
include CongruousApiAdapter::Device
|
178
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
179
|
+
|
180
|
+
# sends a message to the output. the message can be:
|
181
|
+
#
|
182
|
+
# bytes eg output.puts(0x90, 0x40, 0x40)
|
183
|
+
# an array of bytes eg output.puts([0x90, 0x40, 0x40])
|
184
|
+
# or a string eg output.puts("904040")
|
185
|
+
#
|
186
|
+
def puts(*a)
|
187
|
+
@device.puts(*a)
|
188
|
+
end
|
189
|
+
|
190
|
+
# sends a message to the output in a form of a string eg "904040". this method does not do
|
191
|
+
# type checking and therefore is more performant than puts
|
192
|
+
def puts_s(*a)
|
193
|
+
@device.puts_s(*a)
|
194
|
+
end
|
195
|
+
alias_method :puts_bytestr, :puts_s
|
196
|
+
alias_method :puts_hex, :puts_s
|
197
|
+
|
198
|
+
# sends a message to the output in a form of bytes eg output.puts_bytes(0x90, 0x40, 0x40).
|
199
|
+
# this method does not do type checking and therefore is more performant than puts
|
200
|
+
def puts_bytes(*a)
|
201
|
+
@device.puts_bytes(*a)
|
202
|
+
end
|
203
|
+
|
204
|
+
# returns all outputs
|
205
|
+
def self.all
|
206
|
+
@deference[self].all.map { |d| new(d) }
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
class CongruousApiDevice
|
212
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
213
|
+
end
|
214
|
+
|
213
215
|
end
|
data/lib/unimidi/platform.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'singleton'
|
5
|
-
|
6
|
-
module UniMIDI
|
7
|
-
|
8
|
-
class Platform
|
9
|
-
|
10
|
-
include Singleton
|
11
|
-
|
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
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module UniMIDI
|
7
|
+
|
8
|
+
class Platform
|
9
|
+
|
10
|
+
include Singleton
|
11
|
+
|
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
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
@@ -1,15 +1,15 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
|
4
|
-
module UniMIDI
|
5
|
-
|
6
|
-
module TypeConversion
|
7
|
-
|
8
|
-
# byte array to string of hex bytes
|
9
|
-
def numeric_byte_array_to_hex_string(bytes)
|
10
|
-
bytes.map { |b| b.hex }.join
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
module UniMIDI
|
5
|
+
|
6
|
+
module TypeConversion
|
7
|
+
|
8
|
+
# byte array to string of hex bytes
|
9
|
+
def numeric_byte_array_to_hex_string(bytes)
|
10
|
+
bytes.map { |b| b.hex }.join
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
15
|
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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: i386-mingw32
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-05-23 00:00:00.000000000 -04:00
|
13
|
+
default_executable: unimidi
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: midi-winmm
|
17
|
-
requirement: &
|
17
|
+
requirement: &9407904 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,14 +22,16 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
description:
|
25
|
+
version_requirements: *9407904
|
26
|
+
description: Platform Independent, realtime MIDI input and output for Ruby.
|
27
27
|
email:
|
28
28
|
- ari.russo@gmail.com
|
29
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- unimidi
|
30
31
|
extensions: []
|
31
32
|
extra_rdoc_files: []
|
32
33
|
files:
|
34
|
+
- bin/unimidi
|
33
35
|
- lib/unimidi/adapter/alsa-rawmidi.rb
|
34
36
|
- lib/unimidi/adapter/ffi-coremidi.rb
|
35
37
|
- lib/unimidi/adapter/midi-jruby.rb
|
@@ -64,5 +66,5 @@ rubyforge_project: unimidi
|
|
64
66
|
rubygems_version: 1.5.2
|
65
67
|
signing_key:
|
66
68
|
specification_version: 3
|
67
|
-
summary:
|
69
|
+
summary: Realtime MIDI input and output for Ruby.
|
68
70
|
test_files: []
|