Skip to content

Instantly share code, notes, and snippets.

@joshnuss
Last active August 29, 2015 14:01
Show Gist options
  • Save joshnuss/eec6492bf56bf5baf705 to your computer and use it in GitHub Desktop.
Save joshnuss/eec6492bf56bf5baf705 to your computer and use it in GitHub Desktop.
White Noise Generator
=begin
White Noise Generator
http://en.wikipedia.org/wiki/White_noise
Generates a .wav file with random noise.
Copy to phone, and run on loop.
`gem install wavefile`
=end
require 'wavefile'
include WaveFile
format = Format.new(:mono, :pcm_16, 44100)
data = 1000000.times.map { rand(65535) }
buffer = Buffer.new(data, format)
Writer.new("noise.wav", format) do |writer|
writer.write(buffer)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment