unimidi 0.0.5-java

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +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
13
+ limitations under the License.
data/README.rdoc ADDED
@@ -0,0 +1,52 @@
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, 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
data/lib/unimidi.rb ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # A realtime MIDI interface for Ruby
4
+ #
5
+ module UniMIDI
6
+
7
+ VERSION = "0.0.5"
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
@@ -0,0 +1,26 @@
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
+
26
+ end
@@ -0,0 +1,26 @@
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
+
26
+ end
@@ -0,0 +1,26 @@
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
+
26
+ end
@@ -0,0 +1,113 @@
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
+
113
+ end
@@ -0,0 +1,30 @@
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
+
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unimidi
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 5
9
+ version: 0.0.5
10
+ platform: java
11
+ authors:
12
+ - Ari Russo
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-24 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: midi-jruby
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: Platform Independent, realtime MIDI input and output for Ruby.
33
+ email:
34
+ - ari.russo@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - lib/unimidi.rb
43
+ - lib/unimidi/congruous_api_adapter.rb
44
+ - lib/unimidi/platform.rb
45
+ - lib/unimidi/adapter/midi-winmm.rb
46
+ - lib/unimidi/adapter/alsa-rawmidi.rb
47
+ - lib/unimidi/adapter/midi-jruby.rb
48
+ - LICENSE
49
+ - README.rdoc
50
+ has_rdoc: true
51
+ homepage: http://github.com/arirusso/unimidi
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 1
72
+ - 3
73
+ - 6
74
+ version: 1.3.6
75
+ requirements: []
76
+
77
+ rubyforge_project: unimidi
78
+ rubygems_version: 1.3.6
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Realtime MIDI input and output for Ruby.
82
+ test_files: []
83
+