Get Version


→ ‘rawdio’


Rawdio is a library for taking new, beautiful sounds and putting them in old, clunky WAV files.


sudo gem install rawdio

The basics

require 'rubygems'
require 'rawdio'

white_noise = Rawdio::WAV.new
8000.times { white_noise << rand(255).chr }

That’ll give you a low-quality one-second WAV of noise. Awesome!

The basic idea is that you build up your sound in a byte string, which you can just keep appending to the Rawdio::WAV object with << (or you can just access the @data attribute directly, if that’s your style), and then you write it out.

Demonstration of usage

require 'rubygems'
require 'rawdio'

beautiful_music = Rawdio::WAV.new(:channels => 2, :sample_rate => 44100, :bits_per_sample => 8)
beautiful_music.data = some_crazy_string_made_from_mapping_sine_waves_onto_ascii

You can see there the options you have when creating a new Rawdio::WAV object. That’s basically the leeway you get with WAVs.

There are helper methods on the way to help generate sine, square, and triangle waves. Promise.

How to submit patches

Read the 8 steps for fixing other people’s code. And then send your patch to Chris Shea

The trunk repository is svn://code.tie-rack.org/cms/rawdio/trunk/ for anonymous access.


This code is free to use under the terms of the MIT license.


Comments (and patches) are welcome. Send an email to Chris Shea.

website generated via Dr Nic's newgem, on 21st November 2007