Last active
August 29, 2015 14:01
-
-
Save joshnuss/eec6492bf56bf5baf705 to your computer and use it in GitHub Desktop.
White Noise Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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