Sha256: 2d2c183b1d06e5e0bf87936205e8e325bec67e4e2b459de9905d734ef5e8eb03

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

#!/usr/bin/env ruby

puts "This demo writes raw 8-bit PCM data to a file.  Ctrl-C to stop.  Import the file to Audacity (or a similar audio editing program) to hear the results."

require 'rubyonacid/factories/example'

#This factory chooses notes, play durations, etc.
factory = RubyOnAcid::ExampleFactory.new
    
#This factory randomly resets the meta factory.
@resetter = RubyOnAcid::SkipFactory.new(:odds => 0.99999)

File.open("raw_audio.dat", "w") do |file|
  loop do
    channel_count = factory.get(:channel_count, :max => 3).to_i
    channel_count.times do |i|
      file.putc factory.get(i, :min => 100, :max => 175).to_i
    end
    if @resetter.boolean(:reset)
      factory.reset_assignments
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyonacid-0.4.0 examples/raw_audio.rb