unimidi 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ Platform independent realtime MIDI input and output for Ruby.
14
14
 
15
15
  == Requirements
16
16
 
17
- Ruby 1.9.2 or JRuby 1.6.1 are strongly recommended
17
+ Using Ruby 1.9.2 or JRuby 1.6.1 (or newer) is strongly recommended. JRuby should be run in 1.9 mode
18
18
 
19
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
20
20
 
@@ -47,7 +47,7 @@ Here's another {blog post}[http://tx81z.blogspot.com/2011/06/osx-unimidi-and-mid
47
47
 
48
48
  == Tests
49
49
 
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.
50
+ There are a set of tests which assume that an output is connected to an input. You will be asked to select which input and output as the test is run.
51
51
 
52
52
  The tests can be run using
53
53
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  module UniMIDI
8
8
 
9
- VERSION = "0.2.1"
9
+ VERSION = "0.2.2"
10
10
 
11
11
  end
12
12
 
@@ -16,7 +16,7 @@ module UniMIDI
16
16
  end
17
17
 
18
18
  class Device < CongruousApiDevice
19
- defer_to CoreMIDI::Entity
19
+ defer_to CoreMIDI::Endpoint
20
20
  input_class Input
21
21
  output_class Output
22
22
  end
@@ -27,6 +27,10 @@ module UniMIDI
27
27
  self
28
28
  end
29
29
  end
30
+
31
+ def pretty_name
32
+ "#{id}: #{name}"
33
+ end
30
34
 
31
35
  # close the device
32
36
  def close(*a)
@@ -60,6 +64,11 @@ module UniMIDI
60
64
  def all
61
65
  all_by_type.values.flatten
62
66
  end
67
+
68
+ # returns the device at <em>index</em>
69
+ def [](index)
70
+ all[index]
71
+ end
63
72
 
64
73
  # returns all devices as a hash as such
65
74
  # { :input => [input devices], :output => [output devices] }
@@ -8,7 +8,26 @@ require 'unimidi'
8
8
 
9
9
  module TestHelper
10
10
 
11
- TestSysex = !RUBY_PLATFORM.include?("java")
11
+ TestSysex = !RUBY_PLATFORM.include?("java")
12
+
13
+ def self.select_devices
14
+ $test_device ||= {}
15
+ { :input => UniMIDI::Input.all, :output => UniMIDI::Output.all }.each do |type, devs|
16
+ puts ""
17
+ puts "select an #{type.to_s}..."
18
+ while $test_device[type].nil?
19
+ devs.each do |device|
20
+ puts device.pretty_name
21
+ end
22
+ selection = $stdin.gets.chomp
23
+ if selection != ""
24
+ selection = selection.to_i
25
+ $test_device[type] = devs.find { |d| d.id == selection }
26
+ puts "selected #{selection} for #{type.to_s}" unless $test_device[type]
27
+ end
28
+ end
29
+ end
30
+ end
12
31
 
13
32
  def platform_test(adapter, mod)
14
33
  assert_equal(adapter, UniMIDI::Platform.instance.interface)
@@ -69,4 +88,4 @@ module TestHelper
69
88
 
70
89
  end
71
90
 
72
- require File.dirname(__FILE__) + '/config'
91
+ TestHelper.select_devices
@@ -6,16 +6,15 @@ class InputBufferTest < Test::Unit::TestCase
6
6
 
7
7
  include UniMIDI
8
8
  include TestHelper
9
- include TestHelper::Config # before running these tests, adjust the constants in config.rb to suit your hardware setup
10
-
9
+
11
10
  def test_input_buffer
12
11
  sleep(1)
13
12
 
14
13
  messages = VariousMIDIMessages
15
14
  bytes = []
16
15
 
17
- TestOutput.open do |output|
18
- TestInput.open do |input|
16
+ $test_device[:output].open do |output|
17
+ $test_device[:input].open do |input|
19
18
 
20
19
  messages.each do |msg|
21
20
 
@@ -6,7 +6,6 @@ class IoTest < Test::Unit::TestCase
6
6
 
7
7
  include UniMIDI
8
8
  include TestHelper
9
- include TestHelper::Config # before running these tests, adjust the constants in config.rb to suit your hardware setup
10
9
 
11
10
  # ** this test assumes that TestOutput is connected to TestInput
12
11
  def test_full_io
@@ -15,8 +14,8 @@ class IoTest < Test::Unit::TestCase
15
14
  messages_arr = messages.inject { |a,b| a+b }.flatten
16
15
  received_arr = []
17
16
  pointer = 0
18
- TestOutput.open do |output|
19
- TestInput.open do |input|
17
+ $test_device[:output].open do |output|
18
+ $test_device[:input].open do |input|
20
19
 
21
20
  messages.each do |msg|
22
21
 
@@ -52,8 +51,8 @@ class IoTest < Test::Unit::TestCase
52
51
  received_str = ""
53
52
  pointer = 0
54
53
 
55
- TestOutput.open do |output|
56
- TestInput.open do |input|
54
+ $test_device[:output].open do |output|
55
+ $test_device[:input].open do |input|
57
56
 
58
57
  messages.each do |msg|
59
58
 
@@ -86,8 +85,8 @@ class IoTest < Test::Unit::TestCase
86
85
  messages_arr = messages.map { |m| m.to_bytes }.flatten
87
86
  received_arr = []
88
87
  pointer = 0
89
- TestOutput.open do |output|
90
- TestInput.open do |input|
88
+ $test_device[:output].open do |output|
89
+ $test_device[:input].open do |input|
91
90
 
92
91
  messages.each do |msg|
93
92
 
@@ -6,8 +6,7 @@ class PlatformTest < Test::Unit::TestCase
6
6
 
7
7
  include UniMIDI
8
8
  include TestHelper
9
- include TestHelper::Config
10
-
9
+
11
10
  def test_jruby
12
11
  if RUBY_PLATFORM.include?("java")
13
12
  platform_test(MIDIJRubyAdapter, MIDIJRuby)
metadata CHANGED
@@ -1,72 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: unimidi
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
4
5
  prerelease:
5
- version: 0.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ari Russo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-11 00:00:00 -04:00
14
- default_executable: unimidi
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-26 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: alsa-rawmidi
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &79603120 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: ffi-coremidi
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *79603120
25
+ - !ruby/object:Gem::Dependency
26
+ name: ffi-coremidi
27
+ requirement: &79602620 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
36
33
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: midi-jruby
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *79602620
36
+ - !ruby/object:Gem::Dependency
37
+ name: midi-jruby
38
+ requirement: &79602200 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
47
44
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: midi-winmm
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *79602200
47
+ - !ruby/object:Gem::Dependency
48
+ name: midi-winmm
49
+ requirement: &79601840 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
58
55
  type: :runtime
59
- version_requirements: *id004
56
+ prerelease: false
57
+ version_requirements: *79601840
60
58
  description: Platform Independent, realtime MIDI input and output for Ruby
61
- email:
59
+ email:
62
60
  - ari.russo@gmail.com
63
- executables:
61
+ executables:
64
62
  - unimidi
65
63
  extensions: []
66
-
67
64
  extra_rdoc_files: []
68
-
69
- files:
65
+ files:
70
66
  - bin/unimidi
71
67
  - lib/unimidi.rb
72
68
  - lib/unimidi/adapter/ffi-coremidi.rb
@@ -77,39 +73,33 @@ files:
77
73
  - lib/unimidi/platform.rb
78
74
  - lib/unimidi/type_conversion.rb
79
75
  - test/helper.rb
80
- - test/config.rb
81
76
  - test/test_io.rb
82
77
  - test/test_input_buffer.rb
83
78
  - test/test_platform.rb
84
79
  - LICENSE
85
80
  - README.rdoc
86
- has_rdoc: true
87
81
  homepage: http://github.com/arirusso/unimidi
88
82
  licenses: []
89
-
90
83
  post_install_message:
91
84
  rdoc_options: []
92
-
93
- require_paths:
85
+ require_paths:
94
86
  - lib
95
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
96
88
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
101
- required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
94
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
106
98
  version: 1.3.6
107
99
  requirements: []
108
-
109
100
  rubyforge_project: unimidi
110
- rubygems_version: 1.6.2
101
+ rubygems_version: 1.8.7
111
102
  signing_key:
112
103
  specification_version: 3
113
104
  summary: Realtime MIDI input and output for Ruby
114
105
  test_files: []
115
-
@@ -1,15 +0,0 @@
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
-