Reading and writing narray/sound data to file

Discussion in 'Ruby' started by Jon Hope, Feb 17, 2009.

  1. Jon Hope

    Jon Hope Guest

    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
    --
    Posted via http://www.ruby-forum.com/.
    Jon Hope, Feb 17, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,462
    Andrew Thompson
    Oct 31, 2005
  2. Replies:
    0
    Views:
    489
  3. Ara.T.Howard
    Replies:
    0
    Views:
    80
    Ara.T.Howard
    Oct 2, 2004
  4. Brian Schröder

    NArray scalar addition and subtraction

    Brian Schröder, Nov 28, 2004, in forum: Ruby
    Replies:
    1
    Views:
    91
    Brian Schröder
    Nov 28, 2004
  5. Daniel Martin

    YAML and NArray

    Daniel Martin, Aug 18, 2007, in forum: Ruby
    Replies:
    1
    Views:
    106
    Daniel Martin
    Aug 19, 2007
Loading...

Share This Page