midi-message 0.3.2 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +2 -2
- data/README.md +120 -0
- data/lib/midi-message/channel_message.rb +67 -124
- data/lib/midi-message/constant.rb +0 -3
- data/lib/midi-message/message.rb +204 -0
- data/lib/midi-message/note_message.rb +16 -46
- data/lib/midi-message/short_message.rb +45 -29
- data/lib/midi-message/system_exclusive.rb +43 -103
- data/lib/midi-message/system_message.rb +7 -53
- data/lib/midi-message/type_conversion.rb +11 -11
- data/lib/midi-message.rb +13 -24
- data/test/{test_constants.rb → constants_test.rb} +0 -0
- data/test/{test_context.rb → context_test.rb} +0 -0
- data/test/{test_mutability.rb → mutability_test.rb} +0 -0
- data/test/{test_parser.rb → parser_test.rb} +0 -0
- data/test/{test_short_message.rb → short_message_test.rb} +0 -0
- data/test/{test_system_exclusive.rb → system_exclusive_test.rb} +0 -0
- data/test/{test_system_message.rb → system_message_test.rb} +0 -0
- metadata +22 -33
- data/README.rdoc +0 -100
- data/TODO +0 -0
- data/lib/midi-message/event/note.rb +0 -31
- data/lib/midi-message/process/filter.rb +0 -63
- data/lib/midi-message/process/limit.rb +0 -36
- data/lib/midi-message/process/processor.rb +0 -39
- data/lib/midi-message/process/transpose.rb +0 -30
- data/test/test_filter.rb +0 -115
- data/test/test_limit.rb +0 -46
- data/test/test_note_event.rb +0 -32
- data/test/test_processor.rb +0 -19
- data/test/test_transpose.rb +0 -39
data/README.rdoc
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
= MIDI Message
|
2
|
-
|
3
|
-
{pic}[http://img208.imageshack.us/img208/5623/mks80small.jpg]
|
4
|
-
|
5
|
-
MIDI messages, objectified in Ruby
|
6
|
-
|
7
|
-
== Features
|
8
|
-
|
9
|
-
* Flexible API to accommodate various sources and destinations of MIDI data
|
10
|
-
* Simple OO approach to System Exclusive data and devices
|
11
|
-
* {YAML dictionary of MIDI constants}[https://github.com/arirusso/midi-message/blob/master/lib/midi.yml]
|
12
|
-
|
13
|
-
== Install
|
14
|
-
|
15
|
-
gem install midi-message
|
16
|
-
|
17
|
-
== Usage
|
18
|
-
|
19
|
-
require 'midi-message'
|
20
|
-
|
21
|
-
include MIDIMessage
|
22
|
-
|
23
|
-
==== Basic Messages
|
24
|
-
|
25
|
-
There are a few ways to create a new MIDI message. Here are some examples
|
26
|
-
|
27
|
-
NoteOn.new(0, 64, 64)
|
28
|
-
|
29
|
-
NoteOn["E4"].new(0, 100)
|
30
|
-
|
31
|
-
with(:channel => 0, :velocity => 100) { note_on("E4") }
|
32
|
-
|
33
|
-
Those expressions all evaluate to the same object
|
34
|
-
|
35
|
-
#<MIDIMessage::NoteOn:0x9c1c240
|
36
|
-
@channel=0,
|
37
|
-
@data=[64, 64],
|
38
|
-
@name="E4",
|
39
|
-
@note=64,
|
40
|
-
@status=[9, 0],
|
41
|
-
@velocity=64,
|
42
|
-
@verbose_name="Note On: E4">
|
43
|
-
|
44
|
-
==== SysEx Messages
|
45
|
-
|
46
|
-
As with any kind of message, you can begin with raw data
|
47
|
-
|
48
|
-
SystemExclusive.new(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
49
|
-
|
50
|
-
Or in a more object oriented way
|
51
|
-
|
52
|
-
synth = SystemExclusive::Node.new(0x41, :model_id => 0x42, :device_id => 0x10)
|
53
|
-
|
54
|
-
SystemExclusive::Command.new([0x40, 0x7F, 0x00], 0x00, :node => synth)
|
55
|
-
|
56
|
-
A Node represents a device that you're sending a message to (eg. your Yamaha DX7 is a Node). Sysex messages can either be a Command or Request
|
57
|
-
|
58
|
-
You can use the Node to instantiate a message
|
59
|
-
|
60
|
-
synth.command([0x40, 0x7F, 0x00], 0x00)
|
61
|
-
|
62
|
-
One way or another, you will wind up with a pair of objects like this
|
63
|
-
|
64
|
-
#<MIDIMessage::SystemExclusive::Command:0x9c1e57c
|
65
|
-
@address=[64, 0, 127],
|
66
|
-
@checksum=[65],
|
67
|
-
@data=[0],
|
68
|
-
@node=
|
69
|
-
#<MIDIMessage::SystemExclusive::Node:0x9c1e5a4
|
70
|
-
@device_id=16,
|
71
|
-
@manufacturer_id=65,
|
72
|
-
@model_id=66>>
|
73
|
-
|
74
|
-
==== Parsing
|
75
|
-
|
76
|
-
The parse method will take any valid message data and return the object representation
|
77
|
-
|
78
|
-
MIDIMessage.parse(0x90, 0x40, 0x40)
|
79
|
-
|
80
|
-
#<MIDIMessage::NoteOn:0x9c1c240 ..>
|
81
|
-
|
82
|
-
MIDIMessage.parse(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
83
|
-
|
84
|
-
#<MIDIMessage::SystemExclusive::Command:0x9c1e57c ..>
|
85
|
-
|
86
|
-
Check out {nibbler}[http://github.com/arirusso/nibbler] for more advanced parsing
|
87
|
-
|
88
|
-
== API Documentation
|
89
|
-
|
90
|
-
* {rdoc}[http://rubydoc.info/github/arirusso/midi-message]
|
91
|
-
|
92
|
-
== Author
|
93
|
-
|
94
|
-
* {Ari Russo}[http://github.com/arirusso] <ari.russo at gmail.com>
|
95
|
-
|
96
|
-
== License
|
97
|
-
|
98
|
-
Apache 2.0, See the file LICENSE
|
99
|
-
|
100
|
-
Copyright (c) 2011 Ari Russo
|
data/TODO
DELETED
File without changes
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
module MIDIMessage
|
3
|
-
|
4
|
-
module Event
|
5
|
-
|
6
|
-
# an Event::Note is a pairing of a MIDI NoteOn and NoteOff message
|
7
|
-
# has a length that corresponds to sequencer ticks
|
8
|
-
class Note
|
9
|
-
|
10
|
-
extend Forwardable
|
11
|
-
|
12
|
-
attr_reader :start,
|
13
|
-
:finish,
|
14
|
-
:length
|
15
|
-
|
16
|
-
alias_method :duration, :length
|
17
|
-
|
18
|
-
def_delegators :start, :note
|
19
|
-
|
20
|
-
def initialize(start_message, duration, options = {})
|
21
|
-
@start = start_message
|
22
|
-
@length = duration
|
23
|
-
|
24
|
-
@finish = options[:finish] || start_message.to_note_off
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
module MIDIMessage
|
4
|
-
|
5
|
-
module Process
|
6
|
-
|
7
|
-
# Use the Filter superclass when you need a multi-band filter
|
8
|
-
class Filter
|
9
|
-
|
10
|
-
include Processor
|
11
|
-
|
12
|
-
attr_reader :bandwidth, :property, :reject
|
13
|
-
|
14
|
-
def initialize(prop, bandwidth, options = {})
|
15
|
-
@bandwidth = [bandwidth].flatten
|
16
|
-
@property = prop
|
17
|
-
@reject = options[:reject] || false
|
18
|
-
|
19
|
-
initialize_processor(options)
|
20
|
-
end
|
21
|
-
|
22
|
-
def process_single(message)
|
23
|
-
val = message.send(@property)
|
24
|
-
result = @bandwidth.map do |bw|
|
25
|
-
case bw
|
26
|
-
when Range then val >= bw.min && val <= bw.max ? message : nil
|
27
|
-
when Numeric then val == bw ? message : nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
result.include?(message) ^ @reject ? message : nil
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
class LowPassFilter < Filter
|
36
|
-
def initialize(prop, max, options = {})
|
37
|
-
super(prop, (0..max), options)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class HighPassFilter < Filter
|
42
|
-
def initialize(prop, min, options = {})
|
43
|
-
super(prop, (min..127), options)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class BandPassFilter < Filter
|
48
|
-
def initialize(prop, accept_range, options = {})
|
49
|
-
options[:reject] = false
|
50
|
-
super(prop, accept_range, options)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class BandRejectFilter < Filter
|
55
|
-
def initialize(prop, reject_range, options = {})
|
56
|
-
options[:reject] = true
|
57
|
-
super(prop, reject_range, options)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
NotchFilter = BandRejectFilter
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
module MIDIMessage
|
4
|
-
|
5
|
-
module Process
|
6
|
-
|
7
|
-
class Limit
|
8
|
-
|
9
|
-
include Processor
|
10
|
-
|
11
|
-
attr_reader :property, :limit_to
|
12
|
-
alias_method :range, :limit_to
|
13
|
-
|
14
|
-
def initialize(prop, limit_to, options = {})
|
15
|
-
@limit_to = limit_to
|
16
|
-
@property = prop
|
17
|
-
|
18
|
-
initialize_processor(options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def process_single(message)
|
22
|
-
val = message.send(@property)
|
23
|
-
if @limit_to.kind_of?(Range)
|
24
|
-
message.send("#{@property}=", @limit_to.min) if val < @limit_to.min
|
25
|
-
message.send("#{@property}=", @limit_to.max) if val > @limit_to.max
|
26
|
-
elsif @limit_to.kind_of?(Numeric)
|
27
|
-
message.send("#{@property}=", @limit_to)
|
28
|
-
end
|
29
|
-
message
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
module MIDIMessage
|
4
|
-
|
5
|
-
module Process
|
6
|
-
|
7
|
-
module Processor
|
8
|
-
|
9
|
-
def self.included(base)
|
10
|
-
base.extend(ClassMethods)
|
11
|
-
base.send(:attr_reader, :name)
|
12
|
-
end
|
13
|
-
|
14
|
-
def process(messages = nil)
|
15
|
-
messages = @message unless @message.nil?
|
16
|
-
result = [messages].flatten.map { |message| process_single(message) }
|
17
|
-
result.kind_of?(Array) && result.size == 1 ? result.first : result
|
18
|
-
end
|
19
|
-
|
20
|
-
module ClassMethods
|
21
|
-
|
22
|
-
def process(msg, *a, &block)
|
23
|
-
new(*a).process(msg, &block)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def initialize_processor(options)
|
31
|
-
@message = options[:message]
|
32
|
-
@name = options[:name]
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
module MIDIMessage
|
4
|
-
|
5
|
-
module Process
|
6
|
-
|
7
|
-
class Transpose
|
8
|
-
|
9
|
-
include Processor
|
10
|
-
|
11
|
-
attr_reader :factor, :property
|
12
|
-
|
13
|
-
def initialize(prop, factor, options = {})
|
14
|
-
@factor = factor
|
15
|
-
@property = prop
|
16
|
-
|
17
|
-
initialize_processor(options)
|
18
|
-
end
|
19
|
-
|
20
|
-
def process_single(message)
|
21
|
-
val = message.send(@property)
|
22
|
-
message.send("#{@property}=", val + @factor)
|
23
|
-
message
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/test/test_filter.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class FilterTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include MIDIMessage
|
8
|
-
include MIDIMessage::Process
|
9
|
-
include TestHelper
|
10
|
-
|
11
|
-
def test_high_pass_note_reject
|
12
|
-
msg = MIDIMessage::NoteOn["C0"].new(0, 100)
|
13
|
-
assert_equal(12, msg.note)
|
14
|
-
outp = HighPassFilter.new(:note, 20).process(msg)
|
15
|
-
assert_equal(nil, outp)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_high_pass_note_accept
|
19
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
20
|
-
assert_equal(60, msg.note)
|
21
|
-
outp = HighPassFilter.new(:note, 20).process(msg)
|
22
|
-
assert_equal(msg, outp)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_low_pass_note_reject
|
26
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
27
|
-
assert_equal(60, msg.note)
|
28
|
-
outp = LowPassFilter.new(:note, 50).process(msg)
|
29
|
-
assert_equal(nil, outp)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_low_pass_note_accept
|
33
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
34
|
-
assert_equal(60, msg.note)
|
35
|
-
outp = LowPassFilter.new(:note, 100).process(msg)
|
36
|
-
assert_equal(msg, outp)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_band_pass_note_reject
|
40
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
41
|
-
assert_equal(60, msg.note)
|
42
|
-
outp = BandPassFilter.new(:note, (20..50)).process(msg)
|
43
|
-
assert_equal(nil, outp)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_band_pass_note_accept
|
47
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
48
|
-
assert_equal(60, msg.note)
|
49
|
-
outp = BandPassFilter.new(:note, (20..100)).process(msg)
|
50
|
-
assert_equal(msg, outp)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_band_reject_note_reject
|
54
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
55
|
-
assert_equal(60, msg.note)
|
56
|
-
outp = NotchFilter.new(:note, (20..70)).process(msg)
|
57
|
-
assert_equal(nil, outp)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_band_reject_note_accept
|
61
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
62
|
-
assert_equal(60, msg.note)
|
63
|
-
outp = NotchFilter.new(:note, (20..50)).process(msg)
|
64
|
-
assert_equal(msg, outp)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_multiband_note_reject
|
68
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
69
|
-
assert_equal(60, msg.note)
|
70
|
-
outp = Filter.new(:note, [(20..30), (40..50)]).process(msg)
|
71
|
-
assert_equal(nil, outp)
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_multiband_note_accept
|
75
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
76
|
-
assert_equal(60, msg.note)
|
77
|
-
outp = Filter.new(:note, [(20..30), (50..70)]).process(msg)
|
78
|
-
assert_equal(msg, outp)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_multinotch_note_reject
|
82
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
83
|
-
assert_equal(60, msg.note)
|
84
|
-
outp = Filter.new(:note, [(20..30), (55..65)], :reject => true).process(msg)
|
85
|
-
assert_equal(nil, outp)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_multinotch_note_accept
|
89
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
90
|
-
assert_equal(60, msg.note)
|
91
|
-
outp = Filter.new(:note, [(20..30), (40..50)], :reject => true).process(msg)
|
92
|
-
assert_equal(msg, outp)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_numeric_note_accept
|
96
|
-
msg1 = MIDIMessage::NoteOn["C4"].new(0, 100)
|
97
|
-
msg2 = MIDIMessage::NoteOn["C5"].new(0, 100)
|
98
|
-
f = Filter.new(:note, 60)
|
99
|
-
outp = f.process(msg1)
|
100
|
-
assert_equal(msg1, outp)
|
101
|
-
outp = f.process(msg2)
|
102
|
-
assert_equal(nil, outp)
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_numeric_note_reject
|
106
|
-
msg1 = MIDIMessage::NoteOn["C4"].new(0, 100)
|
107
|
-
msg2 = MIDIMessage::NoteOn["C5"].new(0, 100)
|
108
|
-
f = Filter.new(:note, 60, :reject => true)
|
109
|
-
outp = f.process(msg1)
|
110
|
-
assert_equal(nil, outp)
|
111
|
-
outp = f.process(msg2)
|
112
|
-
assert_equal(msg2, outp)
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
data/test/test_limit.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class LimitTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include MIDIMessage
|
8
|
-
include MIDIMessage::Process
|
9
|
-
include TestHelper
|
10
|
-
|
11
|
-
def test_numeric_range
|
12
|
-
msg = MIDIMessage::NoteOn["C0"].new(0, 100)
|
13
|
-
assert_equal(12, msg.note)
|
14
|
-
Limit.new(:note, 30).process(msg)
|
15
|
-
assert_equal(30, msg.note)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_low_note
|
19
|
-
msg = MIDIMessage::NoteOn["C0"].new(0, 100)
|
20
|
-
assert_equal(12, msg.note)
|
21
|
-
Limit.new(:note, (20..50)).process(msg)
|
22
|
-
assert_equal(20, msg.note)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_high_note
|
26
|
-
msg = MIDIMessage::NoteOn["C6"].new(0, 100)
|
27
|
-
assert_equal(84, msg.note)
|
28
|
-
Limit.new(:note, (20..50)).process(msg)
|
29
|
-
assert_equal(50, msg.note)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_low_velocity
|
33
|
-
msg = MIDIMessage::NoteOn["C0"].new(0, 10)
|
34
|
-
assert_equal(10, msg.velocity)
|
35
|
-
Limit.new(:velocity, (30..110)).process(msg)
|
36
|
-
assert_equal(30, msg.velocity)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_high_velocity
|
40
|
-
msg = MIDIMessage::NoteOn["C6"].new(0, 120)
|
41
|
-
assert_equal(120, msg.velocity)
|
42
|
-
Limit.new(:velocity, (25..75)).process(msg)
|
43
|
-
assert_equal(75, msg.velocity)
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
data/test/test_note_event.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class NoteEventTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include MIDIMessage
|
8
|
-
include TestHelper
|
9
|
-
|
10
|
-
def test_create_event
|
11
|
-
msg = NoteOn.new(0, 0x40, 0x40)
|
12
|
-
event = Event::Note.new(msg, 10)
|
13
|
-
assert_equal(msg, event.start)
|
14
|
-
assert_equal(10, event.duration)
|
15
|
-
assert_equal(NoteOff, event.finish.class)
|
16
|
-
assert_equal(msg.note, event.finish.note)
|
17
|
-
assert_equal(msg.note, event.note)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_override_finish
|
21
|
-
msg = NoteOn.new(0, 0x40, 0x40)
|
22
|
-
msg2 = NoteOff.new(0, 0x40, 127)
|
23
|
-
event = Event::Note.new(msg, 5, :finish => msg2)
|
24
|
-
assert_equal(msg, event.start)
|
25
|
-
assert_equal(5, event.duration)
|
26
|
-
assert_equal(0x40, event.start.velocity)
|
27
|
-
assert_equal(NoteOff, event.finish.class)
|
28
|
-
assert_equal(0x40, event.finish.note)
|
29
|
-
assert_equal(127, event.finish.velocity)
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/test/test_processor.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class ProcessorTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include MIDIMessage
|
8
|
-
include MIDIMessage::Process
|
9
|
-
include TestHelper
|
10
|
-
|
11
|
-
def test_class_method
|
12
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
13
|
-
assert_equal(60, msg.note)
|
14
|
-
Transpose.process(msg, :note, 5)
|
15
|
-
assert_equal(65, msg.note)
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
end
|
data/test/test_transpose.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class TransposeTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
include MIDIMessage
|
8
|
-
include MIDIMessage::Process
|
9
|
-
include TestHelper
|
10
|
-
|
11
|
-
def test_transpose_note_up
|
12
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
13
|
-
assert_equal(60, msg.note)
|
14
|
-
Transpose.new(:note, 5).process(msg)
|
15
|
-
assert_equal(65, msg.note)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_transpose_velocity_up
|
19
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 82)
|
20
|
-
assert_equal(82, msg.velocity)
|
21
|
-
Transpose.new(:velocity, 10).process(msg)
|
22
|
-
assert_equal(92, msg.velocity)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_transpose_note_down
|
26
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 100)
|
27
|
-
assert_equal(60, msg.note)
|
28
|
-
Transpose.new(:note, -5).process(msg)
|
29
|
-
assert_equal(55, msg.note)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_transpose_velocity_down
|
33
|
-
msg = MIDIMessage::NoteOn["C4"].new(0, 82)
|
34
|
-
assert_equal(82, msg.velocity)
|
35
|
-
Transpose.new(:velocity, -10).process(msg)
|
36
|
-
assert_equal(72, msg.velocity)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|