music-utils 1.1.1 → 1.1.2
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.
- data/CHANGELOG.md +7 -0
- data/README.md +2 -0
- data/lib/music-utils/interval/interval.rb +10 -5
- data/lib/music-utils/version.rb +1 -1
- data/spec/music-utils_spec.rb +23 -0
- metadata +8 -8
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -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;
|
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
|
-
|
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
|
data/lib/music-utils/version.rb
CHANGED
data/spec/music-utils_spec.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2011-05-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
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: *
|
24
|
+
version_requirements: *85936420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
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: *
|
35
|
+
version_requirements: *85936230
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
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: *
|
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:
|