Created
August 11, 2014 23:08
-
-
Save domgetter/8db787793da339a3de2b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'sound' | |
Sound::Device.new {|d| d.play Sound::Data.new.sine_wave(440, 500, 1)} | |
# This is the short way that opens and closes the device automatically | |
# Here is the more verbose way: | |
device = Sound::Device.new("w") | |
format = Sound::Format.new(Sound::Format::PCM) | |
data = Sound::Data.new(format) | |
data.generate_sine_wave(440, 500, 1) | |
device.write(data) | |
device.flush | |
device.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment