Class: Musicality::Scale
- Inherits:
-
Object
- Object
- Musicality::Scale
- Defined in:
- lib/musicality/composition/model/scale.rb
Instance Attribute Summary collapse
-
#pitch_class ⇒ Object
readonly
Returns the value of attribute pitch_class.
Instance Method Summary collapse
- #at_octave(octave) ⇒ Object
-
#initialize(pitch_class, intervals) ⇒ Scale
constructor
A new instance of Scale.
- #intervals ⇒ Object
- #rotate(n) ⇒ Object
- #size ⇒ Object
- #transpose(diff) ⇒ Object
Constructor Details
#initialize(pitch_class, intervals) ⇒ Scale
Returns a new instance of Scale.
5 6 7 8 |
# File 'lib/musicality/composition/model/scale.rb', line 5 def initialize pitch_class, intervals @pitch_class = pitch_class @intervals = intervals end |
Instance Attribute Details
#pitch_class ⇒ Object (readonly)
Returns the value of attribute pitch_class.
4 5 6 |
# File 'lib/musicality/composition/model/scale.rb', line 4 def pitch_class @pitch_class end |
Instance Method Details
#at_octave(octave) ⇒ Object
28 29 30 31 |
# File 'lib/musicality/composition/model/scale.rb', line 28 def at_octave octave start_pitch = Pitch.new(octave: octave, semitone: @pitch_class) AddingSequence.new(@intervals, start_pitch) end |
#intervals ⇒ Object
10 |
# File 'lib/musicality/composition/model/scale.rb', line 10 def intervals; @intervals.entries; end |
#rotate(n) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/musicality/composition/model/scale.rb', line 21 def rotate n diff = AddingSequence.new(@intervals).at(n) new_pc = (@pitch_class + diff).to_pc new_intervals = @intervals.rotate(n) Scale.new(new_pc,new_intervals) end |
#size ⇒ Object
12 13 14 |
# File 'lib/musicality/composition/model/scale.rb', line 12 def size @intervals.size end |