Class: InevitableCacophony::OctaveStructure::Scale

Inherits:
NoteSequence
  • Object
show all
Defined in:
lib/inevitable_cacophony/octave_structure.rb

Overview

As above, but also tracks the chords that make up the scale.

Instance Attribute Summary

Attributes inherited from NoteSequence

#note_scalings

Instance Method Summary collapse

Methods inherited from NoteSequence

#length

Constructor Details

#initialize(chords, note_scalings = nil) ⇒ Scale

Returns a new instance of Scale.

Parameters:

  • chords (Array<Chord>)

    The chords that make up the scale, in order.

  • note_scalings (Array<Fixnum>) (defaults to: nil)

    Specific note scalings to use; for internal use.



37
38
39
40
# File 'lib/inevitable_cacophony/octave_structure.rb', line 37

def initialize(chords, note_scalings=nil)
        @chords = chords
        super(note_scalings || chords.map(&:note_scalings).flatten)
end

Instance Method Details

#openScale

Convert this scale to an “open” one – i.e. one not including the last note of the octave.

This form is more convenient when concatenating scales together.

Returns:



48
49
50
51
52
53
54
55
56
57
# File 'lib/inevitable_cacophony/octave_structure.rb', line 48

def open
        if note_scalings.last == OCTAVE_RATIO
        
                # -1 is the last note; we want to end on the one before that, so -2
                Scale.new(@chords, note_scalings[0..-2])
        else
                # This scale is already open.
                self
        end
end