coltrane 3.2.0 → 3.3.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/coltrane/representation/guitar/chord.rb +19 -13
- data/lib/coltrane/theory/frequency.rb +5 -0
- data/lib/coltrane/theory/pitch.rb +5 -0
- data/lib/coltrane/theory/voicing.rb +25 -8
- data/lib/coltrane/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d2c4c2f31729c93b6b3e8a37715d3686210da80970f4f42ea5205e8e39f029c
|
4
|
+
data.tar.gz: 376e9ca70b7b63896ea315383695a26b624a6bf90e5397776e8700104de078a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52459e563498115c43f5e69c7da097102c598ef941beb5917df7c3867bf850616ed54978fb6119d6443e6e129255a916e7b4f2583e51dc8a6013134d0e69fbae
|
7
|
+
data.tar.gz: 458eba1dfdfdb95a535b6dd2520ce32bec09aa3ef98aa1f6482855ca878071ebebd818cfd4a75fd3ff30060101196bbc9f438db2dfc5a3ba7d3120533e9bf0c2
|
data/Gemfile.lock
CHANGED
@@ -39,19 +39,19 @@ module Coltrane
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def rank
|
42
|
-
+completeness
|
43
|
-
+fullness
|
44
|
-
-spreadness
|
45
|
-
|
42
|
+
+completeness * 10_000 +
|
43
|
+
+fullness * 1_000 +
|
44
|
+
-spreadness * 10 +
|
45
|
+
-discontinuity * 1 +
|
46
|
+
+easyness * 1
|
46
47
|
end
|
47
48
|
|
48
49
|
def analysis
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
50
|
+
%i[completeness discontinuity fullness spreadness easyness]
|
51
|
+
.reduce({}) do |output, criteria|
|
52
|
+
output.merge(criteria => send(criteria).round(2))
|
53
|
+
end
|
54
|
+
.merge(rank: rank.round(4))
|
55
55
|
end
|
56
56
|
|
57
57
|
def spreadness
|
@@ -70,6 +70,10 @@ module Coltrane
|
|
70
70
|
(guitar.strings.size.to_f - frets.count(nil)) / guitar.strings.size
|
71
71
|
end
|
72
72
|
|
73
|
+
def discontinuity
|
74
|
+
voicing.discontinuity
|
75
|
+
end
|
76
|
+
|
73
77
|
def barre?
|
74
78
|
!@barre.nil?
|
75
79
|
end
|
@@ -153,12 +157,14 @@ module Coltrane
|
|
153
157
|
[(0 unless barre?)].compact
|
154
158
|
end
|
155
159
|
|
156
|
-
def to_s
|
157
|
-
guitar_notes.map {
|
160
|
+
def to_s(debug = false)
|
161
|
+
guitar_notes.map {
|
162
|
+
|n| n.fret.nil? ? 'x' : n.fret
|
163
|
+
}.join('-') + (debug ? ' ' + analysis.to_s : '')
|
158
164
|
end
|
159
165
|
|
160
166
|
def voicing
|
161
|
-
|
167
|
+
Theory::Voicing.new(pitches: guitar_notes.map(&:pitch).compact)
|
162
168
|
end
|
163
169
|
|
164
170
|
private
|
@@ -3,12 +3,17 @@
|
|
3
3
|
module Coltrane
|
4
4
|
module Theory
|
5
5
|
class Frequency
|
6
|
+
include Comparable
|
6
7
|
attr_reader :frequency
|
7
8
|
|
8
9
|
def initialize(frequency)
|
9
10
|
@frequency = frequency.to_f
|
10
11
|
end
|
11
12
|
|
13
|
+
def <=>(other)
|
14
|
+
to_f <=> other.to_f
|
15
|
+
end
|
16
|
+
|
12
17
|
class << self
|
13
18
|
alias [] new
|
14
19
|
end
|
@@ -4,6 +4,7 @@ module Coltrane
|
|
4
4
|
module Theory
|
5
5
|
# It describes a pitch, like E4 or Bb5. It's like a note, but it has an octave
|
6
6
|
class Pitch
|
7
|
+
include Comparable
|
7
8
|
attr_reader :integer
|
8
9
|
|
9
10
|
def initialize(notation_arg = nil,
|
@@ -29,6 +30,10 @@ module Coltrane
|
|
29
30
|
new *args
|
30
31
|
end
|
31
32
|
|
33
|
+
def <=>(other)
|
34
|
+
integer <=> other.integer
|
35
|
+
end
|
36
|
+
|
32
37
|
def scientific_notation
|
33
38
|
"#{pitch_class}#{octave}"
|
34
39
|
end
|
@@ -5,16 +5,19 @@ module Coltrane
|
|
5
5
|
# This class describes an actual implementation of a Chord, being aware
|
6
6
|
# of exact octaves of each pitch and even repeating pitches across octaves.
|
7
7
|
class Voicing
|
8
|
+
|
8
9
|
attr_reader :pitches
|
9
10
|
|
10
11
|
def initialize(*pitch_strings, pitches: nil)
|
11
|
-
@pitches =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
@pitches = begin
|
13
|
+
if pitch_strings.any?
|
14
|
+
pitch_strings.map { |s| Pitch[s] }
|
15
|
+
elsif pitches
|
16
|
+
pitches
|
17
|
+
else
|
18
|
+
raise WrongArgumentsError
|
19
|
+
end
|
20
|
+
end.sort
|
18
21
|
end
|
19
22
|
|
20
23
|
def self.[](*args)
|
@@ -34,8 +37,22 @@ module Coltrane
|
|
34
37
|
end
|
35
38
|
|
36
39
|
def frequencies
|
37
|
-
pitches.map(&:frequency)
|
40
|
+
@frequencies ||= pitches.map(&:frequency)
|
41
|
+
end
|
42
|
+
|
43
|
+
def discontinuity
|
44
|
+
frequencies.each_with_index.reduce(0) do |max_dist, (freq, index)|
|
45
|
+
next 0 if index.zero?
|
46
|
+
[max_dist, freq.to_f - frequencies[index - 1].to_f].max
|
47
|
+
end
|
38
48
|
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def ideal_frequency_distance
|
53
|
+
(Pitch['D3'].frequency - Pitch['A2'].frequency).to_f
|
54
|
+
end
|
55
|
+
|
39
56
|
end
|
40
57
|
end
|
41
58
|
end
|
data/lib/coltrane/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coltrane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Maciel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-reader
|