unimidi 0.1.14-i386-mingw32 → 0.2.0-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.
@@ -1,15 +1,15 @@
1
- #!/usr/bin/env ruby
2
- #
3
-
4
- module UniMIDI
5
-
6
- module TypeConversion
7
-
8
- # byte array to string of hex bytes
9
- def numeric_byte_array_to_hex_string(bytes)
10
- bytes.map { |b| b.hex }.join
11
- end
12
-
13
- end
14
-
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ module UniMIDI
5
+
6
+ module TypeConversion
7
+
8
+ # byte array to string of hex bytes
9
+ def numeric_byte_array_to_hex_string(bytes)
10
+ bytes.map { |b| b.hex }.join
11
+ end
12
+
13
+ end
14
+
15
15
  end
@@ -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
@@ -1,70 +1,82 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: unimidi
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.14
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.2.0
6
6
  platform: i386-mingw32
7
- authors:
7
+ authors:
8
8
  - Ari Russo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-23 00:00:00.000000000 -04:00
12
+
13
+ date: 2011-07-07 00:00:00 -04:00
13
14
  default_executable: unimidi
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
16
17
  name: midi-winmm
17
- requirement: &9400452 !ruby/object:Gem::Requirement
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
18
20
  none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
23
25
  type: :runtime
24
- prerelease: false
25
- version_requirements: *9400452
26
- description: Platform Independent, realtime MIDI input and output for Ruby.
27
- email:
26
+ version_requirements: *id001
27
+ description: Platform Independent, realtime MIDI input and output for Ruby
28
+ email:
28
29
  - ari.russo@gmail.com
29
- executables:
30
+ executables:
30
31
  - unimidi
31
32
  extensions: []
33
+
32
34
  extra_rdoc_files: []
33
- files:
35
+
36
+ files:
34
37
  - bin/unimidi
35
- - lib/unimidi/adapter/alsa-rawmidi.rb
38
+ - lib/unimidi.rb
36
39
  - lib/unimidi/adapter/ffi-coremidi.rb
37
- - lib/unimidi/adapter/midi-jruby.rb
38
40
  - lib/unimidi/adapter/midi-winmm.rb
41
+ - lib/unimidi/adapter/alsa-rawmidi.rb
42
+ - lib/unimidi/adapter/midi-jruby.rb
39
43
  - lib/unimidi/congruous_api_adapter.rb
40
44
  - lib/unimidi/platform.rb
41
45
  - lib/unimidi/type_conversion.rb
42
- - lib/unimidi.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
43
51
  - LICENSE
44
52
  - README.rdoc
45
53
  has_rdoc: true
46
54
  homepage: http://github.com/arirusso/unimidi
47
55
  licenses: []
56
+
48
57
  post_install_message:
49
58
  rdoc_options: []
50
- require_paths:
59
+
60
+ require_paths:
51
61
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
62
+ required_ruby_version: !ruby/object:Gem::Requirement
53
63
  none: false
54
- requirements:
55
- - - ! '>='
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
69
  none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
63
73
  version: 1.3.6
64
74
  requirements: []
75
+
65
76
  rubyforge_project: unimidi
66
- rubygems_version: 1.5.2
77
+ rubygems_version: 1.6.2
67
78
  signing_key:
68
79
  specification_version: 3
69
- summary: Realtime MIDI input and output for Ruby.
80
+ summary: Realtime MIDI input and output for Ruby
70
81
  test_files: []
82
+