unimidi 0.1.14-i686-linux → 0.2.0-i686-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,14 +7,16 @@ Platform independent realtime MIDI input and output for Ruby.
7
7
  == Features
8
8
 
9
9
  * Supports Linux, JRuby, OSX, Windows and Cygwin
10
+ * No compilation required
10
11
  * Both input and output to and from multiple devices concurrently
11
12
  * Agnostically handle different MIDI and SysEx Message types
13
+ * (OSX Only) Internally patch to other programs using IAC and {MIDI Patch Bay}[http://www.apple.com/downloads/macosx/audio/midipatchbay.html]
12
14
 
13
15
  == Requirements
14
16
 
15
17
  Ruby 1.9.2 or JRuby 1.6.1 are strongly recommended
16
18
 
17
- One of the following libraries is required based on what platform you're using. They should all install automatically when you install the unimidi gem. You can freely remove the ones that do not apply to your platform
19
+ One of the following libraries is required based on what platform you're using. It should install automatically with the unimidi gem. In some uncommon cases, they will all install
18
20
 
19
21
  Platform
20
22
 
@@ -26,31 +28,48 @@ Platform
26
28
  == Install
27
29
 
28
30
  gem install unimidi
29
-
30
- No compilation required
31
31
 
32
- == Examples
32
+ == Usage
33
33
 
34
+ Here's a {blog post}[http://tx81z.blogspot.com/2011/06/unimidi-platform-independent-realtime.html] with a quick tutorial to {get started}[http://tx81z.blogspot.com/2011/06/unimidi-platform-independent-realtime.html].
35
+
36
+ Here's another {blog post}[http://tx81z.blogspot.com/2011/06/high-level-midi-io-with-ruby.html] that {explains how to do high-level messaging}[http://tx81z.blogspot.com/2011/06/high-level-midi-io-with-ruby.html]
37
+
38
+ In addition, some examples are included with the library
39
+
40
+ * {selecting a device}[http://github.com/arirusso/unimidi/blob/master/examples/select_a_device.rb]
34
41
  * {input}[http://github.com/arirusso/unimidi/blob/master/examples/input.rb]
35
42
  * {output}[http://github.com/arirusso/unimidi/blob/master/examples/output.rb]
36
43
 
37
- {more}[http://github.com/arirusso/unimidi/blob/master/examples]
44
+ {more examples}[http://github.com/arirusso/unimidi/blob/master/examples]
45
+
46
+ Here's another {blog post}[http://tx81z.blogspot.com/2011/06/osx-unimidi-and-midi-patch-bay.html] about {using unimidi with MIDI Patch Bay on OSX}[http://tx81z.blogspot.com/2011/06/osx-unimidi-and-midi-patch-bay.html]
38
47
 
39
48
  == Tests
40
49
 
41
- * please see {test/config.rb}[http://github.com/arirusso/unimidi/blob/master/test/config.rb] before running tests
50
+ There are a set of generic tests which assume that an output is connected to an input. If you wish to run these tests, first edit {test/config.rb}[http://github.com/arirusso/unimidi/blob/master/test/config.rb] to configure it to your setup.
51
+
52
+ The tests can be run using
53
+
54
+ rake test
55
+
56
+ See below for additional notes on testing with JRuby
42
57
 
43
58
  == Documentation
44
59
 
45
60
  * {rdoc}[http://rdoc.info/gems/unimidi]
46
61
 
47
- == If you are using JRuby
62
+ == Platform Specific Notes
48
63
 
49
- A couple of notes
64
+ ==== JRuby
50
65
 
51
66
  * 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
52
67
  jruby --1.9 -S rake test
53
68
  * javax.sound has some documented issues with SysEx messages in some versions OSX Snow Leopard which do affect this library.
69
+
70
+ ==== Linux
71
+
72
+ * libasound and libasound-dev packages are required
54
73
 
55
74
  == Author
56
75
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  module UniMIDI
8
8
 
9
- VERSION = "0.1.14"
9
+ VERSION = "0.2.0"
10
10
 
11
11
  end
12
12
 
@@ -182,9 +182,21 @@ module UniMIDI
182
182
  # bytes eg output.puts(0x90, 0x40, 0x40)
183
183
  # an array of bytes eg output.puts([0x90, 0x40, 0x40])
184
184
  # or a string eg output.puts("904040")
185
+ # if none of those types are found, unimidi will attempt
186
+ # to call to_bytes and then to_a on the object
185
187
  #
186
188
  def puts(*a)
187
- @device.puts(*a)
189
+ case a.first
190
+ when Array then puts_bytes(*a.first)
191
+ when Numeric then puts_bytes(*a)
192
+ when String then puts_s(*a)
193
+ else
194
+ if a.first.respond_to?(:to_bytes)
195
+ puts_bytes(*a.first.to_bytes.flatten)
196
+ elsif a.first.respond_to?(:to_a)
197
+ puts_bytes(*a.first.to_a.flatten)
198
+ end
199
+ end
188
200
  end
189
201
 
190
202
  # sends a message to the output in a form of a string eg "904040". this method does not do
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module TestHelper::Config
4
+
5
+ # adjust these constants to suit your hardware configuration
6
+ # before running tests
7
+
8
+ TestInput = UniMIDI::Input.first # this is the device you wish to use to test input
9
+ TestOutput = UniMIDI::Output.first # likewise for output
10
+
11
+ puts "connect #{TestInput.name} (#{TestInput.id}) to #{TestOutput.name} (#{TestOutput.id}) and press enter"
12
+ $stdin.gets.chomp
13
+
14
+ end
15
+
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ dir = File.dirname(File.expand_path(__FILE__))
4
+ $LOAD_PATH.unshift dir + '/../lib'
5
+
6
+ require 'test/unit'
7
+ require 'unimidi'
8
+
9
+ module TestHelper
10
+
11
+ TestSysex = !RUBY_PLATFORM.include?("java")
12
+
13
+ def platform_test(adapter, mod)
14
+ assert_equal(adapter, UniMIDI::Platform.instance.interface)
15
+ assert_not_same(mod::Input, UniMIDI::Input)
16
+ assert_not_same(mod::Output, UniMIDI::Output)
17
+ assert_not_same(mod::Device, UniMIDI::Device)
18
+ assert_equal(mod::Input.first.name, UniMIDI::Input.first.name)
19
+ assert_equal(mod::Input.first.id, UniMIDI::Input.first.id)
20
+ assert_not_same(mod::Output.first, UniMIDI::Output.first)
21
+ assert_equal(mod::Output.first.name, UniMIDI::Output.first.name)
22
+ assert_equal(mod::Output.first.id, UniMIDI::Output.first.id)
23
+ end
24
+
25
+ def bytestrs_to_ints(arr)
26
+ data = arr.map { |m| m[:data] }.join
27
+ output = []
28
+ until (bytestr = data.slice!(0,2)).eql?("")
29
+ output << bytestr.hex
30
+ end
31
+ output
32
+ end
33
+
34
+ class MIDIObj
35
+ def initialize(*bytes)
36
+ @bytes = bytes
37
+ end
38
+ def to_bytes
39
+ @bytes
40
+ end
41
+ end
42
+
43
+ # some MIDI messages
44
+ VariousMIDIObjects = [
45
+ TestSysex ? MIDIObj.new(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7) : nil, # SysEx
46
+ MIDIObj.new(0x90, 100, 100), # note on
47
+ MIDIObj.new(0x90, 43, 100), # note on
48
+ MIDIObj.new(0x90, 76, 100), # note on
49
+ MIDIObj.new(0x90, 60, 100), # note on
50
+ MIDIObj.new(0x80, 100, 100) # note off
51
+ ].compact
52
+
53
+ # some MIDI messages
54
+ VariousMIDIMessages = [
55
+ TestSysex ? [0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7] : nil, # SysEx
56
+ [0x90, 100, 100], # note on
57
+ [0x90, 43, 100], # note on
58
+ [0x90, 76, 100], # note on
59
+ [0x90, 60, 100], # note on
60
+ [0x80, 100, 100] # note off
61
+ ].compact
62
+
63
+ # some MIDI messages
64
+ VariousMIDIByteStrMessages = [
65
+ TestSysex ? "F04110421240007F0041F7" : nil, # SysEx
66
+ "906440", # note on
67
+ "804340" # note off
68
+ ].compact
69
+
70
+ end
71
+
72
+ require File.dirname(__FILE__) + '/config'
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'helper'
4
+
5
+ class InputBufferTest < Test::Unit::TestCase
6
+
7
+ include UniMIDI
8
+ include TestHelper
9
+ include TestHelper::Config # before running these tests, adjust the constants in config.rb to suit your hardware setup
10
+
11
+ def test_input_buffer
12
+ sleep(1)
13
+
14
+ messages = VariousMIDIMessages
15
+ bytes = []
16
+
17
+ TestOutput.open do |output|
18
+ TestInput.open do |input|
19
+
20
+ messages.each do |msg|
21
+
22
+ $>.puts "sending: " + msg.inspect
23
+
24
+ output.puts(msg)
25
+
26
+ bytes += msg
27
+
28
+ sleep(0.5)
29
+
30
+ buffer = input.buffer.map { |m| m[:data] }.flatten
31
+
32
+ $>.puts "received: " + buffer.to_s
33
+
34
+ assert_equal(bytes, buffer)
35
+
36
+ end
37
+
38
+ assert_equal(bytes.length, input.buffer.map { |m| m[:data] }.flatten.length)
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'helper'
4
+
5
+ class IoTest < Test::Unit::TestCase
6
+
7
+ include UniMIDI
8
+ include TestHelper
9
+ include TestHelper::Config # before running these tests, adjust the constants in config.rb to suit your hardware setup
10
+
11
+ # ** this test assumes that TestOutput is connected to TestInput
12
+ def test_full_io
13
+ sleep(1)
14
+ messages = VariousMIDIMessages
15
+ messages_arr = messages.inject { |a,b| a+b }.flatten
16
+ received_arr = []
17
+ pointer = 0
18
+ TestOutput.open do |output|
19
+ TestInput.open do |input|
20
+
21
+ messages.each do |msg|
22
+
23
+ $>.puts "sending: " + msg.inspect
24
+
25
+ output.puts(msg)
26
+ sleep(1)
27
+ received = input.gets.map { |m| m[:data] }.flatten
28
+
29
+
30
+ $>.puts "received: " + received.inspect
31
+
32
+ assert_equal(messages_arr.slice(pointer, received.length), received)
33
+
34
+ pointer += received.length
35
+
36
+ received_arr += received
37
+
38
+ end
39
+
40
+ assert_equal(messages_arr.length, received_arr.length)
41
+
42
+ end
43
+ end
44
+ end
45
+
46
+ # ** this test assumes that TestOutput is connected to TestInput
47
+ def test_full_io_bytestr
48
+ sleep(1) # pause between tests
49
+
50
+ messages = VariousMIDIByteStrMessages
51
+ messages_str = messages.join
52
+ received_str = ""
53
+ pointer = 0
54
+
55
+ TestOutput.open do |output|
56
+ TestInput.open do |input|
57
+
58
+ messages.each do |msg|
59
+
60
+ $>.puts "sending: " + msg.inspect
61
+
62
+ output.puts(msg)
63
+ sleep(1)
64
+ received = input.gets_bytestr.map { |m| m[:data] }.flatten.join
65
+ $>.puts "received: " + received.inspect
66
+
67
+ assert_equal(messages_str.slice(pointer, received.length), received)
68
+
69
+ pointer += received.length
70
+
71
+ received_str += received
72
+
73
+ end
74
+
75
+ assert_equal(messages_str, received_str)
76
+
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+ # ** this test assumes that TestOutput is connected to TestInput
83
+ def test_full_io_objects
84
+ sleep(1)
85
+ messages = VariousMIDIObjects
86
+ messages_arr = messages.map { |m| m.to_bytes }.flatten
87
+ received_arr = []
88
+ pointer = 0
89
+ TestOutput.open do |output|
90
+ TestInput.open do |input|
91
+
92
+ messages.each do |msg|
93
+
94
+ $>.puts "sending: " + msg.inspect
95
+
96
+ output.puts(msg)
97
+ sleep(1)
98
+ received = input.gets.map { |m| m[:data] }.flatten
99
+
100
+
101
+ $>.puts "received: " + received.inspect
102
+
103
+ assert_equal(messages_arr.slice(pointer, received.length), received)
104
+
105
+ pointer += received.length
106
+
107
+ received_arr += received
108
+
109
+ end
110
+
111
+ assert_equal(messages_arr.length, received_arr.length)
112
+
113
+ end
114
+ end
115
+ end
116
+
117
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'helper'
4
+
5
+ class PlatformTest < Test::Unit::TestCase
6
+
7
+ include UniMIDI
8
+ include TestHelper
9
+ include TestHelper::Config
10
+
11
+ def test_jruby
12
+ if RUBY_PLATFORM.include?("java")
13
+ platform_test(MIDIJRubyAdapter, MIDIJRuby)
14
+ end
15
+ end
16
+
17
+ def test_linux
18
+ if RUBY_PLATFORM.include?("linux")
19
+ platform_test(AlsaRawMIDIAdapter, AlsaRawMIDI)
20
+ end
21
+ end
22
+
23
+ def test_osx
24
+ if RUBY_PLATFORM.include?("darwin")
25
+ platform_test(CoreMIDIAdapter, CoreMIDI)
26
+ end
27
+ end
28
+
29
+ def test_windows
30
+ if RUBY_PLATFORM.include?("mingw")
31
+ platform_test(MIDIWinMMAdapter, MIDIWinMM)
32
+ end
33
+ end
34
+
35
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: unimidi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.14
5
+ version: 0.2.0
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-23 00:00:00 -04:00
13
+ date: 2011-07-07 00:00:00 -04:00
14
14
  default_executable: unimidi
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  version: "0"
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
- description: Platform Independent, realtime MIDI input and output for Ruby.
27
+ description: Platform Independent, realtime MIDI input and output for Ruby
28
28
  email:
29
29
  - ari.russo@gmail.com
30
30
  executables:
@@ -35,14 +35,19 @@ extra_rdoc_files: []
35
35
 
36
36
  files:
37
37
  - bin/unimidi
38
- - lib/unimidi/type_conversion.rb
39
- - lib/unimidi/platform.rb
40
- - lib/unimidi/adapter/alsa-rawmidi.rb
38
+ - lib/unimidi.rb
41
39
  - lib/unimidi/adapter/ffi-coremidi.rb
42
40
  - lib/unimidi/adapter/midi-winmm.rb
41
+ - lib/unimidi/adapter/alsa-rawmidi.rb
43
42
  - lib/unimidi/adapter/midi-jruby.rb
44
43
  - lib/unimidi/congruous_api_adapter.rb
45
- - lib/unimidi.rb
44
+ - lib/unimidi/platform.rb
45
+ - lib/unimidi/type_conversion.rb
46
+ - test/helper.rb
47
+ - test/config.rb
48
+ - test/test_io.rb
49
+ - test/test_input_buffer.rb
50
+ - test/test_platform.rb
46
51
  - LICENSE
47
52
  - README.rdoc
48
53
  has_rdoc: true
@@ -72,6 +77,6 @@ rubyforge_project: unimidi
72
77
  rubygems_version: 1.6.2
73
78
  signing_key:
74
79
  specification_version: 3
75
- summary: Realtime MIDI input and output for Ruby.
80
+ summary: Realtime MIDI input and output for Ruby
76
81
  test_files: []
77
82