music-transcription 0.6.1 → 0.6.2

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: 131c9cf269096b2ed6365d54fa606979afb2bf7e
4
- data.tar.gz: fc92128e9a48f45b6fbb665013e891731d22f716
3
+ metadata.gz: 798476169e353327ed492007a49a4fa4cb7a5876
4
+ data.tar.gz: e1b210b46df6d19be8376981d273386d259112b6
5
5
  SHA512:
6
- metadata.gz: ddac809b2d0172ddcc452c756e31f4244f27b920b0fabfa5c2463059480c56e450bacdf1f69287635e1f91e51cf7efe289124f3ab5cefff6ae509994d8895347
7
- data.tar.gz: e7f4129f5698aac3647e6931909afb489e6d54e9503226d0b45b9dd1e53f0e97a4e2f62cd543c70da293c03a5d08f98cb5d5b45c5de32d740ac1f912e3312be0
6
+ metadata.gz: 703b333835f7a602d7fddd76f8cb3a4de29e2ffc5e917a5f6041056f8c5bf26d1159095cdd9d9860be184f1ee9dddc52d7819e1aa07a4d2c5c1a570024434a4d
7
+ data.tar.gz: 48f2c1e631998cc99cfa01bf960dc405b0280717a9357fcf40cefc6d8c8550a7c94c9527d35d92f301d62a457f2053ec2b99ad394c0d85950932d4c8cf4454ec
@@ -76,7 +76,7 @@ class Note
76
76
  self.clone.transpose! diff, transpose_links
77
77
  end
78
78
 
79
- def transpose! diff, transpose_link_targets
79
+ def transpose! diff, transpose_link_targets = true
80
80
  unless diff.is_a?(Pitch)
81
81
  diff = Pitch.make_from_semitone(diff)
82
82
  end
@@ -93,6 +93,14 @@ class Note
93
93
  return self
94
94
  end
95
95
 
96
+ def stretch ratio
97
+ self.clone.stretch! ratio
98
+ end
99
+
100
+ def stretch! ratio
101
+ @duration *= ratio
102
+ end
103
+
96
104
  def to_s
97
105
  output = @duration.to_s
98
106
  if @pitches.any?
@@ -2,6 +2,6 @@
2
2
  module Music
3
3
  module Transcription
4
4
  # music-transcription version
5
- VERSION = "0.6.1"
5
+ VERSION = "0.6.2"
6
6
  end
7
7
  end
@@ -62,13 +62,36 @@ describe Note do
62
62
  end
63
63
  end
64
64
  end
65
+
66
+ context 'transpose_link_targets set true' do
67
+ it 'should also transpose link targets' do
68
+ note = Note::Quarter.new([C2,F2], links:{C2=>Link::Slur.new(D2)})
69
+ note.transpose!(2,true)
70
+ note.links[D2].target_pitch.should eq(E2)
71
+ end
72
+ end
73
+
74
+ context 'transpose_link_targets not set' do
75
+ it 'should default to true' do
76
+ note = Note::Quarter.new([C2,F2], links: {C2=>Link::Slur.new(D2)})
77
+ note.transpose!(2)
78
+ note.links[D2].target_pitch.should eq E2
79
+ end
80
+ end
65
81
  end
66
82
 
67
- context 'transpose_link_targets set true' do
68
- it 'should also transpose link targets' do
69
- note = Note::Quarter.new([C2,F2], links:{C2=>Link::Slur.new(D2)})
70
- note.transpose!(2,true)
71
- note.links[D2].target_pitch.should eq(E2)
83
+ describe '#stretch!' do
84
+ it 'should multiply note duration by ratio' do
85
+ note = Note::Quarter.new
86
+ note.stretch!(2)
87
+ note.duration.should eq(Rational(1,2))
88
+
89
+ note = Note::Quarter.new
90
+ note.stretch!(Rational(1,2))
91
+ note.duration.should eq(Rational(1,8))
92
+ note = Note::Quarter.new
93
+ note.stretch!(2)
94
+ note.duration.should eq(Rational(1,2))
72
95
  end
73
96
  end
74
97
  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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Tunnell