head_music 0.23.1 → 0.23.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -4
- data/Gemfile +1 -1
- data/head_music.gemspec +1 -1
- data/lib/head_music/circle.rb +9 -11
- data/lib/head_music/clef.rb +3 -3
- data/lib/head_music/diatonic_interval.rb +8 -0
- data/lib/head_music/interval_cycle.rb +36 -0
- data/lib/head_music/musical_symbol.rb +12 -0
- data/lib/head_music/reference_pitch.rb +1 -1
- data/lib/head_music/sign.rb +11 -4
- data/lib/head_music/version.rb +1 -1
- data/lib/head_music.rb +2 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb1e01b3119838d06ece395586b5ba1a83d8b432f01d6bc63dfbea324f48be1c
|
4
|
+
data.tar.gz: 3f6ac1484a66455949d27fe1af7b53e7becdfddaf66093e151d89ad31b31ffa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa9f404bd1a24082020cf72d0daef7ac68f3b954ab692fec5b3c1f23ecb3a913786550127a9de543b8f88aa0a3370e3c321867cf453ab26cca3cf98ee5b81bfb
|
7
|
+
data.tar.gz: '08bae5514fb6dc84f35cbaf44b16e8ab001688e379a640c462769e950193fb9b1361a018ef29d8a048e256de535a71fe3796336511f65b6cc6fbad40ab1d9209'
|
data/.rubocop.yml
CHANGED
@@ -13,12 +13,21 @@ Metrics/ClassLength:
|
|
13
13
|
Metrics/LineLength:
|
14
14
|
Max: 120
|
15
15
|
|
16
|
-
Style/SymbolArray:
|
17
|
-
Enabled: true
|
18
|
-
|
19
16
|
Style/ClassAndModuleChildren:
|
20
17
|
EnforcedStyle: compact
|
21
18
|
|
19
|
+
Style/HashEachMethods:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/HashTransformKeys:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/HashTransformValues:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/SymbolArray:
|
29
|
+
Enabled: true
|
30
|
+
|
22
31
|
Style/TrailingCommaInArrayLiteral:
|
23
32
|
EnforcedStyleForMultiline: consistent_comma
|
24
33
|
|
@@ -26,7 +35,7 @@ Style/TrailingCommaInHashLiteral:
|
|
26
35
|
EnforcedStyleForMultiline: consistent_comma
|
27
36
|
|
28
37
|
AllCops:
|
29
|
-
TargetRubyVersion: 2.
|
38
|
+
TargetRubyVersion: 2.4
|
30
39
|
|
31
40
|
Layout/EmptyLineAfterGuardClause:
|
32
41
|
Enabled: false
|
data/Gemfile
CHANGED
data/head_music.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_runtime_dependency 'humanize', '~> 1.3'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
31
|
-
spec.add_development_dependency 'rake', '
|
31
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'rspec-its', '~> 1.2'
|
34
34
|
end
|
data/lib/head_music/circle.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'head_music/interval_cycle'
|
4
|
+
|
3
5
|
# A Circle of Fifths or Fourths shows relationships between pitch classes
|
4
|
-
|
5
|
-
# https://en.wikipedia.org/wiki/Interval_cycle
|
6
|
-
class HeadMusic::Circle
|
6
|
+
class HeadMusic::Circle < HeadMusic::IntervalCycle
|
7
7
|
def self.of_fifths
|
8
8
|
get(7)
|
9
9
|
end
|
@@ -19,6 +19,7 @@ class HeadMusic::Circle
|
|
19
19
|
|
20
20
|
attr_reader :interval, :pitch_classes
|
21
21
|
|
22
|
+
# Accepts an interval (as an integer number of semitones)
|
22
23
|
def initialize(interval)
|
23
24
|
@interval = interval.to_i
|
24
25
|
@pitch_classes = pitch_classes_by_interval
|
@@ -32,14 +33,11 @@ class HeadMusic::Circle
|
|
32
33
|
|
33
34
|
private
|
34
35
|
|
36
|
+
def interval_cycle
|
37
|
+
@interval_cycle ||= HeadMusic::IntervalCycle.get(interval)
|
38
|
+
end
|
39
|
+
|
35
40
|
def pitch_classes_by_interval
|
36
|
-
|
37
|
-
loop do
|
38
|
-
next_pitch_class = list.last + interval
|
39
|
-
break if next_pitch_class == list.first
|
40
|
-
|
41
|
-
list << next_pitch_class
|
42
|
-
end
|
43
|
-
end
|
41
|
+
interval_cycle.send(:pitch_classes_by_interval)
|
44
42
|
end
|
45
43
|
end
|
data/lib/head_music/clef.rb
CHANGED
@@ -5,17 +5,17 @@ class HeadMusic::Clef
|
|
5
5
|
include HeadMusic::NamedRudiment
|
6
6
|
|
7
7
|
CLEFS = [
|
8
|
-
{ pitch: 'G4', line: 2, names: [
|
8
|
+
{ pitch: 'G4', line: 2, names: %w[treble G-clef], modern: true },
|
9
9
|
{ pitch: 'G4', line: 1, names: ['French', 'French violin'] },
|
10
10
|
{ pitch: 'G3', line: 2, names: ['choral tenor', 'tenor', 'tenor G-clef'], modern: true },
|
11
11
|
|
12
12
|
{ pitch: 'F3', line: 3, names: ['baritone'] },
|
13
|
-
{ pitch: 'F3', line: 4, names: [
|
13
|
+
{ pitch: 'F3', line: 4, names: %w[bass F-clef], modern: true },
|
14
14
|
{ pitch: 'F3', line: 5, names: ['sub-bass'] },
|
15
15
|
|
16
16
|
{ pitch: 'C4', line: 1, names: ['soprano'] },
|
17
17
|
{ pitch: 'C4', line: 2, names: ['mezzo-soprano'] },
|
18
|
-
{ pitch: 'C4', line: 3, names: [
|
18
|
+
{ pitch: 'C4', line: 3, names: %w[alto viola counter-tenor countertenor C-clef], modern: true },
|
19
19
|
{ pitch: 'C4', line: 4, names: ['tenor', 'tenor C-clef'], modern: true },
|
20
20
|
{ pitch: 'C4', line: 5, names: ['baritone', 'baritone C-clef'] },
|
21
21
|
|
@@ -340,6 +340,14 @@ class HeadMusic::DiatonicInterval
|
|
340
340
|
HeadMusic::Pitch.from_number_and_letter(pitch - semitones, pitch.letter_name.steps_down(number - 1))
|
341
341
|
end
|
342
342
|
|
343
|
+
def interval_class
|
344
|
+
[simple_semitones, 12 - simple_semitones].min
|
345
|
+
end
|
346
|
+
|
347
|
+
def interval_class_name
|
348
|
+
"ic #{interval_class}"
|
349
|
+
end
|
350
|
+
|
343
351
|
# diatonic set theory
|
344
352
|
alias specific_interval simple_semitones
|
345
353
|
alias diatonic_generic_interval simple_steps
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# An Interval Cycle is a collection of pitch classes created from a sequence of the same interval class.
|
4
|
+
class HeadMusic::IntervalCycle
|
5
|
+
def self.get(interval = 7)
|
6
|
+
@circles ||= {}
|
7
|
+
interval = interval.to_s.gsub(/^C/i, '').to_i
|
8
|
+
@circles[interval.to_i] ||= new(interval)
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :interval, :pitch_classes
|
12
|
+
|
13
|
+
def initialize(interval)
|
14
|
+
@interval = interval.to_i
|
15
|
+
@pitch_classes = pitch_classes_by_interval
|
16
|
+
end
|
17
|
+
|
18
|
+
def index(pitch_class)
|
19
|
+
@pitch_classes.index(HeadMusic::Spelling.get(pitch_class).pitch_class)
|
20
|
+
end
|
21
|
+
|
22
|
+
private_class_method :new
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def pitch_classes_by_interval
|
27
|
+
[HeadMusic::PitchClass.get(0)].tap do |list|
|
28
|
+
loop do
|
29
|
+
next_pitch_class = list.last + interval
|
30
|
+
break if next_pitch_class == list.first
|
31
|
+
|
32
|
+
list << next_pitch_class
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A symbol is a mark or sign that signifies a particular rudiment of music
|
4
|
+
class HeadMusic::Symbol
|
5
|
+
attr_reader :ascii, :unicode, :html_entity
|
6
|
+
|
7
|
+
def initialize(ascii: nil, unicode: nil, html_entity: nil)
|
8
|
+
@ascii = ascii
|
9
|
+
@unicode = unicode
|
10
|
+
@html_entity = html_entity
|
11
|
+
end
|
12
|
+
end
|
data/lib/head_music/sign.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'head_music/musical_symbol'
|
4
|
+
|
3
5
|
# A Sign is a symbol that modifies pitch, such as a sharp, flat, or natural.
|
4
6
|
class HeadMusic::Sign
|
5
7
|
include Comparable
|
6
8
|
|
7
|
-
attr_reader :identifier, :
|
9
|
+
attr_reader :identifier, :cents, :symbol
|
8
10
|
|
9
11
|
def self.all
|
10
12
|
@all ||= [
|
@@ -64,14 +66,19 @@ class HeadMusic::Sign
|
|
64
66
|
cents <=> other.cents
|
65
67
|
end
|
66
68
|
|
69
|
+
delegate :ascii, :html_entity, :unicode, to: :symbol
|
70
|
+
|
67
71
|
private
|
68
72
|
|
69
73
|
def initialize(attributes)
|
70
74
|
@identifier = attributes[:identifier]
|
71
|
-
@ascii = attributes[:ascii]
|
72
|
-
@unicode = attributes[:unicode]
|
73
|
-
@html_entity = attributes[:html_entity]
|
74
75
|
@cents = attributes[:cents]
|
76
|
+
|
77
|
+
@symbol = HeadMusic::Symbol.new(
|
78
|
+
unicode: attributes[:unicode],
|
79
|
+
ascii: attributes[:ascii],
|
80
|
+
html_entity: attributes[:html_entity]
|
81
|
+
)
|
75
82
|
end
|
76
83
|
|
77
84
|
private_class_method :new
|
data/lib/head_music/version.rb
CHANGED
data/lib/head_music.rb
CHANGED
@@ -28,11 +28,13 @@ require 'head_music/diatonic_interval'
|
|
28
28
|
require 'head_music/grand_staff'
|
29
29
|
require 'head_music/harmonic_interval'
|
30
30
|
require 'head_music/instrument'
|
31
|
+
require 'head_music/interval_cycle'
|
31
32
|
require 'head_music/key_signature'
|
32
33
|
require 'head_music/letter_name'
|
33
34
|
require 'head_music/melodic_interval'
|
34
35
|
require 'head_music/meter'
|
35
36
|
require 'head_music/motion'
|
37
|
+
require 'head_music/musical_symbol'
|
36
38
|
require 'head_music/octave'
|
37
39
|
require 'head_music/pitch'
|
38
40
|
require 'head_music/pitch/enharmonic_equivalence'
|
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.23.
|
4
|
+
version: 0.23.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: 2020-03-
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,11 +135,13 @@ files:
|
|
135
135
|
- lib/head_music/grand_staff.rb
|
136
136
|
- lib/head_music/harmonic_interval.rb
|
137
137
|
- lib/head_music/instrument.rb
|
138
|
+
- lib/head_music/interval_cycle.rb
|
138
139
|
- lib/head_music/key_signature.rb
|
139
140
|
- lib/head_music/letter_name.rb
|
140
141
|
- lib/head_music/melodic_interval.rb
|
141
142
|
- lib/head_music/meter.rb
|
142
143
|
- lib/head_music/motion.rb
|
144
|
+
- lib/head_music/musical_symbol.rb
|
143
145
|
- lib/head_music/named_rudiment.rb
|
144
146
|
- lib/head_music/octave.rb
|
145
147
|
- lib/head_music/pitch.rb
|