jump to navigation

RAFL – Ruby Audio File Library January 17, 2010

Posted by Aaron in Audio, Programming.

My Ruby programming brainchild has finally been birthed out into the world. I’ve created a Git repository (after some head scratching), so hopefully people out in the world will be able to put it to use, and possibly improve upon it.

I hereby introduce:

RAFL – Ruby Audio File Library

RAFL is an entirely native Ruby library that allows for reading and writing of WAV files (in its current incarnation). I hope to one day expand it to support other formats. As demonstrated with RAFLcopter.rb (see what I did there?), it is capable of doing the following:

When reading a WAV file:

  • Determine Bit Depth, Sample Rate, and Number of Channels (supports surround sound)
  • Calculate Peak and RMS values
  • Translate sample values into dbFS

When writing a WAV file:

  • Write any number of channels at any sample rate
  • Generate white noise, pink noise and sine waves at any amplitude or frequency

With simple modification of the sample code it is possible to interleave separate audio files into one, etc. It’s currently fairly flexible, and will be more so once I code up a mixer of sorts. The current most major limitation is that it doesn’t support anything about 16-bit audio…it’s one of those things that I’ve been meaning to fix for a long time. RAFL now supports 24-bit audio!

Anyhoo…co developers are welcome if anyone would like to help take it to the next level or put it to use in another project.




1. Steven Garcia - January 22, 2010

This looks really freaking cool – and I LOVE the fact you did it all in Ruby. Thank you for sharing this with us

I wonder how hard would it be to work MP3 support in there – would be pretty fresh to be able to convert formats, specify the quality, etc.

Keep up the good work!

2. Denis - February 21, 2010

I’d love to start and audio blog and be able to record directly from the ROR website. Would this be a way to do it?

Aaron - February 21, 2010

Maybe someday, but not at the moment. RAFL doesn’t have a front end for recording…it can just generate wav files from scratch or pull information from existing ones. I’d love to hear from another developer who has the knowhow in rails to create a means of feeding RAFL a stream of recorded data. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: