head_music 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/head_music/consonance.rb +20 -0
- data/lib/head_music/functional_interval.rb +31 -0
- data/lib/head_music/quality.rb +4 -0
- data/lib/head_music/scale.rb +2 -2
- data/lib/head_music/version.rb +1 -1
- data/lib/head_music.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 208eb249d8215ed60a1047fa2ce44d615da37cf3
|
4
|
+
data.tar.gz: 9e02bbfcd8df9e1ca07dc737b594063831caf7f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76df5d52cfc41df45d538da2fb0b4443d64bd65f4713e412e611082853906495881c26631799bad5c1fd160eea7355baa6c3c8911ad4151f8c719f61866900a
|
7
|
+
data.tar.gz: 3153be5ac2b260d3ef0c9035d2e2772ba35d0871f831878eba88313365a843a08e24a4bb6ce59d1bc2fc661c388e317efdb7a2fc3ff92c76eed6db45b5165a3b
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class HeadMusic::Consonance
|
2
|
+
LEVELS = %w[perfect imperfect dissonant]
|
3
|
+
|
4
|
+
def self.get(name)
|
5
|
+
@consonances ||= {}
|
6
|
+
@consonances[name.to_sym] ||= new(name) if LEVELS.include?(name.to_s)
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
delegate :to_s, to: :name
|
12
|
+
|
13
|
+
def initialize(name)
|
14
|
+
@name = name.to_s.to_sym
|
15
|
+
end
|
16
|
+
|
17
|
+
LEVELS.each do |method_name|
|
18
|
+
define_method(:"#{method_name}?") { to_s == method_name }
|
19
|
+
end
|
20
|
+
end
|
@@ -26,6 +26,7 @@ class HeadMusic::FunctionalInterval
|
|
26
26
|
|
27
27
|
delegate :to_s, to: :name
|
28
28
|
delegate :==, to: :to_s
|
29
|
+
delegate :perfect?, :major?, :minor?, :diminished?, :augmented?, :doubly_diminished?, :doubly_augmented?, to: :quality
|
29
30
|
|
30
31
|
def self.get(name)
|
31
32
|
words = name.to_s.split(/[_ ]+/)
|
@@ -136,4 +137,34 @@ class HeadMusic::FunctionalInterval
|
|
136
137
|
end
|
137
138
|
HeadMusic::FunctionalInterval.new(higher_pitch, inverted_low_pitch)
|
138
139
|
end
|
140
|
+
|
141
|
+
def consonance
|
142
|
+
if quality.perfect?
|
143
|
+
if [number, simple_number].include?(4)
|
144
|
+
HeadMusic::Consonance.get(:dissonant)
|
145
|
+
else
|
146
|
+
HeadMusic::Consonance.get(:perfect)
|
147
|
+
end
|
148
|
+
elsif quality.major? || quality.minor?
|
149
|
+
if [number, simple_number] & [3, 6].empty?
|
150
|
+
HeadMusic::Consonance.get(:dissonant)
|
151
|
+
else
|
152
|
+
HeadMusic::Consonance.get(:imperfect)
|
153
|
+
end
|
154
|
+
else
|
155
|
+
HeadMusic::Consonance.get(:dissonant)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def skip?
|
160
|
+
number > 2
|
161
|
+
end
|
162
|
+
|
163
|
+
def step?
|
164
|
+
number <= 2
|
165
|
+
end
|
166
|
+
|
167
|
+
NUMBER_NAMES.each do |method_name|
|
168
|
+
define_method(:"#{method_name}?") { number_name == method_name }
|
169
|
+
end
|
139
170
|
end
|
data/lib/head_music/quality.rb
CHANGED
data/lib/head_music/scale.rb
CHANGED
@@ -42,8 +42,8 @@ class HeadMusic::Scale
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def spellings
|
46
|
-
pitches.map(&:spelling).map(&:to_s)
|
45
|
+
def spellings(direction: :ascending, octaves: 1)
|
46
|
+
pitches(direction: direction, octaves: octaves).map(&:spelling).map(&:to_s)
|
47
47
|
end
|
48
48
|
|
49
49
|
def pitch_names(direction: :ascending, octaves: 1)
|
data/lib/head_music/version.rb
CHANGED
data/lib/head_music.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: head_music
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Head
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/head_music.rb
|
117
117
|
- lib/head_music/accidental.rb
|
118
118
|
- lib/head_music/circle.rb
|
119
|
+
- lib/head_music/consonance.rb
|
119
120
|
- lib/head_music/functional_interval.rb
|
120
121
|
- lib/head_music/interval.rb
|
121
122
|
- lib/head_music/key_signature.rb
|