Sha256: 92299e1e8ceaefbe642a5cf79e0e0000d71e7bb96083b9054716ea97d832c83a

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# lib/gemwarrior/misc/music.rb
# Music cue

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

      th = Thread.new do
        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
      
      return th.join
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemwarrior-0.8.5 lib/gemwarrior/misc/music.rb
gemwarrior-0.8.3 lib/gemwarrior/misc/music.rb
gemwarrior-0.8.2 lib/gemwarrior/misc/music.rb