Javascript and AudioFiles


    Feb 06 2006 | 10:19 pm
    Hi all.
    I am still puzzled by an efficient method of splitting and merging my
    audio files faster than real-time. I never thought of using
    Javascript to do so, but it might be a good idea... the only problem
    is that I can't make any sense of the info I get.
    Is there a way to read the file header so I can get the sampling
    rate, the number of channel, according to a certain file type? Does
    it make sense to do it like this, if I don't want to import the file
    in a buffer~?
    Any hint will help!
    pa

    • Feb 06 2006 | 10:52 pm
      I started working on JavaScipt code that parses aiff files (I think I
      even post it, but I may be wrong - I can send it to you if you want)
      but I stopped because file accesses were just to slow. I think Java is
      the way to go (or C), unfortunately, I had no time yet to study enough
      Java to start working on this. I'm sure there must be Java libraries
      available to parse sound files.
      p
      _____________________________
      Patrick Delges
      Centre de Recherches et de Formation Musicales de Wallonie
    • Feb 07 2006 | 12:33 am
      On around Feb 6, 2006, at 23:52, Patrick Delges said something like:
      > I started working on JavaScipt code that parses aiff files (I think I
      > even post it, but I may be wrong - I can send it to you if you want)
      > but I stopped because file accesses were just to slow. I think Java is
      > the way to go (or C)
      About ten years ago a guy at Harvard named Ben Denckla put together a
      "AIFF DSP Framework" that did all the grunt work of handling AIFF files
      and gave you a simple micro-API for writing code that played with the
      audio data without worrying about headers and stuff.
      It ran on SunOS, HP-UX, Ultrix, NeXTStep, OSF, and Mac OS... I suppose
      that was System 7.1 or something.
      I built some code with it as recently as six years ago using
      Metrowerks. It was not hard. It *was* in C (we're talking 1994).
      -- P.
      -------------- http://www.bek.no/~pcastine/Litter/ --------------
      Peter Castine | ^
      | Litter Power & Litter Bundle for Jitter
      pcastine@gmx.net |
      pcastine@bek.no | iCE: Sequencing, Recording, and Interface Building
      4-15@kagi.com | for Max/MSP
      | Extremely cool
      | http://www.dspaudio.com
      | http://www.dspaudio.com/software/software.html
    • Feb 07 2006 | 1:01 am
      If you're considering C , check out libsndfile.
      It's a popular library to read/write all sorts of audiofiles, and I think it
      is pretty easy to use.
      t_
    • Feb 07 2006 | 1:34 am
      pierre,
      this has been a subject of debate on the list/forum many times. more
      on that below. You should check back in the forum. I believe
      andrew benson posted an example of using jitter matrices to replicate
      cut copy and paste of AUDIO buffers.
      The debate-------------------------
      The Argument of the people who think this functionality should be
      explicitly supported on the list is that "If your coming to max to
      escape commercial software, Max should at least support the
      functionality of the most basic non-real-time audio programs like
      sequencing, cut,copy,merge and paste"
      The argument of the people who think the functionality should not be
      included are those who believe that rather than focus on max's
      ability to replicate existing software, it should focus on being a
      live instrument unto itself. and if your listening and processing in
      real time, these functions are not the best tools for the job.
      Nearly anything is possible in max. When the folks at C74 post
      examples, you see just how limited by your own knowledge base you
      are. The example mentioned above really proves this.
      Hopefully I was fair and balanced
      -matt
      . . . . . . . . . . . .
      Http://www.EstateSound.com
      Http://ideasforstuff.blogspot.com
      . . . . . . . . . . . .
    • Feb 07 2006 | 3:08 am
      for the record, the patch he is referring to is here:
      Recipe 10: BufferOps
      :)
      AB
    • Feb 07 2006 | 4:05 am
    • Feb 07 2006 | 12:59 pm
      On 6 Feb 2006, at 22:52, Patrick Delges wrote:
      > I'm sure there must be Java libraries available to parse sound files.
      I played with this a year or so ago. The Java Media Framework (JMF)
      is what you're after, but you're at the mercy of whatever codecs are
      available on your system.
      -- N.
      nick rothwell -- composition, systems, performance -- http://
      www.cassiel.com
    • Feb 07 2006 | 4:15 pm
      Patrick, Thijs and Nick
      Thanks for your help.
      > I started working on JavaScipt code that parses aiff files (I think
      > I even post it, but I may be wrong - I can send it to you if you want)
      Patrick, I have not found it in the archives. Can you please post it
      on the list?
      > If you're considering C , check out libsndfile.
      and
      >> I'm sure there must be Java libraries available to parse sound files.
      >
      > I played with this a year or so ago. The Java Media Framework (JMF)
      > is what you're after, but you're at the mercy of whatever codecs
      > are available on your system.
      I will look into this later today, and post to the list anything I
      can get out of it. I will probably start with java, so we can use it
      on both platform.
      pa
    • Feb 08 2006 | 12:07 am
      If you look in the java-doc/mxj~ examples directory there is
      an example of using a class we provide to read audio files into
      memory. May or may not be helpful to you.
      09.mxj~.audiofilebuf.pat
      Topher
    • Feb 08 2006 | 3:48 am
      I'm using the class that Topher suggests and it works pretty well : MUCH faster than reading a file through buffer and sending the sample data to JS.
      While we're on the suggest, I'm unable to load sounds longer than 40 minutes, it gives a memory error, is there a way to increase the amount of memory the Java machine can use ?
      Thanks.
    • Feb 08 2006 | 8:49 am
      > While we're on the suggest, I'm unable to load sounds longer than
      > 40 minutes, it gives a memory error, is there a way to increase the
      > amount of memory the Java machine can use ?
      Probably du to the fact that the index counter is in int? I will
      report soon... Thank you Topher for that indication, I will post my
      results soon.
      pa
    • Feb 08 2006 | 9:20 am
    • Feb 08 2006 | 10:55 am
      Hello Topher and all.
      2 small questions:
      1. When I look at the AudioFileBuffer Class Reference, I cannot see
      any open modes (write, for instance...) Does it mean that this class
      opens a file pointer in read mode only?
      2. Should we move that thread in java-dev, even if I am a dumb
      newbie ;-)
      pa
    • Feb 08 2006 | 2:08 pm
      Pierre Alexandre Tremblay wrote:
      > 1. When I look at the AudioFileBuffer Class Reference, I cannot see any
      > open modes (write, for instance...) Does it mean that this class opens
      > a file pointer in read mode only?
      AFAIK it just fills an in-memory buffer with the audio data, and
      provides some read-only meta-data. If you want to write audio data or
      have random access from disk then one of JavaSound (pretty basic) or the
      Java Media Framework will be the thing, I think.
      > 2. Should we move that thread in java-dev
      I should have thought so, yes.
      Cheers,
      Owen
    • Feb 08 2006 | 3:41 pm
      "You can change this in max.java.config.txt, in the Java folder of your
      C74 directory."
      Just checked that file and I can't seem to find anything related to memory..
      Thanks,,
      Nat
    • Feb 08 2006 | 4:26 pm
    • Feb 08 2006 | 4:38 pm
      "You need to set the jvm option for the maximum heap size, which is done by passing the switch -Xmx, e.g. -Xmx256m gives you 256 MB."
      Many thanks ! I changed to 512 and it loads fine now !!
      Nat