Class: MusicTheory::Third
- Inherits:
-
Object
- Object
- MusicTheory::Third
- Includes:
- Output
- Defined in:
- lib/music_theory/third.rb
Instance Attribute Summary collapse
-
#all_notes ⇒ Object
Returns the value of attribute all_notes.
-
#scale ⇒ Object
Returns the value of attribute scale.
Instance Method Summary collapse
- #arpeggio ⇒ Object
- #chord ⇒ Object
-
#initialize(scale) ⇒ Third
constructor
A new instance of Third.
- #output_file_name ⇒ Object
- #samples ⇒ Object
Methods included from Output
#buffer_format, #format, #output_track, #play, #sample_rate
Constructor Details
#initialize(scale) ⇒ Third
Returns a new instance of Third.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/music_theory/third.rb', line 8 def initialize(scale) @scale = scale @all_notes = [scale.scale_notes.first] current = 0 double_scale_notes = scale.scale_notes * 2 scale.mode.in_groups_of(2, false) do |group| current += group.sum all_notes << double_scale_notes[current] end all_notes.compact.uniq {|note| note.frequency}.sort_by! {|note| note.frequency} end |
Instance Attribute Details
#all_notes ⇒ Object
Returns the value of attribute all_notes.
6 7 8 |
# File 'lib/music_theory/third.rb', line 6 def all_notes @all_notes end |
#scale ⇒ Object
Returns the value of attribute scale.
6 7 8 |
# File 'lib/music_theory/third.rb', line 6 def scale @scale end |
Instance Method Details
#arpeggio ⇒ Object
28 29 30 |
# File 'lib/music_theory/third.rb', line 28 def arpeggio arpeggio ||= MusicTheory::Arpeggio.new self.dup end |
#chord ⇒ Object
24 25 26 |
# File 'lib/music_theory/third.rb', line 24 def chord chord ||= MusicTheory::Chord.new self.dup end |
#output_file_name ⇒ Object
32 33 34 |
# File 'lib/music_theory/third.rb', line 32 def output_file_name scale.output_file_name || 'thirds' end |
#samples ⇒ Object
20 21 22 |
# File 'lib/music_theory/third.rb', line 20 def samples all_notes.map(&:samples).flatten end |