Class: Feep::Scale
- Inherits:
-
Object
- Object
- Feep::Scale
- Defined in:
- lib/feep/scale.rb
Instance Method Summary collapse
-
#play_scale(options) ⇒ Object
plays the musical scale with Feep.
Instance Method Details
#play_scale(options) ⇒ Object
plays the musical scale with Feep
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/feep/scale.rb', line 11 def play_scale() unless SCALES.include?([:scale].to_sym) Utils.print_error(:invalid_scale) end valid_notes = NOTES | NOTES_ALT | FREQS freq = Utils::convert_note_to_freq([:freq_or_note]).to_f if valid_notes.include?(freq) steps = SCALES[[:scale].to_sym].split(',') freq_index = FREQS.index(freq) = { :freq_or_note => freq.to_s, :waveform => [:waveform], :volume => [:volume], :duration => [:duration], :save => [:save], :verbose => [:verbose] } # play number of degrees of scale supplied or one octave by default degrees = [:degrees] || steps.length if [:verbose] puts "Playing a #{[:scale]} scale..." end 1.upto(degrees.to_i) {|deg| if [:verbose] puts "note: #{NOTE_FREQ.key(freq)}, freq: #{freq}" end # play note Feep::Base.new() # go to the next note in the scale freq_index += steps[deg].to_i # set new note to play next time around freq = [:freq_or_note] = FREQS[freq_index].to_s } else Utils.print_error(:invalid_scale_root_note) end end |