Module: Gemwarrior::Music

Defined in:
lib/gemwarrior/misc/music.rb

Class Method Summary collapse

Class Method Details

.cue(sequence) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gemwarrior/misc/music.rb', line 6

def self.cue(sequence)
  defaults = {
    :freq_or_note => 440, 
    :waveform     => 'saw', 
    :volume       => 0.3, 
    :duration     => 500,
    :notext       => true
  }

  Thread.start {
    sequence.each do |note|
      note_to_play  = note[:freq_or_note]
      waveform      = note[:waveform].nil? ? defaults[:waveform] : note[:waveform]
      volume        = note[:volume].nil? ? defaults[:volume] : note[:volume]
      duration      = note[:duration].nil? ? defaults[:duration] : note[:duration]
      notext        = note[:notext].nil? ? defaults[:notext] : note[:notext]

      Feep::Base.new({
        :freq_or_note => note_to_play, 
        :waveform     => waveform, 
        :volume       => volume, 
        :duration     => duration,
        :notext       => notext
      })
    end
  }
end