Sha256: fc27a77637b0028e24b11ddb954be2ab00acf7b7ced5fe21e7ca32efbc714619

Contents?: true

Size: 549 Bytes

Versions: 3

Compression:

Stored size: 549 Bytes

Contents

module Serinette
  # Sourced Noises; will provide noises sourced from wav files found in a
  # particular directory
  class SourceNoise < Noise
    SOUND_DIRECTORY = './data/sounds/*'

    def initialize
      init_wavefile
    end

    def init_wavefile
      sox = SoxWrapper.generate_and_run input: SourceNoise.pick_random_file
      @wavefile = sox.output.path
    end

    def self.pick_random_file
      sound_files = Dir.glob(SOUND_DIRECTORY).sort
      num = (0..sound_files.length - 1).to_a.sample

      sound_files[num]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
serinette-0.0.3 lib/serinette/source_noise.rb
serinette-0.0.2 lib/serinette/source_noise.rb
serinette-0.0.0.pre lib/serinette/source_noise.rb