micromidi 0.1.3 → 0.1.4

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/test/effect_test.rb CHANGED
@@ -1,14 +1,11 @@
1
1
  require "helper"
2
2
 
3
- class EffectTest < Test::Unit::TestCase
4
-
5
- include MicroMIDI
6
- include TestHelper
3
+ class EffectTest < Minitest::Test
7
4
 
8
5
  def test_high_pass_note_reject
9
6
  m = MicroMIDI.message
10
7
  msg = m.note "C0"
11
- outp = m.hpf msg, :note, 20
8
+ outp = m.hpf msg, :note, 20
12
9
  assert_equal(12, msg.note)
13
10
  assert_equal(nil, outp)
14
11
  end
@@ -52,7 +49,7 @@ class EffectTest < Test::Unit::TestCase
52
49
  assert_equal(60, msg.note)
53
50
  assert_equal(msg, outp)
54
51
  end
55
-
52
+
56
53
  def test_notch_note_reject
57
54
  m = MicroMIDI.message
58
55
  msg = m.note "C4"
@@ -68,7 +65,7 @@ class EffectTest < Test::Unit::TestCase
68
65
  assert_equal(60, msg.note)
69
66
  assert_equal(msg, outp)
70
67
  end
71
-
68
+
72
69
  def test_multiband_note_reject
73
70
  m = MicroMIDI.message
74
71
  msg = m.note "C4"
@@ -84,7 +81,7 @@ class EffectTest < Test::Unit::TestCase
84
81
  assert_equal(60, msg.note)
85
82
  assert_equal(msg, outp)
86
83
  end
87
-
84
+
88
85
  def test_multinotch_note_reject
89
86
  m = MicroMIDI.message
90
87
  msg = m.note "C4"
@@ -96,11 +93,11 @@ class EffectTest < Test::Unit::TestCase
96
93
  def test_multinotch_note_accept
97
94
  m = MicroMIDI.message
98
95
  msg = m.note "C4"
99
- outp = m.mbf msg, :note, [(20..30), (40..50)], :reject => true
96
+ outp = m.mbf msg, :note, [(20..30), (40..50)], :reject => true
100
97
  assert_equal(60, msg.note)
101
98
  assert_equal(msg, outp)
102
99
  end
103
-
100
+
104
101
  def test_limit_low
105
102
  m = MicroMIDI.message
106
103
  msg = m.note "C0"
@@ -114,7 +111,7 @@ class EffectTest < Test::Unit::TestCase
114
111
  outp = m.limit msg, :note, (20..50)
115
112
  assert_equal(50, msg.note)
116
113
  end
117
-
114
+
118
115
  def test_transpose_note_up
119
116
  m = MicroMIDI.message
120
117
  msg = m.note "C4"
@@ -128,6 +125,5 @@ class EffectTest < Test::Unit::TestCase
128
125
  outp = m.transpose msg, :velocity, -10
129
126
  assert_equal(72, msg.velocity)
130
127
  end
131
-
132
- end
133
128
 
129
+ end
data/test/helper.rb CHANGED
@@ -1,30 +1,37 @@
1
1
  dir = File.dirname(File.expand_path(__FILE__))
2
2
  $LOAD_PATH.unshift dir + "/../lib"
3
3
 
4
- require "test/unit"
4
+ require "minitest/autorun"
5
5
  require "midi"
6
6
 
7
7
  module TestHelper
8
-
9
- def self.select_devices
10
- $test_device ||= {}
8
+
9
+ extend self
10
+
11
+ def test_device
12
+ @test_device ||= select_devices
13
+ end
14
+
15
+ def select_devices
16
+ @test_device ||= {}
11
17
  { :input => UniMIDI::Input.all, :output => UniMIDI::Output.all }.each do |type, devs|
12
18
  puts ""
13
19
  puts "select an #{type.to_s}..."
14
- while $test_device[type].nil?
20
+ while @test_device[type].nil?
15
21
  devs.each do |device|
16
22
  puts device.pretty_name
17
23
  end
18
24
  selection = $stdin.gets.chomp
19
25
  if selection != ""
20
26
  selection = selection.to_i
21
- $test_device[type] = devs.find { |d| d.id == selection }
22
- puts "selected #{selection} for #{type.to_s}" unless $test_device[type]
27
+ @test_device[type] = devs.find { |d| d.id == selection }
28
+ puts "selected #{selection} for #{type.to_s}" unless @test_device[type]
23
29
  end
24
30
  end
25
31
  end
26
- end
27
-
32
+ @test_device
33
+ end
34
+
28
35
  end
29
36
 
30
37
  TestHelper.select_devices
data/test/input_test.rb CHANGED
@@ -1,17 +1,16 @@
1
1
  require "helper"
2
2
 
3
- class InputTest < Test::Unit::TestCase
3
+ class InputTest < Minitest::Test
4
4
 
5
5
  def test_thru_listeners
6
- m = MicroMIDI.message($test_device[:input].open)
6
+ m = MicroMIDI.message(TestHelper.test_device[:input].open)
7
7
  m.thru
8
8
  assert_equal(0, m.state.listeners.size)
9
9
  assert_equal(1, m.state.thru_listeners.size)
10
- assert_equal(MIDIEye::Listener, m.state.thru_listeners.first.class)
10
+ assert_equal(MIDIEye::Listener, m.state.thru_listeners.first.class)
11
11
  end
12
12
 
13
13
  def test_thru_unless
14
14
  end
15
-
16
- end
17
15
 
16
+ end
data/test/message_test.rb CHANGED
@@ -1,15 +1,11 @@
1
1
  require "helper"
2
2
 
3
- class MessageTest < Test::Unit::TestCase
3
+ class MessageTest < Minitest::Test
4
4
 
5
- include MicroMIDI
6
- include MIDIMessage
7
- include TestHelper
8
-
9
5
  def test_cc
10
6
  m = MicroMIDI.message
11
7
  msg = m.cc 16, 12
12
- assert_equal(ControlChange, msg.class)
8
+ assert_equal(MIDIMessage::ControlChange, msg.class)
13
9
  assert_equal(16, msg.index)
14
10
  assert_equal(12, msg.value)
15
11
  end
@@ -17,7 +13,7 @@ class MessageTest < Test::Unit::TestCase
17
13
  def test_channel_aftertouch
18
14
  m = MicroMIDI::IO.new
19
15
  msg = m.channel_aftertouch 2, :channel => 1
20
- assert_equal(ChannelAftertouch, msg.class)
16
+ assert_equal(MIDIMessage::ChannelAftertouch, msg.class)
21
17
  assert_equal(1, msg.channel)
22
18
  assert_equal(2, msg.value)
23
19
  end
@@ -25,34 +21,34 @@ class MessageTest < Test::Unit::TestCase
25
21
  def test_poly_aftertouch
26
22
  m = MicroMIDI::IO.new
27
23
  msg = m.poly_aftertouch 64, 2, :channel => 1
28
- assert_equal(PolyphonicAftertouch, msg.class)
24
+ assert_equal(MIDIMessage::PolyphonicAftertouch, msg.class)
29
25
  assert_equal(1, msg.channel)
30
26
  assert_equal(64, msg.note)
31
27
  assert_equal(2, msg.value)
32
28
  end
33
-
29
+
34
30
  def test_pitch_bend
35
31
  m = MicroMIDI::IO.new
36
32
  msg = m.pitch_bend 64, 2, :channel => 1
37
- assert_equal(PitchBend, msg.class)
33
+ assert_equal(MIDIMessage::PitchBend, msg.class)
38
34
  assert_equal(1, msg.channel)
39
35
  assert_equal(64, msg.low)
40
- assert_equal(2, msg.high)
36
+ assert_equal(2, msg.high)
41
37
  end
42
-
38
+
43
39
  def test_note_off
44
40
  m = MicroMIDI.message
45
41
  msg = m.note_off 13, :channel => 9, :velocity => 80
46
- assert_equal(NoteOff, msg.class)
42
+ assert_equal(MIDIMessage::NoteOff, msg.class)
47
43
  assert_equal(13, msg.note)
48
44
  assert_equal(9, msg.channel)
49
- assert_equal(80, msg.velocity)
45
+ assert_equal(80, msg.velocity)
50
46
  end
51
47
 
52
48
  def test_note_on_string
53
49
  m = MicroMIDI.message
54
50
  msg = m.note "C0", :velocity => 94
55
- assert_equal(NoteOn, msg.class)
51
+ assert_equal(MIDIMessage::NoteOn, msg.class)
56
52
  assert_equal(12, msg.note)
57
53
  assert_equal(94, msg.velocity)
58
54
  end
@@ -60,15 +56,15 @@ class MessageTest < Test::Unit::TestCase
60
56
  def test_note_on_string_no_octave
61
57
  m = MicroMIDI.message
62
58
  msg = m.note "C", :velocity => 94
63
- assert_equal(NoteOn, msg.class)
59
+ assert_equal(MIDIMessage::NoteOn, msg.class)
64
60
  assert_equal(36, msg.note)
65
61
  assert_equal(94, msg.velocity)
66
62
  end
67
-
63
+
68
64
  def test_note_on_int
69
65
  m = MicroMIDI.message
70
66
  msg = m.note 12, :channel => 3
71
- assert_equal(NoteOn, msg.class)
67
+ assert_equal(MIDIMessage::NoteOn, msg.class)
72
68
  assert_equal(12, msg.note)
73
69
  assert_equal(3, msg.channel)
74
70
  end
@@ -76,46 +72,45 @@ class MessageTest < Test::Unit::TestCase
76
72
  def test_note_on_symbol
77
73
  m = MicroMIDI.message
78
74
  msg = m.note :C0
79
- assert_equal(NoteOn, msg.class)
75
+ assert_equal(MIDIMessage::NoteOn, msg.class)
80
76
  assert_equal(12, msg.note)
81
- assert_equal(100, msg.velocity)
77
+ assert_equal(100, msg.velocity)
82
78
  end
83
-
79
+
84
80
  def test_note_on_symbol_no_octave
85
81
  m = MicroMIDI.message
86
82
  msg = m.note :C
87
- assert_equal(NoteOn, msg.class)
83
+ assert_equal(MIDIMessage::NoteOn, msg.class)
88
84
  assert_equal(36, msg.note)
89
- assert_equal(100, msg.velocity)
85
+ assert_equal(100, msg.velocity)
90
86
  end
91
-
87
+
92
88
  def test_parse
93
89
  m = MicroMIDI.message
94
90
  msg = m.parse "906040"
95
- assert_equal(NoteOn, msg.class)
91
+ assert_equal(MIDIMessage::NoteOn, msg.class)
96
92
  assert_equal(96, msg.note)
97
- assert_equal(0, msg.channel)
93
+ assert_equal(0, msg.channel)
98
94
  assert_equal(64, msg.velocity)
99
95
  end
100
-
96
+
101
97
  def test_program_change
102
98
  m = MicroMIDI.message
103
99
  msg = m.program_change 15
104
- assert_equal(ProgramChange, msg.class)
105
- assert_equal(15, msg.program)
100
+ assert_equal(MIDIMessage::ProgramChange, msg.class)
101
+ assert_equal(15, msg.program)
106
102
  end
107
-
103
+
108
104
  def test_off
109
105
  m = MicroMIDI.message
110
106
  msg = m.note "C0", :channel => 3
111
- assert_equal(NoteOn, msg.class)
107
+ assert_equal(MIDIMessage::NoteOn, msg.class)
112
108
  assert_equal(12, msg.note)
113
109
  assert_equal(3, msg.channel)
114
- off_msg = m.off
115
- assert_equal(NoteOff, off_msg.class)
110
+ off_msg = m.off
111
+ assert_equal(MIDIMessage::NoteOff, off_msg.class)
116
112
  assert_equal(12, off_msg.note)
117
113
  assert_equal(3, off_msg.channel)
118
114
  end
119
-
120
- end
121
115
 
116
+ end
data/test/output_test.rb CHANGED
@@ -1,19 +1,14 @@
1
1
  require "helper"
2
2
 
3
- class OutputTest < Test::Unit::TestCase
4
-
5
- include MicroMIDI
6
- include MIDIMessage
7
- include TestHelper
3
+ class OutputTest < Minitest::Test
8
4
 
9
5
  def test_auto_output
10
- m = MicroMIDI.message($test_device[:output].open)
6
+ m = MicroMIDI.message(TestHelper.test_device[:output].open)
11
7
  assert_equal(true, m.state.auto_output)
12
8
  m.output false
13
9
  assert_equal(false, m.state.auto_output)
14
10
  m.output true
15
11
  assert_equal(true, m.state.auto_output)
16
12
  end
17
-
18
- end
19
13
 
14
+ end
data/test/state_test.rb CHANGED
@@ -1,22 +1,18 @@
1
1
  require "helper"
2
2
 
3
- class StateTest < Test::Unit::TestCase
4
-
5
- include MicroMIDI
6
- include MIDIMessage
7
- include TestHelper
3
+ class StateTest < Minitest::Test
8
4
 
9
5
  def test_output_cache
10
6
  m = MicroMIDI.message
11
7
  cache = m.state.output_cache
12
-
13
- m.note "C0"
8
+
9
+ m.note "C0"
14
10
  assert_equal(1, cache.size)
15
-
11
+
16
12
  m.note "C3"
17
- assert_equal(2, cache.size)
13
+ assert_equal(2, cache.size)
18
14
  end
19
-
15
+
20
16
  def test_start_time
21
17
  t1 = Time.now.to_f
22
18
  m = MicroMIDI.message
@@ -25,6 +21,5 @@ class StateTest < Test::Unit::TestCase
25
21
  assert_equal(true, t1 < t)
26
22
  assert_equal(true, t < t2)
27
23
  end
28
-
29
- end
30
24
 
25
+ end
data/test/sticky_test.rb CHANGED
@@ -1,52 +1,48 @@
1
1
  require "helper"
2
2
 
3
- class StickyTest < Test::Unit::TestCase
4
-
5
- include MicroMIDI
6
- include MIDIMessage
7
- include TestHelper
3
+ class StickyTest < Minitest::Test
8
4
 
9
5
  def test_channel
10
6
  m = MicroMIDI.message
11
7
  msg = m.note "C0"
12
- assert_equal(NoteOn, msg.class)
8
+ assert_equal(MIDIMessage::NoteOn, msg.class)
13
9
  assert_equal(12, msg.note)
14
10
  assert_equal(0, msg.channel)
15
-
11
+
16
12
  m.channel 7
17
13
  msg = m.note "C0"
18
- assert_equal(NoteOn, msg.class)
14
+ assert_equal(MIDIMessage::NoteOn, msg.class)
19
15
  assert_equal(12, msg.note)
20
16
  assert_equal(7, msg.channel)
21
17
  end
22
-
18
+
23
19
  def test_channel_override
24
20
  m = MicroMIDI.message
25
21
  m.channel 7
26
22
  msg = m.note "C0", :channel => 3
27
- assert_equal(NoteOn, msg.class)
23
+ assert_equal(MIDIMessage::NoteOn, msg.class)
28
24
  assert_equal(12, msg.note)
29
25
  assert_equal(3, msg.channel)
30
26
  assert_equal(100, msg.velocity)
31
-
27
+
32
28
  msg = m.note "C0"
33
- assert_equal(NoteOn, msg.class)
29
+ assert_equal(MIDIMessage::NoteOn, msg.class)
34
30
  assert_equal(12, msg.note)
35
31
  assert_equal(7, msg.channel)
36
32
  assert_equal(100, msg.velocity)
37
33
  end
38
-
34
+
39
35
  def test_velocity
40
36
  m = MicroMIDI.message
41
37
  msg = m.note "C0"
42
- assert_equal(NoteOn, msg.class)
38
+ assert_equal(MIDIMessage::NoteOn, msg.class)
43
39
  assert_equal(12, msg.note)
44
40
  assert_equal(0, msg.channel)
45
41
  assert_equal(100, msg.velocity)
46
-
47
- m.velocity 10
42
+
43
+ m.velocity 10
48
44
  msg = m.note "C0"
49
- assert_equal(NoteOn, msg.class)
45
+ assert_equal(MIDIMessage::NoteOn, msg.class)
50
46
  assert_equal(12, msg.note)
51
47
  assert_equal(0, msg.channel)
52
48
  assert_equal(10, msg.velocity)
@@ -55,38 +51,38 @@ class StickyTest < Test::Unit::TestCase
55
51
  def test_octave
56
52
  m = MicroMIDI.message
57
53
  msg = m.note "C"
58
- assert_equal(NoteOn, msg.class)
54
+ assert_equal(MIDIMessage::NoteOn, msg.class)
59
55
  assert_equal(36, msg.note)
60
56
  assert_equal(0, msg.channel)
61
57
  assert_equal(100, msg.velocity)
62
-
63
- m.octave 4
58
+
59
+ m.octave 4
64
60
  msg = m.note "C"
65
- assert_equal(NoteOn, msg.class)
61
+ assert_equal(MIDIMessage::NoteOn, msg.class)
66
62
  assert_equal(60, msg.note)
67
63
  assert_equal(0, msg.channel)
68
64
  assert_equal(100, msg.velocity)
69
65
  end
70
-
66
+
71
67
  def test_octave_super_sticky
72
68
  m = MicroMIDI.message
73
69
  m.super_sticky
74
-
70
+
75
71
  msg = m.note "C"
76
- assert_equal(NoteOn, msg.class)
72
+ assert_equal(MIDIMessage::NoteOn, msg.class)
77
73
  assert_equal(36, msg.note)
78
74
  assert_equal(0, msg.channel)
79
75
  assert_equal(100, msg.velocity)
80
-
81
- m.octave 4
76
+
77
+ m.octave 4
82
78
  msg = m.note "C0"
83
- assert_equal(NoteOn, msg.class)
79
+ assert_equal(MIDIMessage::NoteOn, msg.class)
84
80
  assert_equal(12, msg.note)
85
81
  assert_equal(0, msg.channel)
86
82
  assert_equal(100, msg.velocity)
87
-
83
+
88
84
  msg = m.note "D"
89
- assert_equal(NoteOn, msg.class)
85
+ assert_equal(MIDIMessage::NoteOn, msg.class)
90
86
  assert_equal(14, msg.note)
91
87
  assert_equal(0, msg.channel)
92
88
  assert_equal(100, msg.velocity)
@@ -95,38 +91,37 @@ class StickyTest < Test::Unit::TestCase
95
91
  def test_velocity_super_sticky
96
92
  m = MicroMIDI.message
97
93
  m.super_sticky
98
-
94
+
99
95
  msg = m.note "C0"
100
- assert_equal(NoteOn, msg.class)
96
+ assert_equal(MIDIMessage::NoteOn, msg.class)
101
97
  assert_equal(12, msg.note)
102
98
  assert_equal(0, msg.channel)
103
99
  assert_equal(100, msg.velocity)
104
-
105
- m.velocity 10
100
+
101
+ m.velocity 10
106
102
  msg = m.note "C0", :velocity => 20
107
- assert_equal(NoteOn, msg.class)
103
+ assert_equal(MIDIMessage::NoteOn, msg.class)
108
104
  assert_equal(12, msg.note)
109
105
  assert_equal(0, msg.channel)
110
106
  assert_equal(20, msg.velocity)
111
-
107
+
112
108
  msg = m.note "C1"
113
- assert_equal(NoteOn, msg.class)
109
+ assert_equal(MIDIMessage::NoteOn, msg.class)
114
110
  assert_equal(24, msg.note)
115
111
  assert_equal(0, msg.channel)
116
112
  assert_equal(20, msg.velocity)
117
113
  end
118
-
114
+
119
115
  def test_sysex_node
120
116
  m = MicroMIDI.message
121
117
  assert_equal(nil, m.sysex_node)
122
-
118
+
123
119
  node = m.node 0x41, :model_id => 0x42, :device_id => 0x10
124
- assert_equal(SystemExclusive::Node, node.class)
120
+ assert_equal(MIDIMessage::SystemExclusive::Node, node.class)
125
121
  assert_equal(65, node.manufacturer_id)
126
122
  assert_equal(66, node.model_id)
127
123
  assert_equal(16, node.device_id)
128
-
124
+
129
125
  end
130
-
131
- end
132
126
 
127
+ end