Forum: Ruby Reading and writing narray/sound data to file

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jon H. (Guest)
on 2009-02-17 03:57

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 =
    an_file = sf.readf_float(sf.frames) + ".anl","w") do |out|
      out << an_file

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. and 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?

Jon H. (Guest)
on 2009-02-17 05:13
Having been able to declutter my brain I'm guessing I maybe should use
the Marshal module to serialize the data before saving, then use Marshal
to load it in situ?
This topic is locked and can not be replied to.