Week 5 Sample Code
Thursday, April 24th, 2008Hey everyone, I’ve attached the week 5 examples here. Enjoy!
Hey everyone, I’ve attached the week 5 examples here. Enjoy!
Hey everyone! If you’d like to do the extra credit problem, here is a test that you can use to benchmark your solution:
require 'digest/md5'
require 'test/unit'
def test_encode_alac_speed
in_filename = 'test/data/3db65f4f0e1b01a3307c3c2c2ddedbb7.wav'
out_filename = 'test/data/out.raw'
assert_equal('3db65f4f0e1b01a3307c3c2c2ddedbb7',
Digest::MD5.hexdigest(File.read(in_filename))
)
File.open(in_filename, 'rb') { |file|
File.open(out_filename, 'wb') { |outf|
while data = file.read(4096 * 2 * 2)
outf.write(Week4.encode_alac(data))
end
}
}
assert_equal('62047625a959a52469e81a90d852329e',
Digest::MD5.hexdigest(File.read(out_filename)))
end
You’ll need to drop this file in to the test/data directory. But watch out, the file is 29MB. It took about 64 seconds to process on my machine. The extra credit is to make the encode_alac method faster, and to make the method work with Ruby 1.9. There will be a prize for the fastest implementation as well as a prize for a Ruby 1.9 implementation.
I will also come up with a solution and throw it in to the mix. Good luck, and have fun!
Here is a more detailed list of the topics that we’ll be discussing. I hope to cover all of these topics before the class is over. We may cover more material depending on how fast the class goes. Please leave comments or email me about things you’d like to discuss but don’t see in the list!
Metaprogramming
Concurrency
Network Programming
Patterns in Ruby
Alternate Ruby Implementations
Packaging and Extending Ruby
All of these books are recommended but not necessarily required. If you have the Pickaxe, you probably won’t need the Ruby Way, and vice-versa.