musicality 0.11.1 → 0.12.0

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.
Files changed (124) hide show
  1. checksums.yaml +5 -5
  2. data/.coveralls.yml +1 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +4 -0
  5. data/ChangeLog.md +11 -0
  6. data/README.md +3 -0
  7. data/Rakefile +11 -3
  8. data/lib/musicality/composition/model/rhythm.rb +33 -0
  9. data/lib/musicality/composition/model/rhythm_class.rb +30 -0
  10. data/lib/musicality/composition/sequencing/drum_machine/drum_kit.rb +18 -0
  11. data/lib/musicality/composition/sequencing/drum_machine/drum_machine.rb +59 -0
  12. data/lib/musicality/composition/sequencing/drum_machine/drum_parts.rb +21 -0
  13. data/lib/musicality/composition/sequencing/drum_machine/drum_pattern.rb +66 -0
  14. data/lib/musicality/composition/sequencing/drum_machine/drum_patterns/pop_drum_patterns.rb +146 -0
  15. data/lib/musicality/composition/sequencing/note_array.rb +33 -0
  16. data/lib/musicality/composition/sequencing/note_fifo.rb +73 -0
  17. data/lib/musicality/composition/sequencing/sequenceable.rb +9 -0
  18. data/lib/musicality/composition/sequencing/sequencer.rb +35 -0
  19. data/lib/musicality/errors.rb +2 -2
  20. data/lib/musicality/notation/model/dynamics.rb +2 -2
  21. data/lib/musicality/notation/model/key.rb +42 -91
  22. data/lib/musicality/notation/model/keys.rb +35 -34
  23. data/lib/musicality/notation/model/note.rb +31 -9
  24. data/lib/musicality/notation/model/pitch.rb +2 -2
  25. data/lib/musicality/notation/parsing/convenience_methods.rb +23 -12
  26. data/lib/musicality/notation/parsing/duration_parsing.rb +3 -3
  27. data/lib/musicality/notation/parsing/key_parsing.rb +150 -0
  28. data/lib/musicality/notation/parsing/key_parsing.treetop +37 -0
  29. data/lib/musicality/notation/parsing/meter_parsing.rb +3 -3
  30. data/lib/musicality/notation/parsing/numbers/nonnegative_float_parsing.rb +3 -1
  31. data/lib/musicality/notation/parsing/numbers/nonnegative_integer_parsing.rb +1 -0
  32. data/lib/musicality/notation/parsing/numbers/nonnegative_rational_parsing.rb +1 -1
  33. data/lib/musicality/notation/parsing/numbers/positive_float_parsing.rb +4 -1
  34. data/lib/musicality/notation/parsing/numbers/positive_rational_parsing.rb +1 -1
  35. data/lib/musicality/notation/parsing/parseable.rb +13 -17
  36. data/lib/musicality/notation/parsing/pitch_parsing.rb +7 -0
  37. data/lib/musicality/notation/parsing/segment_parsing.rb +3 -0
  38. data/lib/musicality/performance/conversion/note_sequence_extractor.rb +82 -134
  39. data/lib/musicality/performance/model/note_sequence.rb +22 -3
  40. data/lib/musicality/performance/supercollider/performer.rb +2 -2
  41. data/lib/musicality/performance/supercollider/sc_drum_kits.rb +29 -0
  42. data/lib/musicality/performance/supercollider/synthdefs/bass.rb +211 -0
  43. data/lib/musicality/performance/supercollider/synthdefs/claps.rb +80 -0
  44. data/lib/musicality/performance/supercollider/synthdefs/cymbals.rb +57 -0
  45. data/lib/musicality/performance/supercollider/synthdefs/hihats.rb +67 -0
  46. data/lib/musicality/performance/supercollider/synthdefs/kicks.rb +158 -0
  47. data/lib/musicality/performance/supercollider/synthdefs/mario.rb +49 -0
  48. data/lib/musicality/performance/supercollider/{synthdefs.rb → synthdefs/other.rb} +0 -767
  49. data/lib/musicality/performance/supercollider/synthdefs/pianos.rb +46 -0
  50. data/lib/musicality/performance/supercollider/synthdefs/snares.rb +169 -0
  51. data/lib/musicality/performance/supercollider/synthdefs/toms.rb +25 -0
  52. data/lib/musicality/performance/supercollider/synthdefs/volume.rb +20 -0
  53. data/lib/musicality/pitch_class.rb +1 -1
  54. data/lib/musicality/pitch_classes.rb +3 -5
  55. data/lib/musicality/version.rb +1 -1
  56. data/lib/musicality.rb +25 -1
  57. data/musicality.gemspec +3 -2
  58. data/spec/composition/convenience_methods_spec.rb +8 -8
  59. data/spec/composition/generation/random_rhythm_generator_spec.rb +5 -5
  60. data/spec/composition/model/pitch_class_spec.rb +22 -16
  61. data/spec/composition/model/pitch_classes_spec.rb +5 -5
  62. data/spec/composition/model/rhythm_class_spec.rb +42 -0
  63. data/spec/composition/model/rhythm_spec.rb +43 -0
  64. data/spec/composition/model/scale_class_spec.rb +26 -26
  65. data/spec/composition/model/scale_spec.rb +38 -38
  66. data/spec/composition/sequencing/drum_machine/drum_machine_spec.rb +67 -0
  67. data/spec/composition/sequencing/drum_machine/drum_pattern_spec.rb +58 -0
  68. data/spec/composition/sequencing/note_array_spec.rb +94 -0
  69. data/spec/composition/sequencing/note_fifo_spec.rb +183 -0
  70. data/spec/composition/sequencing/sequencer_spec.rb +76 -0
  71. data/spec/composition/util/adding_sequence_spec.rb +33 -33
  72. data/spec/composition/util/compound_sequence_spec.rb +6 -6
  73. data/spec/composition/util/note_generation_spec.rb +34 -34
  74. data/spec/composition/util/probabilities_spec.rb +7 -7
  75. data/spec/composition/util/random_sampler_spec.rb +3 -3
  76. data/spec/composition/util/repeating_sequence_spec.rb +28 -28
  77. data/spec/musicality_spec.rb +1 -1
  78. data/spec/notation/conversion/change_conversion_spec.rb +87 -87
  79. data/spec/notation/conversion/note_time_converter_spec.rb +22 -22
  80. data/spec/notation/conversion/score_conversion_spec.rb +1 -1
  81. data/spec/notation/conversion/score_converter_spec.rb +31 -31
  82. data/spec/notation/conversion/tempo_conversion_spec.rb +11 -11
  83. data/spec/notation/model/change_spec.rb +80 -80
  84. data/spec/notation/model/key_spec.rb +135 -69
  85. data/spec/notation/model/link_spec.rb +27 -27
  86. data/spec/notation/model/meter_spec.rb +28 -28
  87. data/spec/notation/model/note_spec.rb +68 -47
  88. data/spec/notation/model/part_spec.rb +19 -19
  89. data/spec/notation/model/pitch_spec.rb +69 -68
  90. data/spec/notation/model/score_spec.rb +50 -47
  91. data/spec/notation/parsing/articulation_parsing_spec.rb +4 -4
  92. data/spec/notation/parsing/convenience_methods_spec.rb +49 -10
  93. data/spec/notation/parsing/duration_nodes_spec.rb +13 -13
  94. data/spec/notation/parsing/duration_parsing_spec.rb +10 -10
  95. data/spec/notation/parsing/key_parsing_spec.rb +19 -0
  96. data/spec/notation/parsing/link_nodes_spec.rb +7 -7
  97. data/spec/notation/parsing/link_parsing_spec.rb +4 -4
  98. data/spec/notation/parsing/meter_parsing_spec.rb +5 -5
  99. data/spec/notation/parsing/note_node_spec.rb +19 -19
  100. data/spec/notation/parsing/note_parsing_spec.rb +4 -4
  101. data/spec/notation/parsing/numbers/nonnegative_float_spec.rb +8 -8
  102. data/spec/notation/parsing/numbers/nonnegative_integer_spec.rb +2 -2
  103. data/spec/notation/parsing/numbers/nonnegative_rational_spec.rb +1 -1
  104. data/spec/notation/parsing/numbers/positive_float_spec.rb +8 -8
  105. data/spec/notation/parsing/numbers/positive_integer_spec.rb +6 -6
  106. data/spec/notation/parsing/numbers/positive_rational_spec.rb +6 -6
  107. data/spec/notation/parsing/pitch_node_spec.rb +7 -7
  108. data/spec/notation/parsing/pitch_parsing_spec.rb +2 -2
  109. data/spec/notation/parsing/segment_parsing_spec.rb +3 -3
  110. data/spec/notation/util/function_spec.rb +15 -15
  111. data/spec/notation/util/transition_spec.rb +12 -12
  112. data/spec/notation/util/value_computer_spec.rb +35 -36
  113. data/spec/performance/conversion/glissando_converter_spec.rb +24 -24
  114. data/spec/performance/conversion/note_sequence_extractor_spec.rb +39 -39
  115. data/spec/performance/conversion/portamento_converter_spec.rb +23 -23
  116. data/spec/performance/midi/midi_util_spec.rb +41 -41
  117. data/spec/performance/midi/part_sequencer_spec.rb +10 -10
  118. data/spec/performance/midi/score_sequencer_spec.rb +15 -15
  119. data/spec/performance/midi/score_sequencing_spec.rb +2 -2
  120. data/spec/performance/util/optimization_spec.rb +9 -9
  121. data/spec/printing/note_engraving_spec.rb +16 -16
  122. data/spec/printing/score_engraver_spec.rb +5 -5
  123. data/spec/spec_helper.rb +5 -0
  124. metadata +85 -30
@@ -13,53 +13,53 @@ require 'yaml'
13
13
 
14
14
  describe '#initialize' do
15
15
  it 'should assign the given pitch to :target_pitch' do
16
- @obj.target_pitch.should eq(@tgt_pitch)
16
+ expect(@obj.target_pitch).to eq(@tgt_pitch)
17
17
  end
18
18
  end
19
-
19
+
20
20
  describe '#==' do
21
21
  it 'should return true if two links have the same target pitch' do
22
- @obj.should eq(klass.new(@tgt_pitch))
22
+ expect(@obj).to eq(klass.new(@tgt_pitch))
23
23
  end
24
-
24
+
25
25
  it 'should return false if two links do not have the same target pitch' do
26
- @obj.should_not eq(klass.new(@tgt_pitch.transpose(1)))
26
+ expect(@obj).to_not eq(klass.new(@tgt_pitch.transpose(1)))
27
27
  end
28
-
28
+
29
29
  it 'should return false if the link type is different' do
30
- @obj.should_not eq(klass2.new(@tgt_pitch))
30
+ expect(@obj).to_not eq(klass2.new(@tgt_pitch))
31
31
  end
32
32
  end
33
-
33
+
34
34
  describe '#clone' do
35
35
  it 'should return a link equal to original' do
36
- @obj.clone.should eq @obj
36
+ expect(@obj.clone).to eq @obj
37
37
  end
38
38
  end
39
-
39
+
40
40
  describe '#to_yaml' do
41
41
  it 'should produce YAML that can be loaded' do
42
- YAML.load(@obj.to_yaml).should eq @obj
42
+ expect(YAML.load(@obj.to_yaml)).to eq @obj
43
43
  end
44
44
  end
45
45
 
46
46
  describe '#pack' do
47
47
  it 'should produce a Hash' do
48
- @obj.pack.should be_a Hash
48
+ expect(@obj.pack).to be_a Hash
49
49
  end
50
50
  end
51
51
 
52
52
  describe 'unpack' do
53
53
  it 'should produce a Link object equal the original' do
54
54
  obj2 = @obj.class.unpack @obj.pack
55
- obj2.should be_a @obj.class
56
- obj2.should eq @obj
55
+ expect(obj2).to be_a @obj.class
56
+ expect(obj2).to eq @obj
57
57
  end
58
58
  end
59
-
59
+
60
60
  describe '#to_s' do
61
61
  it 'should produce string that include link char and target pitch str' do
62
- @obj.to_s.should eq(link_symbol + @tgt_pitch.to_s)
62
+ expect(@obj.to_s).to eq(link_symbol + @tgt_pitch.to_s)
63
63
  end
64
64
  end
65
65
  end
@@ -72,43 +72,43 @@ describe Link::Tie do
72
72
 
73
73
  describe '#==' do
74
74
  it 'should return true if another Tie object is given' do
75
- @obj.should eq(Link::Tie.new)
75
+ expect(@obj).to eq(Link::Tie.new)
76
76
  end
77
-
77
+
78
78
  it 'should return false if an object of another class is given' do
79
- @obj.should_not eq(5)
79
+ expect(@obj).to_not eq(5)
80
80
  end
81
81
  end
82
-
82
+
83
83
  describe '#clone' do
84
84
  it 'should return a link equal to original' do
85
- @obj.clone.should eq @obj
85
+ expect(@obj.clone).to eq @obj
86
86
  end
87
87
  end
88
-
88
+
89
89
  describe '#to_yaml' do
90
90
  it 'should produce YAML that can be loaded' do
91
- YAML.load(@obj.to_yaml).should eq @obj
91
+ expect(YAML.load(@obj.to_yaml)).to eq @obj
92
92
  end
93
93
  end
94
94
 
95
95
  describe '#pack' do
96
96
  it 'should produce a Hash' do
97
- @obj.pack.should be_a Hash
97
+ expect(@obj.pack).to be_a Hash
98
98
  end
99
99
  end
100
100
 
101
101
  describe 'unpack' do
102
102
  it 'should produce a Link object equal the original' do
103
103
  obj2 = @obj.class.unpack @obj.pack
104
- obj2.should be_a @obj.class
105
- obj2.should eq @obj
104
+ expect(obj2).to be_a @obj.class
105
+ expect(obj2).to eq @obj
106
106
  end
107
107
  end
108
108
 
109
109
  describe '#to_s' do
110
110
  it "should return #{LINK_SYMBOLS[Link::Tie]}" do
111
- @obj.to_s.should eq(LINK_SYMBOLS[Link::Tie])
111
+ expect(@obj.to_s).to eq(LINK_SYMBOLS[Link::Tie])
112
112
  end
113
113
  end
114
114
  end
@@ -6,11 +6,11 @@ describe Meter do
6
6
  it 'should assign beats per measure and beat duration' do
7
7
  [[4,"1/4".to_r],[3,"1/4".to_r],[6,"1/8".to_r]].each do |bpm,bd|
8
8
  m = Meter.new(bpm,bd)
9
- m.beats_per_measure.should eq bpm
10
- m.beat_duration.should eq bd
11
- end
9
+ expect(m.beats_per_measure).to eq bpm
10
+ expect(m.beat_duration).to eq bd
11
+ end
12
12
  end
13
-
13
+
14
14
  it 'should derive measure duration' do
15
15
  {
16
16
  [4,"1/4".to_r] => "1/1".to_r,
@@ -19,68 +19,68 @@ describe Meter do
19
19
  [12,"1/8".to_r] => "12/8".to_r,
20
20
  }.each do |bpm,bd|
21
21
  m = Meter.new(bpm,bd)
22
- m.measure_duration.should eq(bpm*bd)
23
- end
22
+ expect(m.measure_duration).to eq(bpm*bd)
23
+ end
24
24
  end
25
25
  end
26
-
26
+
27
27
  describe '#==' do
28
28
  context 'meters with same beat duration and beats per measure' do
29
29
  it 'should return true' do
30
30
  m1 = Meter.new(4,"1/4".to_r)
31
31
  m2 = Meter.new(4,"1/4".to_r)
32
- m1.should eq m2
32
+ expect(m1).to eq m2
33
33
  end
34
34
  end
35
-
35
+
36
36
  context 'meters with same meausre duration but different beat duration' do
37
37
  it 'should return false' do
38
38
  m1 = Meter.new(4,"1/4".to_r)
39
39
  m2 = Meter.new(2,"1/2".to_r)
40
- m1.should_not eq m2
40
+ expect(m1).to_not eq m2
41
41
  end
42
42
  end
43
43
  end
44
-
44
+
45
45
  describe '#to_yaml' do
46
46
  it 'should produce YAML that can be loaded' do
47
47
  m = Meter.new(4,"1/4".to_r)
48
- YAML.load(m.to_yaml).should eq m
48
+ expect(YAML.load(m.to_yaml)).to eq m
49
49
  end
50
50
  end
51
51
 
52
52
  describe '#pack' do
53
53
  it 'should produce a Hash' do
54
- FOUR_FOUR.pack.should be_a Hash
54
+ expect(FOUR_FOUR.pack).to be_a Hash
55
55
  end
56
56
  end
57
57
 
58
58
  describe 'unpack' do
59
59
  it 'should produce an object equal the original' do
60
60
  m2 = Meter.unpack FOUR_FOUR.pack
61
- m2.should be_a Meter
62
- m2.should eq(FOUR_FOUR)
61
+ expect(m2).to be_a Meter
62
+ expect(m2).to eq(FOUR_FOUR)
63
63
  end
64
64
  end
65
-
65
+
66
66
  describe '#to_s' do
67
67
  context 'beat duration with 1 in denominator' do
68
68
  it 'should return string of fraction: beats_per_measure / beat_duration.denom' do
69
- FOUR_FOUR.to_s.should eq("4/4")
70
- TWO_FOUR.to_s.should eq("2/4")
71
- THREE_FOUR.to_s.should eq("3/4")
72
- TWO_TWO.to_s.should eq("2/2")
69
+ expect(FOUR_FOUR.to_s).to eq("4/4")
70
+ expect(TWO_FOUR.to_s).to eq("2/4")
71
+ expect(THREE_FOUR.to_s).to eq("3/4")
72
+ expect(TWO_TWO.to_s).to eq("2/2")
73
73
  end
74
74
  end
75
-
75
+
76
76
  context 'beat duration with >1 in denominator' do
77
77
  it 'should return beats_per_measure * beat_dur fraction' do
78
- SIX_EIGHT.to_s.should eq("2*3/8")
79
- Meter.new(3,"3/8".to_r).to_s.should eq("3*3/8")
78
+ expect(SIX_EIGHT.to_s).to eq("2*3/8")
79
+ expect(Meter.new(3,"3/8".to_r).to_s).to eq("3*3/8")
80
80
  end
81
81
  end
82
82
  end
83
-
83
+
84
84
  describe '#valid?' do
85
85
  {
86
86
  '4/4 meter' => [4,'1/4'.to_r],
@@ -91,11 +91,11 @@ describe Meter do
91
91
  }.each do |context_str,args|
92
92
  context context_str do
93
93
  it 'should return true' do
94
- Meter.new(*args).should be_valid
94
+ expect(Meter.new(*args)).to be_valid
95
95
  end
96
96
  end
97
97
  end
98
-
98
+
99
99
  {
100
100
  'non-integer positive beats per measure' => [4.0,"1/4".to_r],
101
101
  'integer negative beats per measure' => [-1,"1/4".to_r],
@@ -104,9 +104,9 @@ describe Meter do
104
104
  }.each do |context_str,args|
105
105
  context context_str do
106
106
  it 'should return false' do
107
- Meter.new(*args).should be_invalid
107
+ expect(Meter.new(*args)).to be_invalid
108
108
  end
109
- end
109
+ end
110
110
  end
111
111
  end
112
112
  end
@@ -5,52 +5,52 @@ describe Note do
5
5
  before :all do
6
6
  @pitch = C4
7
7
  end
8
-
9
- describe '.new' do
8
+
9
+ describe '#initialize' do
10
10
  it 'should assign :duration that is given during construction' do
11
- Note.new(2).duration.should eq(2)
11
+ expect(Note.new(2).duration).to eq(2)
12
12
  end
13
13
 
14
14
  it "should assign :articulation to NORMAL if not given" do
15
- Note.new(2).articulation.should eq(NORMAL)
15
+ expect(Note.new(2).articulation).to eq(NORMAL)
16
16
  end
17
-
17
+
18
18
  it "should assign :articulation parameter if given during construction" do
19
- Note.new(2, articulation: STACCATO).articulation.should eq(STACCATO)
19
+ expect(Note.new(2, articulation: STACCATO).articulation).to eq(STACCATO)
20
20
  end
21
-
21
+
22
22
  it 'should assign :marks to [] if not given' do
23
- Note.new(2).marks.should eq([])
23
+ expect(Note.new(2).marks).to eq([])
24
24
  end
25
-
25
+
26
26
  it 'should assign :marks if given' do
27
27
  [
28
28
  [], [BEGIN_SLUR], [END_SLUR]
29
29
  ].each do |marks|
30
- Note.quarter(marks: marks).marks.should eq(marks)
30
+ expect(Note.quarter(marks: marks).marks).to eq(marks)
31
31
  end
32
32
  end
33
-
33
+
34
34
  it 'should have no pitches if not given' do
35
- Note.new(2).pitches.should be_empty
35
+ expect(Note.new(2).pitches).to be_empty
36
36
  end
37
-
37
+
38
38
  it 'should assign pitches when given' do
39
39
  pitches = [ C2, D2 ]
40
40
  n = Note.new(2, pitches)
41
- n.pitches.should include(pitches[0])
42
- n.pitches.should include(pitches[1])
41
+ expect(n.pitches).to include(pitches[0])
42
+ expect(n.pitches).to include(pitches[1])
43
43
  end
44
44
  end
45
-
45
+
46
46
  describe '#duration=' do
47
47
  it 'should assign duration' do
48
48
  note = Note.new 2, [@pitch]
49
49
  note.duration = 3
50
- note.duration.should eq 3
50
+ expect(note.duration).to eq 3
51
51
  end
52
52
  end
53
-
53
+
54
54
  {
55
55
  :sixteenth => Rational(1,16),
56
56
  :dotted_sixteenth => Rational(3,32),
@@ -64,11 +64,11 @@ describe Note do
64
64
  }.each do |fn_name,tgt_dur|
65
65
  describe ".#{fn_name}" do
66
66
  it "should make a note with duration #{tgt_dur}" do
67
- Note.send(fn_name).duration.should eq tgt_dur
67
+ expect(Note.send(fn_name).duration).to eq tgt_dur
68
68
  end
69
69
  end
70
70
  end
71
-
71
+
72
72
  describe '#transpose' do
73
73
  context 'given pitch diff' do
74
74
  before(:all) do
@@ -76,22 +76,22 @@ describe Note do
76
76
  @interval = 4
77
77
  @note2 = @note1.transpose(@interval)
78
78
  end
79
-
79
+
80
80
  it 'should modifiy pitches by adding pitch diff' do
81
81
  @note2.pitches.each_with_index do |p,i|
82
- p.diff(@note1.pitches[i]).should eq(@interval)
82
+ expect(p.diff(@note1.pitches[i])).to eq(@interval)
83
83
  end
84
84
  end
85
-
85
+
86
86
  it 'should also affect link targets' do
87
87
  @note1.links.each do |k,v|
88
88
  kt = k.transpose(@interval)
89
- @note2.links.should have_key kt
90
- @note2.links[kt].target_pitch.should eq(v.target_pitch.transpose(@interval))
89
+ expect(@note2.links).to have_key kt
90
+ expect(@note2.links[kt].target_pitch).to eq(v.target_pitch.transpose(@interval))
91
91
  end
92
92
  end
93
93
  end
94
-
94
+
95
95
  context 'with links that have no target pitch' do
96
96
  it 'should not raise error' do
97
97
  n = Note::half([E2],links: {E2 => Link::Tie.new})
@@ -99,20 +99,41 @@ describe Note do
99
99
  end
100
100
  end
101
101
  end
102
-
102
+
103
103
  describe '#resize' do
104
104
  it 'should return new note object with given duration' do
105
105
  note = Note::quarter.resize("1/2".to_r)
106
- note.duration.should eq(Rational(1,2))
106
+ expect(note.duration).to eq(Rational(1,2))
107
+ end
108
+ end
109
+
110
+ describe '#tie_to' do
111
+ context 'given a pitch object' do
112
+ it 'should return new note object tied to given pitch' do
113
+ note = Note.half(@pitch).tie_to(@pitch)
114
+ expect(note.links).to have_key(@pitch)
115
+ expect(note.links[@pitch]).to be_a Link::Tie
116
+ end
117
+ end
118
+
119
+ context 'given an array of pitch objects' do
120
+ it 'should return new note object tied to given pitches' do
121
+ pitches = [@pitch,@pitch+1]
122
+ note = Note.half(pitches).tie_to(pitches)
123
+ pitches.each do |pitch|
124
+ expect(note.links).to have_key(pitch)
125
+ expect(note.links[pitch]).to be_a Link::Tie
126
+ end
127
+ end
107
128
  end
108
129
  end
109
-
130
+
110
131
  describe '#to_s' do
111
132
  before :all do
112
133
  @note_parser = Parsing::NoteParser.new
113
134
  end
114
-
115
- context
135
+
136
+ context
116
137
  it 'should produce string that when parsed produces an equal note' do
117
138
  durations = ["1/8".to_r,"1".to_r,"5/3".to_r]
118
139
  include Articulations
@@ -124,7 +145,7 @@ describe Note do
124
145
  [[C5,E6,Gb2],{ C5 => Link::Glissando.new(D5) }],
125
146
  [[C5,E6,Gb2],{ C5 => Link::Portamento.new(D5), Gb2 => Link::Tie.new }],
126
147
  ]
127
-
148
+
128
149
  notes = []
129
150
  durations.each do |d|
130
151
  pitches_links_sets.each do |pitches_links_set|
@@ -140,36 +161,36 @@ describe Note do
140
161
  end
141
162
  end
142
163
  end
143
-
164
+
144
165
  notes.each do |note|
145
166
  str = note.to_s
146
167
  res = @note_parser.parse(str)
147
168
  note2 = res.to_note
148
- note2.should eq(note)
169
+ expect(note2).to eq(note)
149
170
  end
150
171
  end
151
172
  end
152
-
173
+
153
174
  describe '#to_yaml' do
154
175
  it 'should produce YAML that can be loaded' do
155
176
  n = Note.new(1,[C2])
156
- YAML.load(n.to_yaml).should eq n
157
-
177
+ expect(YAML.load(n.to_yaml)).to eq n
178
+
158
179
  n = Note.new(1,[C2,E2])
159
- YAML.load(n.to_yaml).should eq n
160
-
180
+ expect(YAML.load(n.to_yaml)).to eq n
181
+
161
182
  n = Note.new(1,[C2], articulation: STACCATO)
162
- YAML.load(n.to_yaml).should eq n
163
-
183
+ expect(YAML.load(n.to_yaml)).to eq n
184
+
164
185
  n = Note.new(1,[E2], links: {E2 => Link::Portamento.new(F2)})
165
- YAML.load(n.to_yaml).should eq n
186
+ expect(YAML.load(n.to_yaml)).to eq n
166
187
  end
167
188
  end
168
189
 
169
190
  describe '#pack' do
170
191
  it 'should produce a Hash' do
171
192
  n = Note.quarter([E2,F2,A2], articulation: STACCATO, marks: [BEGIN_SLUR], links: {E2 => Link::Tie.new, F2 => Link::Glissando.new(C3)})
172
- n.pack.should be_a Hash
193
+ expect(n.pack).to be_a Hash
173
194
  end
174
195
  end
175
196
 
@@ -177,15 +198,15 @@ describe Note do
177
198
  it 'should produce an object equal the original' do
178
199
  n = Note.quarter([E2,F2,A2], articulation: STACCATO, marks: [BEGIN_SLUR], links: {E2 => Link::Tie.new, F2 => Link::Glissando.new(C3)})
179
200
  n2 = Note.unpack n.pack
180
- n2.should be_a Note
181
- n2.should eq n
201
+ expect(n2).to be_a Note
202
+ expect(n2).to eq n
182
203
  end
183
204
  end
184
-
205
+
185
206
  describe '#valid?' do
186
207
  context 'note with positive duration' do
187
208
  it 'should return true' do
188
- Note.new(1,[C2]).should be_valid
209
+ expect(Note.new(1,[C2])).to be_valid
189
210
  end
190
211
  end
191
212
  end
@@ -5,29 +5,29 @@ describe Part do
5
5
  describe '#initialize' do
6
6
  it 'should use empty containers for parameters not given' do
7
7
  p = Part.new(Dynamics::MP)
8
- p.notes.should be_empty
9
- p.dynamic_changes.should be_empty
8
+ expect(p.notes).to be_empty
9
+ expect(p.dynamic_changes).to be_empty
10
10
  end
11
-
11
+
12
12
  it "should assign parameters given during construction" do
13
13
  p = Part.new(Dynamics::PPP)
14
- p.start_dynamic.should eq Dynamics::PPP
15
-
14
+ expect(p.start_dynamic).to eq Dynamics::PPP
15
+
16
16
  notes = [Note::whole([A2]), Note::half]
17
17
  dcs = { "1/2".to_r => Change::Immediate.new(Dynamics::P), 1 => Change::Gradual.sigmoid(Dynamics::MF,1) }
18
18
  p = Part.new(Dynamics::FF, notes: notes, dynamic_changes: dcs)
19
- p.notes.should eq notes
20
- p.dynamic_changes.should eq dcs
19
+ expect(p.notes).to eq notes
20
+ expect(p.dynamic_changes).to eq dcs
21
21
 
22
22
  p = Part.new(Dynamics::P, settings: [ "dummy" ])
23
- p.settings.should eq [ "dummy" ]
23
+ expect(p.settings).to eq [ "dummy" ]
24
24
  end
25
25
  end
26
26
 
27
27
  describe '#find_settings' do
28
28
  context 'settings is empty' do
29
29
  it 'should return nil' do
30
- Part.new(Dynamics::P).find_settings(Integer).should be_nil
30
+ expect(Part.new(Dynamics::P).find_settings(Integer)).to be_nil
31
31
  end
32
32
  end
33
33
 
@@ -38,14 +38,14 @@ describe Part do
38
38
 
39
39
  context 'given class of object in settings' do
40
40
  it 'should return the object' do
41
- @part.find_settings(Integer).should be_a Integer
42
- @part.find_settings(String).should be_a String
41
+ expect(@part.find_settings(Integer)).to be_a Integer
42
+ expect(@part.find_settings(String)).to be_a String
43
43
  end
44
44
  end
45
45
 
46
46
  context 'given class not of any object in settings' do
47
47
  it 'should return nil' do
48
- @part.find_settings(Float).should be_nil
48
+ expect(@part.find_settings(Float)).to be_nil
49
49
  end
50
50
  end
51
51
  end
@@ -54,7 +54,7 @@ describe Part do
54
54
  describe '#to_yaml' do
55
55
  it 'should produce YAML that can be loaded' do
56
56
  p = Samples::SAMPLE_PART
57
- YAML.load(p.to_yaml).should eq p
57
+ expect(YAML.load(p.to_yaml)).to eq p
58
58
  end
59
59
  end
60
60
 
@@ -63,7 +63,7 @@ describe Part do
63
63
  notes = [Note::whole([A2]), Note::half]
64
64
  dcs = { "1/2".to_r => Change::Immediate.new(Dynamics::P), 1 => Change::Gradual.sigmoid(Dynamics::MF,1) }
65
65
  p = Part.new(Dynamics::FF, notes: notes, dynamic_changes: dcs, settings: [ "dummy" ])
66
- p.pack.should be_a Hash
66
+ expect(p.pack).to be_a Hash
67
67
  end
68
68
  end
69
69
 
@@ -73,8 +73,8 @@ describe Part do
73
73
  dcs = { "1/2".to_r => Change::Immediate.new(Dynamics::P), 1 => Change::Gradual.sigmoid(Dynamics::MF,1) }
74
74
  p = Part.new(Dynamics::FF, notes: notes, dynamic_changes: dcs, settings: [ "dummy" ])
75
75
  p2 = Part.unpack p.pack
76
- p2.should be_a Part
77
- p2.should eq p
76
+ expect(p2).to be_a Part
77
+ expect(p2).to eq p
78
78
  end
79
79
  end
80
80
 
@@ -93,11 +93,11 @@ describe Part do
93
93
  }.each do |context_str, args|
94
94
  context context_str do
95
95
  it 'should return false' do
96
- Part.new(*args).should be_invalid
96
+ expect(Part.new(*args)).to be_invalid
97
97
  end
98
98
  end
99
99
  end
100
-
100
+
101
101
  {
102
102
  'valid notes' => [ Dynamics::PP,
103
103
  :notes => [ Note::whole, quarter([C5]) ]],
@@ -110,7 +110,7 @@ describe Part do
110
110
  context context_str do
111
111
  it 'should return true' do
112
112
  part = Part.new(*args)
113
- part.should be_valid
113
+ expect(part).to be_valid
114
114
  end
115
115
  end
116
116
  end