Class: HeadMusic::Analysis::Circle
Overview
A Circle of Fifths or Fourths shows relationships between pitch classes
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.get(interval = :perfect_fifth) ⇒ Object
16
17
18
19
20
|
# File 'lib/head_music/analysis/circle.rb', line 16
def self.get(interval = :perfect_fifth)
@circles ||= {}
diatonic_interval = HeadMusic::Analysis::DiatonicInterval.get(interval)
@circles[interval] ||= new(interval: diatonic_interval, starting_pitch: "C4")
end
|
.of_fifths ⇒ Object
8
9
10
|
# File 'lib/head_music/analysis/circle.rb', line 8
def self.of_fifths
get(:perfect_fifth)
end
|
.of_fourths ⇒ Object
12
13
14
|
# File 'lib/head_music/analysis/circle.rb', line 12
def self.of_fourths
get(:perfect_fourth)
end
|
Instance Method Details
#index(pitch_class) ⇒ Object
22
23
24
|
# File 'lib/head_music/analysis/circle.rb', line 22
def index(pitch_class)
pitch_classes.index(HeadMusic::Rudiment::Spelling.get(pitch_class).pitch_class)
end
|
#key_signatures_down ⇒ Object
30
31
32
|
# File 'lib/head_music/analysis/circle.rb', line 30
def key_signatures_down
spellings_down.map { |spelling| HeadMusic::Rudiment::KeySignature.new(spelling) }
end
|
#key_signatures_up ⇒ Object
26
27
28
|
# File 'lib/head_music/analysis/circle.rb', line 26
def key_signatures_up
spellings_up.map { |spelling| HeadMusic::Rudiment::KeySignature.new(spelling) }
end
|
#pitches_down ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/head_music/analysis/circle.rb', line 46
def pitches_down
@pitches_down ||= [starting_pitch].tap do |list|
loop do
next_pitch = list.last - interval
next_pitch += octave while starting_pitch - next_pitch > 12
break if next_pitch.pitch_class == list.first.pitch_class
list << next_pitch
end
end
end
|
#spellings_down ⇒ Object
40
41
42
43
44
|
# File 'lib/head_music/analysis/circle.rb', line 40
def spellings_down
pitches_down.map(&:pitch_class).map do |pitch_class|
pitch_class.smart_spelling(max_sharps_in_major_key_signature: 4)
end
end
|
#spellings_up ⇒ Object
34
35
36
37
38
|
# File 'lib/head_music/analysis/circle.rb', line 34
def spellings_up
pitches_up.map(&:pitch_class).map do |pitch_class|
pitch_class.smart_spelling(max_sharps_in_major_key_signature: 7)
end
end
|