Reading and writing narray/sound data to file

J

Jon Hope

Hi,

I was wondering if anyone could help.

I'm writing a program that analyses and processes audio in Ruby, using
the audio/sndfile library and narray. Currently I'm analysing a file and
storing the analysis data, an Audio::Sound class, directly into a file
like so:

sf = Audio::Soundfile.open(self.full_filename)
an_file = sf.readf_float(sf.frames)
File.open(self.full_filename + ".anl","w") do |out|
out << an_file
end

So now I have the data in this file stored directly as it is stored in
the an_file NArray.

My problem is that I want to crack open this file and load it directly
into a an Audio::Sound NArray. File.read and IO.read seem to load the
data as one giant string, even if I've previously declared that the
variable i'm loading it into is an Audio::Sound. Is there no way to
simply dump the data as-is?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top