unimidi 0.0.7-i386-mingw32 → 0.1.3-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 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,52 +1,51 @@
1
- = UniMIDI
2
-
3
- == Summary
4
-
5
- Platform independent realtime MIDI input and output for Ruby.
6
-
7
- == Features
8
-
9
- * Platform independent. Currently Linux, JRuby, Windows and Cygwin are supported. More platforms will follow (see "to-do")
10
- * Both input and output to and from multiple devices concurrently
11
- * Agnostically handle different MIDI Message types (including SysEx)
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
- * Windows/Cygwin: {midi-winmm}[http://github.com/arirusso/midi-winmm]
20
-
21
- Note that if you are using JRuby you must be in 1.9 mode. This is normally accomplished by passing --1.9 to JRuby at the command line.
22
-
23
- == Install
24
-
25
- * gem install unimidi
26
-
27
- == Examples
28
-
29
- * {input}[http://github.com/arirusso/unimidi/blob/master/examples/input.rb]
30
- * {output}[http://github.com/arirusso/unimidi/blob/master/examples/output.rb]
31
-
32
- == Tests
33
-
34
- * please see {test/config.rb}[http://github.com/arirusso/unimidi/blob/master/test/config.rb] before running tests
35
-
36
- == Documentation
37
-
38
- * {rdoc}[http://rdoc.info/gems/unimidi]
39
-
40
- == To-do
41
-
42
- * OSX (coremidirb?) implementation
43
-
44
- == Author
45
-
46
- {Ari Russo}[http://github.com/arirusso] <ari.russo at gmail.com>
47
-
48
- == License
49
-
50
- Apache 2.0, See the file LICENSE
51
-
52
- Copyright (c) 2010-2011 Ari Russo
1
+ = UniMIDI
2
+
3
+ == Summary
4
+
5
+ Platform independent realtime MIDI input and output for Ruby.
6
+
7
+ == Features
8
+
9
+ * Currently Linux, JRuby, Windows and Cygwin are supported. OSX is {in progress}[http://github.com/arirusso/ffi-coremidi]
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
+ * Windows/Cygwin: {midi-winmm}[http://github.com/arirusso/midi-winmm]
20
+
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.
25
+
26
+ == Install
27
+
28
+ * gem install unimidi
29
+
30
+ == Examples
31
+
32
+ * {input}[http://github.com/arirusso/unimidi/blob/master/examples/input.rb]
33
+ * {output}[http://github.com/arirusso/unimidi/blob/master/examples/output.rb]
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
+ == Author
44
+
45
+ {Ari Russo}[http://github.com/arirusso] <ari.russo at gmail.com>
46
+
47
+ == License
48
+
49
+ Apache 2.0, See the file LICENSE
50
+
51
+ Copyright (c) 2010-2011 Ari Russo
data/lib/unimidi.rb CHANGED
@@ -1,17 +1,19 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # A realtime MIDI interface for Ruby
4
- #
5
- module UniMIDI
6
-
7
- VERSION = "0.0.7"
8
-
9
- end
10
-
11
- require 'unimidi/congruous_api_adapter'
12
- require 'unimidi/platform'
13
-
14
- module UniMIDI
15
- extend(Platform.instance.interface)
16
- include(Platform.instance.interface)
17
- end
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.3"
10
+
11
+ end
12
+
13
+ require 'unimidi/congruous_api_adapter'
14
+ require 'unimidi/platform'
15
+
16
+ module UniMIDI
17
+ extend(Platform.instance.interface)
18
+ include(Platform.instance.interface)
19
+ end
@@ -1,26 +1,33 @@
1
- require 'alsa-rawmidi'
2
-
3
- module UniMIDI
4
-
5
- module AlsaRawMIDIAdapter
6
-
7
- class Device
8
- extend CongruousApiAdapter::Device::ClassMethods
9
- defer_to AlsaRawMIDI::Device
10
- end
11
-
12
- class Input
13
- include CongruousApiAdapter::Device
14
- include CongruousApiAdapter::Input
15
- defer_to AlsaRawMIDI::Input
16
- end
17
-
18
- class Output
19
- include CongruousApiAdapter::Device
20
- include CongruousApiAdapter::Output
21
- defer_to AlsaRawMIDI::Output
22
- end
23
-
24
- end
25
-
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
4
+ #
5
+
6
+ require 'alsa-rawmidi'
7
+
8
+ module UniMIDI
9
+
10
+ module AlsaRawMIDIAdapter
11
+
12
+ class Input
13
+ include CongruousApiAdapter::Device
14
+ include CongruousApiAdapter::Input
15
+ defer_to AlsaRawMIDI::Input
16
+ end
17
+
18
+ class Output
19
+ include CongruousApiAdapter::Device
20
+ include CongruousApiAdapter::Output
21
+ defer_to AlsaRawMIDI::Output
22
+ end
23
+
24
+ class Device
25
+ extend CongruousApiAdapter::Device::ClassMethods
26
+ defer_to AlsaRawMIDI::Device
27
+ input_class Input
28
+ output_class Output
29
+ end
30
+
31
+ end
32
+
26
33
  end
@@ -1,26 +1,33 @@
1
- require 'midi-jruby'
2
-
3
- module UniMIDI
4
-
5
- module AlsaRawMIDIAdapter
6
-
7
- class Device
8
- extend CongruousApiAdapter::Device::ClassMethods
9
- defer_to MIDIJRuby::Device
10
- end
11
-
12
- class Input
13
- include CongruousApiAdapter::Device
14
- include CongruousApiAdapter::Input
15
- defer_to MIDIJRuby::Input
16
- end
17
-
18
- class Output
19
- include CongruousApiAdapter::Device
20
- include CongruousApiAdapter::Output
21
- defer_to MIDIJRuby::Output
22
- end
23
-
24
- end
25
-
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
4
+ #
5
+
6
+ require 'midi-jruby'
7
+
8
+ module UniMIDI
9
+
10
+ module MIDIJRubyAdapter
11
+
12
+ class Input
13
+ include CongruousApiAdapter::Device
14
+ include CongruousApiAdapter::Input
15
+ defer_to MIDIJRuby::Input
16
+ end
17
+
18
+ class Output
19
+ include CongruousApiAdapter::Device
20
+ include CongruousApiAdapter::Output
21
+ defer_to MIDIJRuby::Output
22
+ end
23
+
24
+ class Device
25
+ extend CongruousApiAdapter::Device::ClassMethods
26
+ defer_to MIDIJRuby::Device
27
+ input_class Input
28
+ output_class Output
29
+ end
30
+
31
+ end
32
+
26
33
  end
@@ -1,26 +1,33 @@
1
- require 'midi-winmm'
2
-
3
- module UniMIDI
4
-
5
- module MIDIWinMMAdapter
6
-
7
- class Device
8
- extend CongruousApiAdapter::Device::ClassMethods
9
- defer_to MIDIWinMM::Device
10
- end
11
-
12
- class Input
13
- include CongruousApiAdapter::Device
14
- include CongruousApiAdapter::Input
15
- defer_to MIDIWinMM::Input
16
- end
17
-
18
- class Output
19
- include CongruousApiAdapter::Device
20
- include CongruousApiAdapter::Output
21
- defer_to MIDIWinMM::Output
22
- end
23
-
24
- end
25
-
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
4
+ #
5
+
6
+ require 'midi-winmm'
7
+
8
+ module UniMIDI
9
+
10
+ module MIDIWinMMAdapter
11
+
12
+ class Input
13
+ include CongruousApiAdapter::Device
14
+ include CongruousApiAdapter::Input
15
+ defer_to MIDIWinMM::Input
16
+ end
17
+
18
+ class Output
19
+ include CongruousApiAdapter::Device
20
+ include CongruousApiAdapter::Output
21
+ defer_to MIDIWinMM::Output
22
+ end
23
+
24
+ class Device
25
+ extend CongruousApiAdapter::Device::ClassMethods
26
+ defer_to MIDIWinMM::Device
27
+ input_class Input
28
+ output_class Output
29
+ end
30
+
31
+ end
32
+
26
33
  end
@@ -1,113 +1,197 @@
1
- module UniMIDI
2
-
3
- module CongruousApiAdapter
4
-
5
- module Device
6
-
7
- def initialize(device_obj)
8
- @device = device_obj
9
- end
10
-
11
- def open(*a, &block)
12
- begin
13
- @device.open(*a)
14
- block.call(self)
15
- ensure
16
- close
17
- end
18
- end
19
-
20
- def close(*a)
21
- @device.close(*a)
22
- end
23
-
24
- def self.included(base)
25
- base.send(:attr_reader, :device)
26
- end
27
-
28
- module ClassMethods
29
-
30
- def first
31
- new(device_class.first)
32
- end
33
-
34
- def last
35
- new(device_class.last)
36
- end
37
-
38
- def all
39
- device_class.all.map { |d| new(d) }
40
- end
41
-
42
- def all_by_type
43
- {
44
- :input => device_class.all_by_type[:input].map { |d| new(d) },
45
- :output => device_class.all_by_type[:output].map { |d| new(d) }
46
- }
47
- end
48
-
49
- def defer_to(klass)
50
- const_set("DeferToClass", klass)
51
- end
52
-
53
- def device_class
54
- const_get("DeferToClass")
55
- end
56
-
57
- end
58
-
59
- end
60
-
61
- module Input
62
-
63
- def self.included(base)
64
- base.extend(Device::ClassMethods)
65
- base.extend(ClassMethods)
66
- end
67
-
68
- def gets(*a)
69
- @device.gets(*a)
70
- end
71
-
72
- def gets_bytestr(*a)
73
- @device.gets_bytestr(*a)
74
- end
75
-
76
- module ClassMethods
77
-
78
- def self.all
79
- device_class.all_by_type[:input].map { |d| new(d) }
80
- end
81
-
82
- end
83
-
84
- end
85
-
86
- module Output
87
-
88
- def self.included(base)
89
- base.extend(Device::ClassMethods)
90
- base.extend(ClassMethods)
91
- end
92
-
93
- def puts(*a)
94
- @device.puts(*a)
95
- end
96
-
97
- def puts_bytestr(*a)
98
- @device.puts_bytestr(*a)
99
- end
100
-
101
- module ClassMethods
102
-
103
- def self.all
104
- device_class.all_by_type[:output].map { |d| new(d) }
105
- end
106
-
107
- end
108
-
109
- end
110
-
111
- end
112
-
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
4
+ #
5
+
6
+ module UniMIDI
7
+
8
+ module CongruousApiAdapter
9
+
10
+ module Device
11
+
12
+ def initialize(device_obj)
13
+ @device = device_obj
14
+ @id = @device.id
15
+ @name = @device.name
16
+ end
17
+
18
+ # enable the device for use, can be passed a block to which the device will be passed back
19
+ def open(*a, &block)
20
+ @device.open(*a)
21
+ unless block.nil?
22
+ begin
23
+ block.call(self)
24
+ ensure
25
+ close
26
+ end
27
+ else
28
+ self
29
+ end
30
+ end
31
+
32
+ # close the device
33
+ def close(*a)
34
+ @device.close(*a)
35
+ end
36
+
37
+ def self.included(base)
38
+ #base.send(:attr_reader, :device)
39
+ base.send(:attr_reader, :name)
40
+ base.send(:attr_reader, :id)
41
+ end
42
+
43
+ module ClassMethods
44
+
45
+ def first
46
+ new(device_class.first)
47
+ end
48
+
49
+ def last
50
+ new(device_class.last)
51
+ end
52
+
53
+ def all
54
+ all_by_type.values.flatten
55
+ end
56
+
57
+ def all_by_type
58
+ {
59
+ :input => device_class.all_by_type[:input].map { |d| get_input_class.new(d) },
60
+ :output => device_class.all_by_type[:output].map { |d| get_output_class.new(d) }
61
+ }
62
+ end
63
+
64
+ def defer_to(klass)
65
+ const_set("DeferToClass", klass)
66
+ end
67
+
68
+ def get_input_class
69
+ const_get("InputClass")
70
+ end
71
+
72
+ def get_output_class
73
+ const_get("OutputClass")
74
+ end
75
+
76
+ def input_class(klass)
77
+ const_set("InputClass", klass)
78
+ end
79
+
80
+ def output_class(klass)
81
+ const_set("OutputClass", klass)
82
+ end
83
+
84
+ def device_class
85
+ const_get("DeferToClass")
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ module Input
93
+
94
+ def self.included(base)
95
+ base.extend(Device::ClassMethods)
96
+ base.extend(ClassMethods)
97
+ end
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_bytestr(*a)
123
+ @device.gets_bytestr(*a)
124
+ end
125
+
126
+ #
127
+ # returns an array of data bytes such as
128
+ # [144, 60, 100, 128, 60, 100, 144, 40, 120]
129
+ #
130
+ def gets_data(*a)
131
+ arr = gets
132
+ arr.map { |msg| msg[:data] }.inject { |a,b| a + b }
133
+ end
134
+
135
+ #
136
+ # returns a string of data such as
137
+ # "90406080406090447F"
138
+ #
139
+ def gets_data_bytestr(*a)
140
+ arr = gets_bytestr
141
+ arr.map { |msg| msg[:data] }.join
142
+ end
143
+
144
+ module ClassMethods
145
+
146
+ # returns all inputs
147
+ def all
148
+ device_class.all.map { |d| new(d) }
149
+ end
150
+
151
+ end
152
+
153
+ end
154
+
155
+ module Output
156
+
157
+ def self.included(base)
158
+ base.extend(Device::ClassMethods)
159
+ base.extend(ClassMethods)
160
+ end
161
+
162
+ # sends a message to the output. the message can be:
163
+ #
164
+ # bytes eg output.puts(0x90, 0x40, 0x40)
165
+ # an array of bytes eg output.puts([0x90, 0x40, 0x40])
166
+ # or a string eg output.puts("904040")
167
+ #
168
+ def puts(*a)
169
+ @device.puts(*a)
170
+ end
171
+
172
+ # sends a message to the output in a form of a string eg "904040". this method does not do
173
+ # type checking and therefore is more performant than puts
174
+ def puts_bytestr(*a)
175
+ @device.puts_bytestr(*a)
176
+ end
177
+
178
+ # sends a message to the output in a form of bytes eg output.puts_bytes(0x90, 0x40, 0x40).
179
+ # this method does not do type checking and therefore is more performant than puts
180
+ def puts_bytes(*a)
181
+ @device.puts_bytes(*a)
182
+ end
183
+
184
+ module ClassMethods
185
+
186
+ # returns all outputs
187
+ def all
188
+ device_class.all.map { |d| new(d) }
189
+ end
190
+
191
+ end
192
+
193
+ end
194
+
195
+ end
196
+
113
197
  end
@@ -1,30 +1,35 @@
1
- require 'singleton'
2
-
3
- module UniMIDI
4
-
5
- class Platform
6
-
7
- include Singleton
8
-
9
- attr_reader :interface
10
-
11
- def initialize
12
- lib = case RUBY_PLATFORM
13
- when /java/ then 'midi-jruby'
14
- when /linux/ then 'alsa-rawmidi'
15
- when /mingw/ then 'midi-winmm' #cygwin
16
- when /win/ then 'midi-winmm'
17
- end
18
- require("unimidi/adapter/#{lib}")
19
- @interface = case RUBY_PLATFORM
20
- when /java/ then MIDIJRuby
21
- when /linux/ then AlsaRawMIDIAdapter
22
- when /mingw/ then MIDIWinMMAdapter #cygwin
23
- when /win/ then MIDIWinMMAdapter
24
- end
25
- end
26
-
27
- end
28
-
29
- end
30
-
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # (c)2010-2011 Ari Russo and licensed under the Apache 2.0 License
4
+ #
5
+
6
+ require 'singleton'
7
+
8
+ module UniMIDI
9
+
10
+ class Platform
11
+
12
+ include Singleton
13
+
14
+ attr_reader :interface
15
+
16
+ def initialize
17
+ lib = case RUBY_PLATFORM
18
+ when /java/ then 'midi-jruby'
19
+ when /linux/ then 'alsa-rawmidi'
20
+ when /mingw/ then 'midi-winmm' #cygwin
21
+ when /win/ then 'midi-winmm'
22
+ end
23
+ require("unimidi/adapter/#{lib}")
24
+ @interface = case RUBY_PLATFORM
25
+ when /java/ then MIDIJRubyAdapter
26
+ when /linux/ then AlsaRawMIDIAdapter
27
+ when /mingw/ then MIDIWinMMAdapter #cygwin
28
+ when /win/ then MIDIWinMMAdapter
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
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.0.7
4
+ version: 0.1.3
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-04-24 00:00:00.000000000 -04:00
12
+ date: 2011-05-04 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: midi-winmm
17
- requirement: &21157896 !ruby/object:Gem::Requirement
17
+ requirement: &9399804 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,8 +22,8 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *21157896
26
- description: Cross-Platform, realtime MIDI input and output for Ruby.
25
+ version_requirements: *9399804
26
+ description: Platform Independent, realtime MIDI input and output for Ruby.
27
27
  email:
28
28
  - ari.russo@gmail.com
29
29
  executables: []
@@ -62,5 +62,5 @@ rubyforge_project: unimidi
62
62
  rubygems_version: 1.5.2
63
63
  signing_key:
64
64
  specification_version: 3
65
- summary: Cross-Platform, realtime MIDI input and output for Ruby
65
+ summary: Realtime MIDI input and output for Ruby.
66
66
  test_files: []