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. Advertisements

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. HNguyen
    Replies:
    4
    Views:
    2,684
    HNguyen
    Dec 21, 2004
  2. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,747
    Andrew Thompson
    Oct 31, 2005
  3. Replies:
    0
    Views:
    690
  4. Replies:
    7
    Views:
    747
  5. Erin K
    Replies:
    2
    Views:
    469
    William Brogden
    Aug 7, 2006
  6. Ven
    Replies:
    6
    Views:
    717
  7. Ara.T.Howard
    Replies:
    0
    Views:
    157
    Ara.T.Howard
    Oct 2, 2004
  8. Replies:
    5
    Views:
    360
    Chris Angelico
    May 14, 2014
Loading...