Javascript and AudioFiles

Feb 6, 2006 at 10:19pm

Javascript and AudioFiles

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

#24300
Feb 6, 2006 at 10:52pm

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

http://users.skynet.be/crfmw/max

#70063
Feb 7, 2006 at 12:33am

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

#70064
Feb 7, 2006 at 1:01am

If you’re considering C , check out libsndfile.

http://www.mega-nerd.com/libsndfile/

It’s a popular library to read/write all sorts of audiofiles, and I think it
is pretty easy to use.

t_

#70065
Feb 7, 2006 at 1:34am

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

#70066
Feb 7, 2006 at 3:08am

for the record, the patch he is referring to is here:

http://cycling74.com/story/2006/2/6/114353/4118

Recipe 10: BufferOps

:)
AB

#70067
Feb 7, 2006 at 4:05am

#70068
Feb 7, 2006 at 12:59pm

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://
http://www.cassiel.com

#70069
Feb 7, 2006 at 1:12pm

#70070
Feb 7, 2006 at 4:15pm

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

#70071
Feb 8, 2006 at 12:07am

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

#70072
Feb 8, 2006 at 3:48am

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.

#70073
Feb 8, 2006 at 8:49am

> 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

#70074
Feb 8, 2006 at 9:20am

#70075
Feb 8, 2006 at 10:55am

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

#70076
Feb 8, 2006 at 1:58pm

#70077
Feb 8, 2006 at 2:08pm

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

#70078
Feb 8, 2006 at 3:41pm

“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

#70079
Feb 8, 2006 at 4:26pm

#70080
Feb 8, 2006 at 4:38pm

“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

#70081

You must be logged in to reply to this topic.