unimidi 0.0.7-i686-linux → 0.0.8-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 +7 -4
- data/lib/unimidi.rb +1 -1
- data/lib/unimidi/adapter/alsa-rawmidi.rb +8 -6
- data/lib/unimidi/adapter/midi-jruby.rb +8 -6
- data/lib/unimidi/adapter/midi-winmm.rb +7 -5
- data/lib/unimidi/congruous_api_adapter.rb +65 -10
- data/lib/unimidi/platform.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -6,7 +6,7 @@ Platform independent realtime MIDI input and output for Ruby.
|
|
6
6
|
|
7
7
|
== Features
|
8
8
|
|
9
|
-
*
|
9
|
+
* Currently Linux, JRuby, Windows and Cygwin are supported. More platforms will follow (see "to-do")
|
10
10
|
* Both input and output to and from multiple devices concurrently
|
11
11
|
* Agnostically handle different MIDI Message types (including SysEx)
|
12
12
|
|
@@ -18,7 +18,10 @@ Platform
|
|
18
18
|
* Linux: {alsa-rawmidi}[http://github.com/arirusso/alsa-rawmidi]
|
19
19
|
* Windows/Cygwin: {midi-winmm}[http://github.com/arirusso/midi-winmm]
|
20
20
|
|
21
|
-
|
21
|
+
A couple of notes about JRuby only:
|
22
|
+
|
23
|
+
* You must be in 1.9 mode. This is normally accomplished by passing --1.9 to JRuby at the command line.
|
24
|
+
* javax.sound has some documented issues with SysEx messages in some versions OSX Snow Leopard which do affect this library.
|
22
25
|
|
23
26
|
== Install
|
24
27
|
|
@@ -39,7 +42,7 @@ Note that if you are using JRuby you must be in 1.9 mode. This is normally acco
|
|
39
42
|
|
40
43
|
== To-do
|
41
44
|
|
42
|
-
* OSX
|
45
|
+
* OSX {coremidi}[http://github.com/arirusso/coremidi] implementation once that lib is done
|
43
46
|
|
44
47
|
== Author
|
45
48
|
|
@@ -49,4 +52,4 @@ Note that if you are using JRuby you must be in 1.9 mode. This is normally acco
|
|
49
52
|
|
50
53
|
Apache 2.0, See the file LICENSE
|
51
54
|
|
52
|
-
Copyright (c) 2010-2011 Ari Russo
|
55
|
+
Copyright (c) 2010-2011 Ari Russo
|
data/lib/unimidi.rb
CHANGED
@@ -4,11 +4,6 @@ module UniMIDI
|
|
4
4
|
|
5
5
|
module AlsaRawMIDIAdapter
|
6
6
|
|
7
|
-
class Device
|
8
|
-
extend CongruousApiAdapter::Device::ClassMethods
|
9
|
-
defer_to AlsaRawMIDI::Device
|
10
|
-
end
|
11
|
-
|
12
7
|
class Input
|
13
8
|
include CongruousApiAdapter::Device
|
14
9
|
include CongruousApiAdapter::Input
|
@@ -20,7 +15,14 @@ module UniMIDI
|
|
20
15
|
include CongruousApiAdapter::Output
|
21
16
|
defer_to AlsaRawMIDI::Output
|
22
17
|
end
|
23
|
-
|
18
|
+
|
19
|
+
class Device
|
20
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
21
|
+
defer_to AlsaRawMIDI::Device
|
22
|
+
input_class Input
|
23
|
+
output_class Output
|
24
|
+
end
|
25
|
+
|
24
26
|
end
|
25
27
|
|
26
28
|
end
|
@@ -2,12 +2,7 @@ require 'midi-jruby'
|
|
2
2
|
|
3
3
|
module UniMIDI
|
4
4
|
|
5
|
-
module
|
6
|
-
|
7
|
-
class Device
|
8
|
-
extend CongruousApiAdapter::Device::ClassMethods
|
9
|
-
defer_to MIDIJRuby::Device
|
10
|
-
end
|
5
|
+
module MIDIJRubyAdapter
|
11
6
|
|
12
7
|
class Input
|
13
8
|
include CongruousApiAdapter::Device
|
@@ -20,6 +15,13 @@ module UniMIDI
|
|
20
15
|
include CongruousApiAdapter::Output
|
21
16
|
defer_to MIDIJRuby::Output
|
22
17
|
end
|
18
|
+
|
19
|
+
class Device
|
20
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
21
|
+
defer_to MIDIJRuby::Device
|
22
|
+
input_class Input
|
23
|
+
output_class Output
|
24
|
+
end
|
23
25
|
|
24
26
|
end
|
25
27
|
|
@@ -4,11 +4,6 @@ module UniMIDI
|
|
4
4
|
|
5
5
|
module MIDIWinMMAdapter
|
6
6
|
|
7
|
-
class Device
|
8
|
-
extend CongruousApiAdapter::Device::ClassMethods
|
9
|
-
defer_to MIDIWinMM::Device
|
10
|
-
end
|
11
|
-
|
12
7
|
class Input
|
13
8
|
include CongruousApiAdapter::Device
|
14
9
|
include CongruousApiAdapter::Input
|
@@ -20,6 +15,13 @@ module UniMIDI
|
|
20
15
|
include CongruousApiAdapter::Output
|
21
16
|
defer_to MIDIWinMM::Output
|
22
17
|
end
|
18
|
+
|
19
|
+
class Device
|
20
|
+
extend CongruousApiAdapter::Device::ClassMethods
|
21
|
+
defer_to MIDIWinMM::Device
|
22
|
+
input_class Input
|
23
|
+
output_class Output
|
24
|
+
end
|
23
25
|
|
24
26
|
end
|
25
27
|
|
@@ -6,10 +6,12 @@ module UniMIDI
|
|
6
6
|
|
7
7
|
def initialize(device_obj)
|
8
8
|
@device = device_obj
|
9
|
+
@id = @device.id
|
10
|
+
@name = @device.name
|
9
11
|
end
|
10
12
|
|
11
13
|
def open(*a, &block)
|
12
|
-
begin
|
14
|
+
begin
|
13
15
|
@device.open(*a)
|
14
16
|
block.call(self)
|
15
17
|
ensure
|
@@ -22,7 +24,9 @@ module UniMIDI
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.included(base)
|
25
|
-
base.send(:attr_reader, :device)
|
27
|
+
#base.send(:attr_reader, :device)
|
28
|
+
base.send(:attr_reader, :name)
|
29
|
+
base.send(:attr_reader, :id)
|
26
30
|
end
|
27
31
|
|
28
32
|
module ClassMethods
|
@@ -36,20 +40,36 @@ module UniMIDI
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def all
|
39
|
-
|
43
|
+
all_by_type.values.flatten
|
40
44
|
end
|
41
45
|
|
42
46
|
def all_by_type
|
43
47
|
{
|
44
|
-
:input => device_class.all_by_type[:input].map { |d| new(d) },
|
45
|
-
:output => device_class.all_by_type[:output].map { |d| new(d) }
|
48
|
+
:input => device_class.all_by_type[:input].map { |d| get_input_class.new(d) },
|
49
|
+
:output => device_class.all_by_type[:output].map { |d| get_output_class.new(d) }
|
46
50
|
}
|
47
51
|
end
|
48
52
|
|
49
53
|
def defer_to(klass)
|
50
54
|
const_set("DeferToClass", klass)
|
51
55
|
end
|
56
|
+
|
57
|
+
def get_input_class
|
58
|
+
const_get("InputClass")
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_output_class
|
62
|
+
const_get("OutputClass")
|
63
|
+
end
|
52
64
|
|
65
|
+
def input_class(klass)
|
66
|
+
const_set("InputClass", klass)
|
67
|
+
end
|
68
|
+
|
69
|
+
def output_class(klass)
|
70
|
+
const_set("OutputClass", klass)
|
71
|
+
end
|
72
|
+
|
53
73
|
def device_class
|
54
74
|
const_get("DeferToClass")
|
55
75
|
end
|
@@ -65,18 +85,53 @@ module UniMIDI
|
|
65
85
|
base.extend(ClassMethods)
|
66
86
|
end
|
67
87
|
|
88
|
+
#
|
89
|
+
# returns an array of MIDI event hashes as such:
|
90
|
+
# [
|
91
|
+
# { :data => [144, 60, 100], :timestamp => 1024 },
|
92
|
+
# { :data => [128, 60, 100], :timestamp => 1100 },
|
93
|
+
# { :data => [144, 40, 120], :timestamp => 1200 }
|
94
|
+
# ]
|
95
|
+
#
|
96
|
+
# the data is an array of Numeric bytes
|
97
|
+
# the timestamp is the number of millis since this input was enabled
|
98
|
+
#
|
68
99
|
def gets(*a)
|
69
100
|
@device.gets(*a)
|
70
101
|
end
|
71
102
|
|
103
|
+
#
|
104
|
+
# same as gets but returns message data as string of hex digits as such:
|
105
|
+
# [
|
106
|
+
# { :data => "904060", :timestamp => 904 },
|
107
|
+
# { :data => "804060", :timestamp => 1150 },
|
108
|
+
# { :data => "90447F", :timestamp => 1300 }
|
109
|
+
# ]
|
110
|
+
#
|
72
111
|
def gets_bytestr(*a)
|
73
112
|
@device.gets_bytestr(*a)
|
74
113
|
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# returns an array of data bytes such as [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
|
122
|
+
|
123
|
+
#
|
124
|
+
# returns a string of data such as "90406080406090447F"
|
125
|
+
#
|
126
|
+
def gets_data_bytestr(*a)
|
127
|
+
arr = gets_bytestr
|
128
|
+
arr.map { |msg| msg[:data] }.join
|
129
|
+
end
|
75
130
|
|
76
131
|
module ClassMethods
|
77
|
-
|
78
|
-
def
|
79
|
-
device_class.
|
132
|
+
|
133
|
+
def all
|
134
|
+
device_class.all.map { |d| new(d) }
|
80
135
|
end
|
81
136
|
|
82
137
|
end
|
@@ -100,8 +155,8 @@ module UniMIDI
|
|
100
155
|
|
101
156
|
module ClassMethods
|
102
157
|
|
103
|
-
def
|
104
|
-
device_class.
|
158
|
+
def all
|
159
|
+
device_class.all.map { |d| new(d) }
|
105
160
|
end
|
106
161
|
|
107
162
|
end
|
data/lib/unimidi/platform.rb
CHANGED
@@ -17,7 +17,7 @@ module UniMIDI
|
|
17
17
|
end
|
18
18
|
require("unimidi/adapter/#{lib}")
|
19
19
|
@interface = case RUBY_PLATFORM
|
20
|
-
when /java/ then
|
20
|
+
when /java/ then MIDIJRubyAdapter
|
21
21
|
when /linux/ then AlsaRawMIDIAdapter
|
22
22
|
when /mingw/ then MIDIWinMMAdapter #cygwin
|
23
23
|
when /win/ then MIDIWinMMAdapter
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: unimidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
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-04-
|
13
|
+
date: 2011-04-30 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|