Class: Fet::ChordProgression
- Inherits:
-
Object
- Object
- Fet::ChordProgression
- Defined in:
- lib/fet/chord_progression.rb
Overview
Class in charge of generating chord progressions, as well as any associated music theory
Constant Summary collapse
- TEMPLATE_MAJOR =
"major".deep_freeze
- TEMPLATE_MINOR =
"minor".deep_freeze
- DEFAULT_TEMPLATES =
{ # I-IV-V7-I TEMPLATE_MAJOR => [[0, 4, 7], [0, 5, 9], [-1, 5, 7], [0, 4, 7]], # i-iv-V7-i TEMPLATE_MINOR => [[0, 3, 7], [0, 5, 8], [-1, 5, 7], [0, 3, 7]], }.deep_freeze
Instance Attribute Summary collapse
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(offset:, template_type: nil, template: nil) ⇒ ChordProgression
constructor
A new instance of ChordProgression.
- #with_offset ⇒ Object
Constructor Details
#initialize(offset:, template_type: nil, template: nil) ⇒ ChordProgression
Returns a new instance of ChordProgression.
18 19 20 21 22 23 24 |
# File 'lib/fet/chord_progression.rb', line 18 def initialize(offset:, template_type: nil, template: nil) self.template = template_type ? DEFAULT_TEMPLATES[template_type] : template validate_template! self.offset = offset validate_offset! end |
Instance Attribute Details
#offset ⇒ Object
Returns the value of attribute offset.
16 17 18 |
# File 'lib/fet/chord_progression.rb', line 16 def offset @offset end |
#template ⇒ Object
Returns the value of attribute template.
16 17 18 |
# File 'lib/fet/chord_progression.rb', line 16 def template @template end |
Instance Method Details
#with_offset ⇒ Object
26 27 28 |
# File 'lib/fet/chord_progression.rb', line 26 def with_offset return template.map { |chord| chord.map { |note| note + offset } } end |