music-transcription 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31245c605d780f4ff342ad6a33f9296a05a1dba1
4
- data.tar.gz: 9be01f0138f712d589178163b62d71439f6e0c4f
3
+ metadata.gz: ef4e1b1a2226ec89a5a829c21bb11776da593edd
4
+ data.tar.gz: 57558652bbb28a3b083ff86c472c039ae1f6edc8
5
5
  SHA512:
6
- metadata.gz: 80e8d7b289839c11bf75ef05e1786d1fa058c43e82f2ae67e3bae242954dca33fbd2eb2013664e481c41c5f1517a3a38664eabe45fdab187a63f7a6c30c0b917
7
- data.tar.gz: dff4b97a87751abafebc8f95364b85b47d453773e838e4c3e896840d2a31b00e32ca6688e444c2a342b96e5b0d7385bba8d602e6055d7e52a2d05d86d5bcdb97
6
+ metadata.gz: e687171913e9eabf15d5987b874f6e2df2a51f8ffde8c0bca96345b036ce4052f5d196758bd226b60e90d4546db61524e604cce5b275bbd9b3e5fd476b0bd6c7
7
+ data.tar.gz: 8148701c9bd8f1251bd57b97a12fd85ef3e962b940707d772ce2d47d5e72c640886c9cee71dd72b488867ac35f584ad020d333912f3449c864a0bd50619d5b62
@@ -5,9 +5,8 @@ include Music::Transcription
5
5
  include Pitches
6
6
  include Articulations
7
7
  include Meters
8
- include Parsing
9
8
 
10
- score = Score.new(FOUR_FOUR,120) do |s|
9
+ score = MeasureScore.new(FOUR_FOUR,Tempo::BPM.new(120)) do |s|
11
10
  s.program = Program.new([0...2, 0...2,2...4,0...2])
12
11
  s.parts["lead"] = Part.new(Dynamics::MF) do |p|
13
12
  riff = "/6Bb3 /4 /12Db4= /6Db4= /36Db4 /36Eb4 /36Db4 /6Ab3 /12Db4 \
@@ -29,5 +28,5 @@ File.open("#{name}.yml", "w") do |file|
29
28
  end
30
29
 
31
30
  File.open("#{name}_packed.yml", "w") do |file|
32
- file.write score.pack.to_yaml
31
+ file.write pack_score(score).to_yaml
33
32
  end
@@ -1,4 +1,4 @@
1
- --- !ruby/object:Music::Transcription::Score
1
+ --- !ruby/object:Music::Transcription::MeasureScore
2
2
  start_meter: !ruby/object:Music::Transcription::Meter
3
3
  beats_per_measure: 4
4
4
  beat_duration: !ruby/object:Rational
@@ -7,8 +7,9 @@ start_meter: !ruby/object:Music::Transcription::Meter
7
7
  measure_duration: !ruby/object:Rational
8
8
  denominator: 1
9
9
  numerator: 1
10
- start_tempo: 120
11
10
  meter_changes: {}
11
+ start_tempo: !ruby/object:Music::Transcription::Tempo::BPM
12
+ value: 120
12
13
  tempo_changes: {}
13
14
  parts:
14
15
  lead: !ruby/object:Music::Transcription::Part
@@ -1,7 +1,5 @@
1
1
  ---
2
- start_meter: 4/4
3
- meter_changes: {}
4
- start_tempo: 120
2
+ start_tempo: 120bpm
5
3
  tempo_changes: {}
6
4
  program:
7
5
  - 0...2
@@ -20,3 +18,6 @@ parts:
20
18
  /6C3 /4 /3Bb2 /4Bb2
21
19
  start_dynamic: 0.5
22
20
  dynamic_changes: {}
21
+ start_meter: 4/4
22
+ meter_changes: {}
23
+ type: Music::Transcription::MeasureScore
@@ -5,9 +5,8 @@ include Music::Transcription
5
5
  include Pitches
6
6
  include Articulations
7
7
  include Meters
8
- include Parsing
9
8
 
10
- score = Score.new(FOUR_FOUR, 120) do |s|
9
+ score = MeasureScore.new(FOUR_FOUR, Tempo::BPM.new(120)) do |s|
11
10
  s.program = Program.new([0...2,0...6])
12
11
  s.parts["bass"] = Part.new(Dynamics::MF) do |p|
13
12
  p.notes = "/4Eb2 /4 /4Bb2 /4 /4Eb2 /8 /8B2 /4Bb2 /4Ab2".to_notes
@@ -23,5 +22,5 @@ File.open("#{name}.yml", "w") do |file|
23
22
  end
24
23
 
25
24
  File.open("#{name}_packed.yml", "w") do |file|
26
- file.write score.pack.to_yaml
25
+ file.write pack_score(score).to_yaml
27
26
  end
@@ -1,4 +1,4 @@
1
- --- !ruby/object:Music::Transcription::Score
1
+ --- !ruby/object:Music::Transcription::MeasureScore
2
2
  start_meter: !ruby/object:Music::Transcription::Meter
3
3
  beats_per_measure: 4
4
4
  beat_duration: !ruby/object:Rational
@@ -7,8 +7,9 @@ start_meter: !ruby/object:Music::Transcription::Meter
7
7
  measure_duration: !ruby/object:Rational
8
8
  denominator: 1
9
9
  numerator: 1
10
- start_tempo: 120
11
10
  meter_changes: {}
11
+ start_tempo: !ruby/object:Music::Transcription::Tempo::BPM
12
+ value: 120
12
13
  tempo_changes: {}
13
14
  parts:
14
15
  bass: !ruby/object:Music::Transcription::Part
@@ -1,7 +1,5 @@
1
1
  ---
2
- start_meter: 4/4
3
- meter_changes: {}
4
- start_tempo: 120
2
+ start_tempo: 120bpm
5
3
  tempo_changes: {}
6
4
  program:
7
5
  - 0...2
@@ -12,3 +10,6 @@ parts:
12
10
  /8F3= /2F3 /4B2 /8 /8Gb3= /2Gb3 /8 /8Gb3= /2Gb3
13
11
  start_dynamic: 0.625
14
12
  dynamic_changes: {}
13
+ start_meter: 4/4
14
+ meter_changes: {}
15
+ type: Music::Transcription::MeasureScore
@@ -5,9 +5,8 @@ include Music::Transcription
5
5
  include Pitches
6
6
  include Articulations
7
7
  include Meters
8
- include Parsing
9
8
 
10
- score = Score.new(FOUR_FOUR, 120) do |s|
9
+ score = MeasureScore.new(FOUR_FOUR, Tempo::BPM.new(120)) do |s|
11
10
  s.program = Program.new([ 0...4.0, 0...4.0 ])
12
11
 
13
12
  s.parts[1] = Part.new(Dynamics::MF) do |p|
@@ -30,5 +29,5 @@ File.open("#{name}.yml", "w") do |file|
30
29
  end
31
30
 
32
31
  File.open("#{name}_packed.yml", "w") do |file|
33
- file.write score.pack.to_yaml
32
+ file.write pack_score(score).to_yaml
34
33
  end
@@ -1,4 +1,4 @@
1
- --- !ruby/object:Music::Transcription::Score
1
+ --- !ruby/object:Music::Transcription::MeasureScore
2
2
  start_meter: !ruby/object:Music::Transcription::Meter
3
3
  beats_per_measure: 4
4
4
  beat_duration: !ruby/object:Rational
@@ -7,8 +7,9 @@ start_meter: !ruby/object:Music::Transcription::Meter
7
7
  measure_duration: !ruby/object:Rational
8
8
  denominator: 1
9
9
  numerator: 1
10
- start_tempo: 120
11
10
  meter_changes: {}
11
+ start_tempo: !ruby/object:Music::Transcription::Tempo::BPM
12
+ value: 120
12
13
  tempo_changes: {}
13
14
  parts:
14
15
  1: !ruby/object:Music::Transcription::Part
@@ -1,7 +1,5 @@
1
1
  ---
2
- start_meter: 4/4
3
- meter_changes: {}
4
- start_tempo: 120
2
+ start_tempo: 120bpm
5
3
  tempo_changes: {}
6
4
  program:
7
5
  - 0...4.0
@@ -17,3 +15,6 @@ parts:
17
15
  /8Bb3 /8Bb3 /8Bb3 /8Bb3 /4C4 /8A3 /8E4 /8=E4 /8=D4 /8C4
18
16
  start_dynamic: 0.625
19
17
  dynamic_changes: {}
18
+ start_meter: 4/4
19
+ meter_changes: {}
20
+ type: Music::Transcription::MeasureScore
@@ -4,9 +4,8 @@ require 'yaml'
4
4
  include Music::Transcription
5
5
  include Pitches
6
6
  include Meters
7
- include Parsing
8
7
 
9
- score = Score.new(FOUR_FOUR, 120) do |s|
8
+ score = MeasureScore.new(FOUR_FOUR, Tempo::BPM.new(120)) do |s|
10
9
  s.program = Program.new([0...4.0, 0...4.0 ])
11
10
 
12
11
  s.parts[1] = Part.new(Dynamics::MF) do |p|
@@ -29,5 +28,5 @@ File.open("#{name}.yml", "w") do |file|
29
28
  end
30
29
 
31
30
  File.open("#{name}_packed.yml", "w") do |file|
32
- file.write score.pack.to_yaml
31
+ file.write pack_score(score).to_yaml
33
32
  end
@@ -1,4 +1,4 @@
1
- --- !ruby/object:Music::Transcription::Score
1
+ --- !ruby/object:Music::Transcription::MeasureScore
2
2
  start_meter: !ruby/object:Music::Transcription::Meter
3
3
  beats_per_measure: 4
4
4
  beat_duration: !ruby/object:Rational
@@ -7,8 +7,9 @@ start_meter: !ruby/object:Music::Transcription::Meter
7
7
  measure_duration: !ruby/object:Rational
8
8
  denominator: 1
9
9
  numerator: 1
10
- start_tempo: 120
11
10
  meter_changes: {}
11
+ start_tempo: !ruby/object:Music::Transcription::Tempo::BPM
12
+ value: 120
12
13
  tempo_changes: {}
13
14
  parts:
14
15
  1: !ruby/object:Music::Transcription::Part
@@ -1,7 +1,5 @@
1
1
  ---
2
- start_meter: 4/4
3
- meter_changes: {}
4
- start_tempo: 120
2
+ start_tempo: 120bpm
5
3
  tempo_changes: {}
6
4
  program:
7
5
  - 0...4.0
@@ -19,3 +17,6 @@ parts:
19
17
  notes: /8 /4G5 /2F5 /4 /4F5 /2Eb5 /4 /4Eb5 /2Eb5 /8 /2Eb5 /2F5
20
18
  start_dynamic: 0.625
21
19
  dynamic_changes: {}
20
+ start_meter: 4/4
21
+ meter_changes: {}
22
+ type: Music::Transcription::MeasureScore
@@ -46,6 +46,7 @@ require 'music-transcription/packing/part_packing'
46
46
  require 'music-transcription/packing/program_packing'
47
47
  require 'music-transcription/packing/note_score_packing'
48
48
  require 'music-transcription/packing/measure_score_packing'
49
+ require 'music-transcription/packing/score_packing'
49
50
 
50
51
  require 'music-transcription/conversion/tempo_conversion'
51
52
  require 'music-transcription/conversion/measure_note_map'
@@ -54,7 +54,7 @@ class MeasureScore < NoteScore
54
54
  end
55
55
 
56
56
  def ==(other)
57
- return super() && @start_meter == other.start_meter &&
57
+ return super(other) && @start_meter == other.start_meter &&
58
58
  @meter_changes == other.meter_changes
59
59
  end
60
60
  end
@@ -0,0 +1,17 @@
1
+ module Music
2
+ module Transcription
3
+
4
+ module_function
5
+ def pack_score score
6
+ packing = score.pack
7
+ packing["type"] = score.class.to_s
8
+ return packing
9
+ end
10
+
11
+ def unpack_score packing
12
+ type = Kernel.const_get(packing["type"])
13
+ type.unpack(packing)
14
+ end
15
+
16
+ end
17
+ end
@@ -2,6 +2,6 @@
2
2
  module Music
3
3
  module Transcription
4
4
  # music-transcription version
5
- VERSION = "0.20.0"
5
+ VERSION = "0.21.0"
6
6
  end
7
7
  end
@@ -0,0 +1,95 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ note_score = NoteScore.new(Tempo::QNPM.new(30)) do |s|
4
+ s.program = Program.new([0...2, 0...2,2...4,0...2])
5
+ s.parts["lead"] = Part.new(Dynamics::MF) do |p|
6
+ riff = "/6Bb3 /4 /12Db4= /6Db4= /36Db4 /36Eb4 /36Db4 /6Ab3 /12Db4 \
7
+ /6Bb3 /4 /12Db4= /4Db4= /8=Db4 /8C4".to_notes
8
+ p.notes = riff + riff.map {|n| n.transpose(2) }
9
+ end
10
+
11
+ s.parts["bass"] = Part.new(Dynamics::MP) do |p|
12
+ riff = "/6Bb2 /4 /3Ab2 /6F2 /12Ab2 \
13
+ /6Bb2 /4 /3Ab2 /4Ab2".to_notes
14
+ p.notes = riff + riff.map {|n| n.transpose(2) }
15
+ end
16
+ end
17
+
18
+ measure_score = MeasureScore.new(FOUR_FOUR,Tempo::BPM.new(120)) do |s|
19
+ s.program = Program.new([0...2, 0...2,2...4,0...2])
20
+ s.parts["lead"] = Part.new(Dynamics::MF) do |p|
21
+ riff = "/6Bb3 /4 /12Db4= /6Db4= /36Db4 /36Eb4 /36Db4 /6Ab3 /12Db4 \
22
+ /6Bb3 /4 /12Db4= /4Db4= /8=Db4 /8C4".to_notes
23
+ p.notes = riff + riff.map {|n| n.transpose(2) }
24
+ end
25
+
26
+ s.parts["bass"] = Part.new(Dynamics::MP) do |p|
27
+ riff = "/6Bb2 /4 /3Ab2 /6F2 /12Ab2 \
28
+ /6Bb2 /4 /3Ab2 /4Ab2".to_notes
29
+ p.notes = riff + riff.map {|n| n.transpose(2) }
30
+ end
31
+ end
32
+
33
+ describe 'pack_score' do
34
+ context 'give a NoteScore' do
35
+ before :all do
36
+ @packing = pack_score(note_score)
37
+ end
38
+
39
+ it 'should produce a Hash' do
40
+ @packing.should be_a Hash
41
+ end
42
+
43
+ it 'should add a "type" key' do
44
+ @packing.should have_key("type")
45
+ end
46
+
47
+ it 'should be otherwise equal to the Hash produced by NoteScore#pack' do
48
+ note_score.pack.each do |k,v|
49
+ @packing.should have_key(k)
50
+ @packing[k].should eq(v)
51
+ end
52
+ end
53
+ end
54
+
55
+ context 'give a MeasureScore' do
56
+ before :all do
57
+ @packing = pack_score(measure_score)
58
+ end
59
+
60
+ it 'should produce a Hash' do
61
+ @packing.should be_a Hash
62
+ end
63
+
64
+ it 'should add a "type" key' do
65
+ @packing.should have_key("type")
66
+ end
67
+
68
+ it 'should be otherwise equal to the Hash produced by MeasureScore#pack' do
69
+ measure_score.pack.each do |k,v|
70
+ @packing.should have_key(k)
71
+ @packing[k].should eq(v)
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ describe 'unpack_score' do
78
+ context 'given packing from NoteScore#pack' do
79
+ it 'should return a NoteScore object equal to original' do
80
+ packing = pack_score(note_score)
81
+ score = unpack_score(packing)
82
+ score.should be_a NoteScore
83
+ score.should eq(note_score)
84
+ end
85
+ end
86
+
87
+ context 'given packing from MeasureScore#pack' do
88
+ it 'should return a NoteScore object equal to original' do
89
+ packing = pack_score(measure_score)
90
+ score = unpack_score(packing)
91
+ score.should be_a MeasureScore
92
+ score.should eq(measure_score)
93
+ end
94
+ end
95
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: music-transcription
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Tunnell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-14 00:00:00.000000000 Z
11
+ date: 2014-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,6 +192,7 @@ files:
192
192
  - lib/music-transcription/packing/note_score_packing.rb
193
193
  - lib/music-transcription/packing/part_packing.rb
194
194
  - lib/music-transcription/packing/program_packing.rb
195
+ - lib/music-transcription/packing/score_packing.rb
195
196
  - lib/music-transcription/parsing/articulation_parsing.rb
196
197
  - lib/music-transcription/parsing/articulation_parsing.treetop
197
198
  - lib/music-transcription/parsing/convenience_methods.rb
@@ -248,6 +249,7 @@ files:
248
249
  - spec/packing/note_score_packing_spec.rb
249
250
  - spec/packing/part_packing_spec.rb
250
251
  - spec/packing/program_packing_spec.rb
252
+ - spec/packing/score_packing_spec.rb
251
253
  - spec/parsing/articulation_parsing_spec.rb
252
254
  - spec/parsing/convenience_methods_spec.rb
253
255
  - spec/parsing/duration_nodes_spec.rb
@@ -313,6 +315,7 @@ test_files:
313
315
  - spec/packing/note_score_packing_spec.rb
314
316
  - spec/packing/part_packing_spec.rb
315
317
  - spec/packing/program_packing_spec.rb
318
+ - spec/packing/score_packing_spec.rb
316
319
  - spec/parsing/articulation_parsing_spec.rb
317
320
  - spec/parsing/convenience_methods_spec.rb
318
321
  - spec/parsing/duration_nodes_spec.rb