music-utils 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.1.2 (May 21, 2011)
2
+
3
+ Features:
4
+
5
+ - Fixed bugs in semitones count
6
+
7
+
1
8
  ## 1.1.1 (May 20, 2011)
2
9
 
3
10
  Features:
data/README.md CHANGED
@@ -60,7 +60,9 @@ To run the tests:
60
60
  To Do
61
61
  -----
62
62
 
63
+ * Fix octave semitones count bug
63
64
  * Add validations (notes, alterations, etc)
65
+ * Add support to pentatonic scale and others
64
66
 
65
67
 
66
68
  Copyright
@@ -30,11 +30,11 @@ module MusicUtils
30
30
 
31
31
  # Returns the number of semitones
32
32
  def semitones
33
+ return CROMATIC_SCALE.length if @note1 == @note2
34
+
33
35
  # initialize counter and index of scale
34
36
  i = note1_index
35
37
  count = 0
36
-
37
- count, i = no_unison(count, i)
38
38
 
39
39
  # counting semi-tones
40
40
  until_find_note2(i) do |ii|
@@ -82,12 +82,12 @@ module MusicUtils
82
82
 
83
83
  # Common loop to search note 2
84
84
  def until_find_note2(i)
85
- length = DIATONIC_SCALE.length
85
+ length = DIATONIC_SCALE.length - 1
86
86
  # search note2
87
87
  while DIATONIC_SCALE[i] != @note2
88
88
  i += 1
89
89
  if i > length
90
- i = 0; next
90
+ i = 0;
91
91
  end
92
92
  yield i
93
93
  end
@@ -96,7 +96,12 @@ module MusicUtils
96
96
  # Jumps to the next note if note 1 and note 2 are the same
97
97
  def no_unison(count, i)
98
98
  if @note1 == @note2
99
- count += 1; i += 1
99
+ if DIATONIC_SCALE[i] == Scales::FA or DIATONIC_SCALE[i] == Scales::DO
100
+ count += 1
101
+ else
102
+ count += 2
103
+ end
104
+ i += 1
100
105
  end
101
106
  [count, i]
102
107
  end
@@ -1,3 +1,3 @@
1
1
  module MusicUtils
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -90,6 +90,29 @@ describe MusicUtils do
90
90
  it "compound interval do-si should be 21 semitones" do
91
91
  MusicUtils.semitones(DO, SI, 1).should == 23
92
92
  end
93
+ it "compound interval do-do should be 21 semitones" do
94
+ MusicUtils.semitones(DO, DO).should == 12
95
+ end
96
+ end
97
+ context "Diatonic from others" do
98
+ it "simple interval so-la should be 2 semitones" do
99
+ MusicUtils.semitones(SOL, LA).should == 2
100
+ end
101
+ it "simple interval re-do should be 10 semitones" do
102
+ MusicUtils.semitones(RE, DO).should == 10
103
+ end
104
+ it "simple interval fa-re should be 9 semitones" do
105
+ MusicUtils.semitones(FA, RE).should == 9
106
+ end
107
+ it "simple interval si-mi should be 5 semitones" do
108
+ MusicUtils.semitones(SI, MI).should == 5
109
+ end
110
+ it "simple interval mi-si should be 7 semitones" do
111
+ MusicUtils.semitones(MI, SI).should == 7
112
+ end
113
+ it "simple interval fa-do should be 7 semitones" do
114
+ MusicUtils.semitones(FA, DO).should == 7
115
+ end
93
116
  end
94
117
  end
95
118
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: music-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-20 00:00:00.000000000Z
12
+ date: 2011-05-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &74447040 !ruby/object:Gem::Requirement
16
+ requirement: &85936420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.8'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *74447040
24
+ version_requirements: *85936420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &74446850 !ruby/object:Gem::Requirement
27
+ requirement: &85936230 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *74446850
35
+ version_requirements: *85936230
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &74446620 !ruby/object:Gem::Requirement
38
+ requirement: &85936000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *74446620
46
+ version_requirements: *85936000
47
47
  description: Utils to classify music intervals, create scales and more. See README.md
48
48
  and CHANGELOG.md on homepage for more info.
49
49
  email: