#!/usr/bin/ruby require 'audiofile' f = AudioFile.new("foo.wav") print "foo.wav has #{f.channels} channels.\n" data = f.read 1000 f.pos = 2000 frames = f.frame_count rate = f.sample_rate seconds = frames.to_f / rate.to_f print "foo.wav is #{seconds} long.\n" f.close