Class: MusicTheory::Arpeggio

Inherits:
Object
  • Object
show all
Includes:
Output
Defined in:
lib/music_theory/arpeggio.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Output

#buffer_format, #format, #output_track, #play, #sample_rate

Constructor Details

#initialize(third, options = {}) ⇒ Arpeggio

Returns a new instance of Arpeggio.



9
10
11
12
13
# File 'lib/music_theory/arpeggio.rb', line 9

def initialize(third, options = {})
  @duration         = options[:duration] || 0.25
  @third            = third
  @output_file_name = options[:output_file_name] || 'chord' # File name to write (without extension)
end

Instance Attribute Details

#all_notesObject

Returns the value of attribute all_notes.



7
8
9
# File 'lib/music_theory/arpeggio.rb', line 7

def all_notes
  @all_notes
end

#durationObject

Returns the value of attribute duration.



7
8
9
# File 'lib/music_theory/arpeggio.rb', line 7

def duration
  @duration
end

#output_file_nameObject

Returns the value of attribute output_file_name.



7
8
9
# File 'lib/music_theory/arpeggio.rb', line 7

def output_file_name
  @output_file_name
end

#thirdObject

Returns the value of attribute third.



7
8
9
# File 'lib/music_theory/arpeggio.rb', line 7

def third
  @third
end

Instance Method Details

#arpeggionateObject



15
16
17
18
# File 'lib/music_theory/arpeggio.rb', line 15

def arpeggionate
   third.all_notes.each {|note| note.duration = duration}
   third.all_notes += [third.all_notes[2], third.all_notes[1], third.all_notes[0], third.all_notes[1]]
end

#samplesObject



20
21
22
# File 'lib/music_theory/arpeggio.rb', line 20

def samples
  arpeggionate.map(&:samples).flatten
end