nerpin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ include Nerpin
4
+
5
+ describe Controller do
6
+ before do
7
+ @destination = double("CoreMIDI::Destination")
8
+ end
9
+
10
+ subject do
11
+ Controller.new(@destination, Nrpn::Micron)
12
+ end
13
+
14
+ it 'controls the pitch of oscillator 1 with 999' do
15
+ subject.should_receive(:puts).with(15, :v0x06 => 7, :v0x26 => 103)
16
+
17
+ subject.oscillator_1_pitch(999)
18
+ end
19
+
20
+ describe '#puts' do
21
+ it 'sends message with specified value to the destination' do
22
+ @destination.should_receive(:puts).with(0b10110000, 99, anything())
23
+ @destination.should_receive(:puts).with(0b10110000, 98, anything())
24
+ @destination.should_receive(:puts).with(0b10110000, 6, 5)
25
+ @destination.should_receive(:puts).with(0b10110000, 38, 123)
26
+
27
+ subject.puts(15, :v0x06 => 5, :v0x26 => 123)
28
+ end
29
+
30
+ context 'nrpn is lower than 128' do
31
+ it 'sends message to the destination' do
32
+ @destination.should_receive(:puts).with(0b10110000, 99, 0)
33
+ @destination.should_receive(:puts).with(0b10110000, 98, 15)
34
+ @destination.should_receive(:puts).with(0b10110000, 6, anything())
35
+ @destination.should_receive(:puts).with(0b10110000, 38, anything())
36
+
37
+ subject.puts(15, :v0x06 => 0, :v0x26 => 0)
38
+ end
39
+ end
40
+
41
+ context 'nrpn is higher than 127' do
42
+ it 'sends message to the destination' do
43
+ @destination.should_receive(:puts).with(0b10110000, 99, 1)
44
+ @destination.should_receive(:puts).with(0b10110000, 98, 54)
45
+ @destination.should_receive(:puts).with(0b10110000, 6, anything())
46
+ @destination.should_receive(:puts).with(0b10110000, 38, anything())
47
+
48
+ subject.puts(182, :v0x06 => 0, :v0x26 => 0)
49
+ end
50
+ end
51
+ end
52
+
53
+ describe '#nrpns' do
54
+ it 'return NRPNs' do
55
+ subject.nrpns.size.should eql(234)
56
+ subject.nrpns.values.first.should be_a_kind_of(Nrpn::Base)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Nerpin do
4
+ before do
5
+ @destination = double("CoreMIDI::Destination")
6
+ end
7
+
8
+ describe '::Micron' do
9
+ it 'returns a controller for micron' do
10
+ Controller.should_receive(:new).with(@destination, Nrpn::Micron)
11
+
12
+ Nerpin::Micron(@destination)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,66 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ include Nerpin::Nrpn
4
+
5
+ describe Micron do
6
+ subject do
7
+ Micron.new(15, :oscillator_1_pitch, -999, 999)
8
+ end
9
+
10
+ its(:id) { should eql(15) }
11
+ its(:key) { should eql(:oscillator_1_pitch) }
12
+ its(:max) { should eql(999) }
13
+ its(:min) { should eql(-999) }
14
+
15
+ describe '.find_by_key' do
16
+ it 'finds NRPN by key' do
17
+ Micron.find_by_key(:oscillator_1_pitch).should be_an_instance_of(Micron)
18
+ end
19
+ end
20
+
21
+ describe '#initialize' do
22
+ it 'instantiates' do
23
+ subject.should be_an_instance_of(Micron)
24
+ end
25
+ end
26
+
27
+ describe '#value' do
28
+ context 'lower than 128' do
29
+ it do
30
+ subject.value(123).should eql(:v0x06 => 0, :v0x26 => 123)
31
+ end
32
+ end
33
+
34
+ context 'higher than 127' do
35
+ it do
36
+ subject.value(129).should eql(:v0x06 => 1, :v0x26 => 1)
37
+ end
38
+ end
39
+
40
+ context 'zero' do
41
+ it do
42
+ subject.value(0).should eql(:v0x06 => 0, :v0x26 => 0)
43
+ end
44
+ end
45
+
46
+ context 'nagative value, higher than -128' do
47
+ it do
48
+ subject.value(-127).should eql(:v0x06 => 127, :v0x26 => 1)
49
+ end
50
+ end
51
+
52
+ context 'nagative value, lower than -127' do
53
+ it do
54
+ subject.value(-128).should eql(:v0x06 => 126, :v0x26 => 128)
55
+ end
56
+ end
57
+ end
58
+
59
+ describe '#value_at' do
60
+ it 'returns nrpn value at given scaled value' do
61
+ subject.value_at(0.0).should eql(:v0x06 => 120, :v0x26 => 25)
62
+ subject.value_at(0.5).should eql(:v0x06 => 0, :v0x26 => 0)
63
+ subject.value_at(1.0).should eql(:v0x06 => 7, :v0x26 => 103)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ include Nerpin
4
+
5
+ describe Util do
6
+ describe '.parse_spec_for_micron' do
7
+ before do
8
+ @url = 'http://ion-micron-miniak.wikia.com/wiki/Common_FAQ'
9
+
10
+ stub_request(:get, @url).
11
+ to_return(:body => open(File.expand_path(File.dirname(__FILE__) + '/../micron.html')).read)
12
+ end
13
+
14
+ it 'parses the spec for NRPN' do
15
+ parsed = Util.parse_spec_for_micron
16
+
17
+ parsed.should be_an_instance_of(Hash)
18
+ parsed.size.should eql(234)
19
+ parsed[:oscillator_1_pitch].should eql(
20
+ :id => 15,
21
+ :min => -999,
22
+ :max => 999
23
+ )
24
+ parsed[:lfo_1_rate_follow_tempo].should eql(
25
+ :id => 159,
26
+ :min => 0,
27
+ :max => 24
28
+ )
29
+ parsed[:tracking_point_minus1].should eql(
30
+ :id => 136,
31
+ :min => -100,
32
+ :max => 100
33
+ )
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,21 @@
1
+ require 'rspec'
2
+ require 'nerpin'
3
+ require 'webmock/rspec'
4
+
5
+ # This file was generated by the `rspec --init` command. Conventionally, all
6
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
+ # Require this file using `require "spec_helper"` to ensure that it is only
8
+ # loaded once.
9
+ #
10
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nerpin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - youpy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.12'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.12'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: webmock
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: nerpin
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: nokogiri
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A Ruby library to send manufacturer-specific or instrument-specific MIDI
111
+ messages
112
+ email:
113
+ - youpy@buycheapviagraonlinenow.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - Gemfile
121
+ - LICENSE
122
+ - README.md
123
+ - Rakefile
124
+ - data/nrpn/micron.json
125
+ - lib/nerpin.rb
126
+ - lib/nerpin/controller.rb
127
+ - lib/nerpin/nrpn.rb
128
+ - lib/nerpin/nrpn/micron.rb
129
+ - lib/nerpin/util.rb
130
+ - lib/nerpin/version.rb
131
+ - nerpin.gemspec
132
+ - spec/micron.html
133
+ - spec/nerpin/controller_spec.rb
134
+ - spec/nerpin/micron_spec.rb
135
+ - spec/nerpin/nrpn/micron_spec.rb
136
+ - spec/nerpin/util_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: ''
139
+ licenses: []
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ segments:
151
+ - 0
152
+ hash: -2538626082048456367
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ segments:
160
+ - 0
161
+ hash: -2538626082048456367
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 1.8.24
165
+ signing_key:
166
+ specification_version: 3
167
+ summary: A Ruby library to send manufacturer-specific or instrument-specific MIDI
168
+ messages
169
+ test_files:
170
+ - spec/micron.html
171
+ - spec/nerpin/controller_spec.rb
172
+ - spec/nerpin/micron_spec.rb
173
+ - spec/nerpin/nrpn/micron_spec.rb
174
+ - spec/nerpin/util_spec.rb
175
+ - spec/spec_helper.rb