Class: HeadMusic::Circle
Overview
A Circle of Fifths or Fourths shows relationships between pitch classes
Instance Attribute Summary
#interval, #starting_pitch
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #pitch_class_set, #pitch_classes, #pitches, #spellings
Class Method Details
.get(interval = :perfect_fifth) ⇒ Object
15
16
17
18
19
|
# File 'lib/head_music/circle.rb', line 15
def self.get(interval = :perfect_fifth)
@circles ||= {}
diatonic_interval = HeadMusic::DiatonicInterval.get(interval)
@circles[interval] ||= new(interval: diatonic_interval, starting_pitch: "C4")
end
|
.of_fifths ⇒ Object
7
8
9
|
# File 'lib/head_music/circle.rb', line 7
def self.of_fifths
get(:perfect_fifth)
end
|
.of_fourths ⇒ Object
11
12
13
|
# File 'lib/head_music/circle.rb', line 11
def self.of_fourths
get(:perfect_fourth)
end
|
Instance Method Details
#index(pitch_class) ⇒ Object
21
22
23
|
# File 'lib/head_music/circle.rb', line 21
def index(pitch_class)
pitch_classes.index(HeadMusic::Spelling.get(pitch_class).pitch_class)
end
|
#key_signatures_down ⇒ Object
29
30
31
|
# File 'lib/head_music/circle.rb', line 29
def key_signatures_down
spellings_down.map { |spelling| HeadMusic::KeySignature.new(spelling) }
end
|
#key_signatures_up ⇒ Object
25
26
27
|
# File 'lib/head_music/circle.rb', line 25
def key_signatures_up
spellings_up.map { |spelling| HeadMusic::KeySignature.new(spelling) }
end
|
#pitches_down ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/head_music/circle.rb', line 45
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
39
40
41
42
43
|
# File 'lib/head_music/circle.rb', line 39
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
33
34
35
36
37
|
# File 'lib/head_music/circle.rb', line 33
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
|