class MusicTheory::Octave
Attributes
all_notes[RW]
amount[RW]
direction[RW]
output_file_name[RW]
starting_note[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/music_theory/octave.rb, line 8 def initialize(options = {}) @starting_note = options[:starting_note] || MusicTheory::Note.new # Note to start on @amount = options[:amount] || 2 # Number of octaves to repeat @direction = options[:direction] || 'asc' # Number of seconds per note @output_file_name = options[:output_file_name] || 'octave' # File name to write (without extension) build_octave end
Public Instance Methods
build_octave()
click to toggle source
# File lib/music_theory/octave.rb, line 16 def build_octave @all_notes = [ starting_note ] amount.to_i.times do new_note = all_notes.last.dup if direction == 'asc' new_note.frequency = all_notes.last.frequency * 2 elsif direction == 'desc' new_note.frequency = all_notes.last.frequency / 2 end all_notes << new_note unless new_note.frequency > 20000 end end
samples()
click to toggle source
# File lib/music_theory/octave.rb, line 29 def samples all_notes.map(&:samples).flatten end