music-transcription 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -5,19 +5,7 @@ include Music::Transcription
5
5
 
6
6
  class Samples
7
7
  SAMPLE_PART = Part.new(
8
- :notes => [
9
- Note.new(
10
- :duration => 0.25,
11
- :intervals => [
12
- Interval.new( :pitch => C1 ),
13
- Interval.new( :pitch => D1 ),
14
- ]
15
- )
16
- ],
17
- :loudness_profile => profile(
18
- 0.5, {
19
- 1.0 => linear_change(1.0, 2.0)
20
- }
21
- )
8
+ :notes => [ Note.new(0.25, [ C1, D1 ]) ],
9
+ :loudness_profile => Profile.new(0.5, 1.0 => linear_change(1.0, 2.0))
22
10
  )
23
11
  end
@@ -1,13 +1,31 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Transition do
4
+ describe Transition::Immediate do
5
+ describe '.new' do
6
+ it "should assign duration of 0" do
7
+ t = Transition::Immediate.new()
8
+ t.duration.should eq(0)
9
+ end
10
+ end
11
+ end
4
12
 
5
- context '.new' do
6
- it "should assign duration and type given during construction" do
7
- t = Transition.new(:duration => 1.5, :type => Transition::LINEAR)
8
- t.duration.should eq(1.5)
9
- t.type.should eq(Transition::LINEAR)
13
+ describe Transition::Linear do
14
+ describe '.new' do
15
+ it "should assign duration given" do
16
+ t = Transition::Linear.new(1.5)
17
+ t.duration.should eq(1.5)
18
+ end
10
19
  end
11
20
  end
12
-
13
- end
21
+
22
+ describe Transition::Immediate do
23
+ describe '.new' do
24
+ it "should assign duration and abruptness given" do
25
+ t = Transition::Sigmoid.new(1.2, 0.4)
26
+ t.duration.should eq(1.2)
27
+ t.abruptness.should eq(0.4)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -4,14 +4,14 @@ describe ValueChange do
4
4
 
5
5
  context '.new' do
6
6
  it "should assign offset, value, and duration given during construction" do
7
- event = ValueChange.new(:value => 0)
7
+ event = ValueChange.new(0)
8
8
  event.value.should eq(0)
9
- event.transition.type.should eq(Transition::IMMEDIATE)
9
+ event.transition.class.should eq(Transition::Immediate)
10
10
  event.transition.duration.should eq(0)
11
11
 
12
- event = ValueChange.new(:value => 2, :transition => linear(3))
12
+ event = ValueChange.new(2, Transition::Linear.new(3))
13
13
  event.value.should eq(2)
14
- event.transition.type.should eq(Transition::LINEAR)
14
+ event.transition.class.should eq(Transition::Linear)
15
15
  event.transition.duration.should eq(3)
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: music-transcription
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,32 +9,32 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-07 00:00:00.000000000 Z
12
+ date: 2013-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: hashmake
15
+ name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
21
+ version: '1.5'
22
+ type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: '1.5'
30
30
  - !ruby/object:Gem::Dependency
31
- name: bundler
31
+ name: rubygems-bundler
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '1.0'
37
+ version: '1.4'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '1.0'
45
+ version: '1.4'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0.8'
53
+ version: '10.1'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.8'
61
+ version: '10.1'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rspec
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '2.4'
69
+ version: '2.14'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '2.4'
77
+ version: '2.14'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: yard
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +126,7 @@ dependencies:
126
126
  description: ! "The goal of music-transcription is the abstract representation of
127
127
  standard \nmusical features such as pitch, note, loudness, tempo, etc. Establishing\na
128
128
  common representation enables composition and performance.\n"
129
- email: jamestunnell@lavabit.com
129
+ email: jamestunnell@gmail.com
130
130
  executables:
131
131
  - transcribe
132
132
  extensions: []
@@ -135,6 +135,7 @@ files:
135
135
  - .document
136
136
  - .gitignore
137
137
  - .rspec
138
+ - .ruby-version
138
139
  - .yardopts
139
140
  - ChangeLog.rdoc
140
141
  - Gemfile
@@ -143,9 +144,8 @@ files:
143
144
  - Rakefile
144
145
  - bin/transcribe
145
146
  - lib/music-transcription.rb
146
- - lib/music-transcription/arrangement.rb
147
- - lib/music-transcription/instrument_config.rb
148
- - lib/music-transcription/interval.rb
147
+ - lib/music-transcription/accent.rb
148
+ - lib/music-transcription/errors.rb
149
149
  - lib/music-transcription/link.rb
150
150
  - lib/music-transcription/note.rb
151
151
  - lib/music-transcription/part.rb
@@ -177,8 +177,6 @@ files:
177
177
  - samples/arrangements/slur_test.yml
178
178
  - samples/arrangements/song1.yml
179
179
  - samples/arrangements/song2.yml
180
- - spec/instrument_config_spec.rb
181
- - spec/interval_spec.rb
182
180
  - spec/link_spec.rb
183
181
  - spec/musicality_spec.rb
184
182
  - spec/note_spec.rb
@@ -205,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
203
  version: '0'
206
204
  segments:
207
205
  - 0
208
- hash: -4504170498906695205
206
+ hash: 4349874836488789101
209
207
  required_rubygems_version: !ruby/object:Gem::Requirement
210
208
  none: false
211
209
  requirements:
@@ -214,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
212
  version: '0'
215
213
  segments:
216
214
  - 0
217
- hash: -4504170498906695205
215
+ hash: 4349874836488789101
218
216
  requirements: []
219
217
  rubyforge_project:
220
218
  rubygems_version: 1.8.23
@@ -223,8 +221,6 @@ specification_version: 3
223
221
  summary: Classes for representing music notational features like pitch, note, loudness,
224
222
  tempo, etc.
225
223
  test_files:
226
- - spec/instrument_config_spec.rb
227
- - spec/interval_spec.rb
228
224
  - spec/link_spec.rb
229
225
  - spec/musicality_spec.rb
230
226
  - spec/note_spec.rb
@@ -1,31 +0,0 @@
1
- module Music
2
- module Transcription
3
-
4
- # Contains a Score object, and also instrument configurations to be assigned to
5
- # score parts.
6
- class Arrangement
7
- include Hashmake::HashMakeable
8
-
9
- # specifies which hashed args can be used for initialize.
10
- ARG_SPECS = {
11
- :score => arg_spec(:reqd => true, :type => Score),
12
- :instrument_configs => arg_spec_hash(:reqd => false, :type => InstrumentConfig),
13
- }
14
-
15
- attr_reader :score, :instrument_configs
16
-
17
- def initialize args
18
- hash_make args, Arrangement::ARG_SPECS
19
- end
20
-
21
- # Assign a new score.
22
- # @param [Score] score The new score.
23
- # @raise [ArgumentError] if score is not a Score.
24
- def score= score
25
- Arrangement::ARG_SPECS[:score].validate_value score
26
- @score = score
27
- end
28
- end
29
-
30
- end
31
- end
@@ -1,38 +0,0 @@
1
- module Music
2
- module Transcription
3
-
4
- # Contains all the information needed to create the instrument plugin, configure
5
- # initial settings, and any settings changes.
6
- #
7
- # @author James Tunnell
8
- class InstrumentConfig
9
- include Hashmake::HashMakeable
10
-
11
- attr_reader :plugin_name, :initial_settings, :setting_changes
12
-
13
- # hashed-arg specs (for hash-makeable idiom)
14
- ARG_SPECS = {
15
- :plugin_name => arg_spec(:reqd => true, :type => String),
16
- :initial_settings => arg_spec(:reqd => false, :default => ->(){ {} }, :validator => ->(a){ a.is_a?(String) || a.is_a?(Array) || a.is_a?(Hash)} ),
17
- :setting_changes => arg_spec_hash(:reqd => false, :type => Hash)
18
- }
19
-
20
- # A new instance of InstrumentConfig.
21
- # @param [Hash] args Hashed arguments. Required key is :plugin_name (String).
22
- # Optional key is :initial_settings and setting_changes.
23
- def initialize args={}
24
- hash_make args, InstrumentConfig::ARG_SPECS
25
-
26
- @setting_changes.each do |offset, hash|
27
- hash.each do |key, val|
28
- # replace plain values with immediate value changes
29
- unless val.is_a?(ValueChange)
30
- hash[keys] = immediate_change(val)
31
- end
32
- end
33
- end
34
- end
35
- end
36
-
37
- end
38
- end
@@ -1,66 +0,0 @@
1
- module Music
2
- module Transcription
3
-
4
- # Describes a pitch (for one note) that can be linked to a pitch in another note.
5
- #
6
- # @author James Tunnell
7
- #
8
- # @!attribute [rw] pitch
9
- # @return [Pitch] The pitch of the note.
10
- #
11
- # @!attribute [rw] link
12
- # @return [Link] Shows how the current note is related to a following note.
13
- #
14
- class Interval
15
- include Hashmake::HashMakeable
16
- attr_reader :pitch, :link
17
-
18
- # hashed-arg specs (for hash-makeable idiom)
19
- ARG_SPECS = {
20
- :pitch => arg_spec(:type => Pitch, :reqd => true),
21
- :link => arg_spec(:type => Link, :reqd => false, :default => ->(){ Link.new } ),
22
- }
23
-
24
- def initialize args
25
- hash_make args
26
- end
27
-
28
- # Return true if the @link relationship is not NONE.
29
- def linked?
30
- @link.relationship != Link::RELATIONSHIP_NONE
31
- end
32
-
33
- # Compare the equality of another Interval object.
34
- def == other
35
- return (@pitch == other.pitch) && (@link == other.link)
36
- end
37
-
38
- # Set the note pitch.
39
- # @param [Pitch] pitch The pitch to use.
40
- # @raise [ArgumentError] if pitch is not a Pitch.
41
- def pitch= pitch
42
- ARG_SPECS[:pitch].validate_value pitch
43
- @pitch = pitch
44
- end
45
-
46
- # Setup the relationship to a following note.
47
- # @param [Link] link The Link object to assign.
48
- def link= link
49
- ARG_SPECS[:link].validate_value link
50
- @link = link
51
- end
52
-
53
- # Produce an identical Note object.
54
- def clone
55
- Interval.new(:pitch => @pitch, :link => @link.clone)
56
- end
57
- end
58
-
59
- module_function
60
-
61
- def interval pitch, link = Link.new
62
- Interval.new(:pitch => pitch, :link => link)
63
- end
64
-
65
- end
66
- end
@@ -1,47 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe InstrumentConfig do
4
-
5
- it "should assign the given name" do
6
- cfg = InstrumentConfig.new :plugin_name => "MyPluginName"
7
- cfg.plugin_name.should eq("MyPluginName")
8
- end
9
-
10
- it "should assign the given initial settings" do
11
- settings = {
12
- :volume => 0.5,
13
- :gain => 0.75,
14
- }
15
- cfg = InstrumentConfig.new :plugin_name => "MyPluginName", :initial_settings => settings
16
- cfg.initial_settings.should eq(settings)
17
- end
18
-
19
- it "should allow a String to be given as initial settings" do
20
- settings = "preset A"
21
- cfg = InstrumentConfig.new :plugin_name => "MyPluginName", :initial_settings => settings
22
- cfg.initial_settings.should eq(settings)
23
- end
24
-
25
- it "should allow an Array to be given as initial settings" do
26
- settings = ["preset A","preset B"]
27
- cfg = InstrumentConfig.new :plugin_name => "MyPluginName", :initial_settings => settings
28
- cfg.initial_settings.should eq(settings)
29
- end
30
-
31
- it "should assign each of the given setting changes" do
32
- setting_changes = {
33
- 1.0 => {
34
- :volume => ValueChange.new(:value => 0.5),
35
- :gain => ValueChange.new(:value => 0.75),
36
- },
37
- 4.0 => {
38
- :volume => ValueChange.new(:value => 0.1),
39
- :gain => ValueChange.new(:value => 0.1),
40
- }
41
- }
42
-
43
- cfg = InstrumentConfig.new :plugin_name => "MyPluginName", :setting_changes => setting_changes
44
- cfg.setting_changes.should eq(setting_changes)
45
- end
46
-
47
- end
@@ -1,38 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Interval do
4
- before :all do
5
- @pitch = C4
6
- end
7
-
8
- context '.new' do
9
- it "should assign :pitch parameter given during construction" do
10
- interval = Interval.new :pitch => @pitch
11
- interval.pitch.should eq(@pitch)
12
- end
13
-
14
- it "should assign :link parameter if given during construction" do
15
- link = Link.new(:relationship => Link::RELATIONSHIP_TIE, :target_pitch => @pitch)
16
- interval = Interval.new :pitch => @pitch, :link => link
17
- interval.link.should eq(link)
18
- end
19
- end
20
-
21
- context '#pitch=' do
22
- it "should assign pitch" do
23
- interval = Interval.new :pitch => @pitch
24
- interval.pitch = Gb4
25
- interval.pitch.should eq Gb4
26
- end
27
- end
28
-
29
- context '#link=' do
30
- it "should assign link" do
31
- link = Link.new(:relationship => Link::RELATIONSHIP_SLUR, :target_pitch => G2)
32
- interval = Interval.new :pitch => @pitch
33
- interval.link = link
34
- interval.link.should eq(link)
35
- end
36
- end
37
-
38
- end