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
13
14
15
16
17
|
# File 'lib/head_music/circle.rb', line 13
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
5
6
7
|
# File 'lib/head_music/circle.rb', line 5
def self.of_fifths
get(:perfect_fifth)
end
|
.of_fourths ⇒ Object
9
10
11
|
# File 'lib/head_music/circle.rb', line 9
def self.of_fourths
get(:perfect_fourth)
end
|
Instance Method Details
#index(pitch_class) ⇒ Object
19
20
21
|
# File 'lib/head_music/circle.rb', line 19
def index(pitch_class)
pitch_classes.index(HeadMusic::Spelling.get(pitch_class).pitch_class)
end
|
#key_signatures_down ⇒ Object
27
28
29
|
# File 'lib/head_music/circle.rb', line 27
def key_signatures_down
spellings_down.map { |spelling| HeadMusic::KeySignature.new(spelling) }
end
|
#key_signatures_up ⇒ Object
23
24
25
|
# File 'lib/head_music/circle.rb', line 23
def key_signatures_up
spellings_up.map { |spelling| HeadMusic::KeySignature.new(spelling) }
end
|
#pitches_down ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/head_music/circle.rb', line 43
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
37
38
39
40
41
|
# File 'lib/head_music/circle.rb', line 37
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
31
32
33
34
35
|
# File 'lib/head_music/circle.rb', line 31
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
|