caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* reading audio
@ 2006-12-04  9:19 Vu Ngoc San
  2006-12-04  9:31 ` [Caml-list] " David Baelde
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vu Ngoc San @ 2006-12-04  9:19 UTC (permalink / raw)
  To: Caml Mailing List

Hello

is there a library available for reading wav files in ocaml and, say,
convert it to a bigarray or something equivalent ?

I had a look at sdl_mixer, which does read wav files, but it seems that
you don't have physical accesss to the audio if you wanted to modifiy it
in memory. (or I missed something). All you can do is play/mix it. I
guess it should not be too hard to look at the C code and come up with a
nice ocaml interface for converting the audio chunk into a bigarray, but
that's beyond my capabilities.

I looked at the list archive and back in 2003 some people had similar
whishes. Maybe this have evolved ?

Thanks for you help.


San



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04  9:19 reading audio Vu Ngoc San
@ 2006-12-04  9:31 ` David Baelde
  2006-12-04 10:01   ` Erik de Castro Lopo
  2006-12-04 12:56   ` Vu Ngoc San
  2006-12-04 11:42 ` Richard Jones
  2006-12-04 14:20 ` Eric Cooper
  2 siblings, 2 replies; 8+ messages in thread
From: David Baelde @ 2006-12-04  9:31 UTC (permalink / raw)
  To: Vu Ngoc San; +Cc: Caml Mailing List

Hi,

It would be nice to have a binding of libsndfile for that kind of
purpose. Unfortunately I don't think we have one yet.

For what it's worth, there is a Wav module at
<https://svn.sourceforge.net/svnroot/savonet/trunk/liquidsoap/src/tools/>.
Simply remove the conversion of format to Mixer.format and there
shouldn't be any external dependency left.

I know that it doesn't handle some formats, but .. it's good enough
for us most of the time. If anybody does ocaml-libsndfile I'd be happy
to use it instead.

Cheers.
-- 
David


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04  9:31 ` [Caml-list] " David Baelde
@ 2006-12-04 10:01   ` Erik de Castro Lopo
  2006-12-04 10:35     ` Vu Ngoc San
  2006-12-04 12:56   ` Vu Ngoc San
  1 sibling, 1 reply; 8+ messages in thread
From: Erik de Castro Lopo @ 2006-12-04 10:01 UTC (permalink / raw)
  To: caml-list; +Cc: david.baelde

David Baelde wrote:

> Hi,
> 
> It would be nice to have a binding of libsndfile for that kind of
> purpose. Unfortunately I don't think we have one yet.

Since I (the main author of libsndfile) is also an Ocaml user
I really should get around to doing that.

However, the Ocaml version would not ba able to have functions
for reading shorts or ints, just a function for reading doubles
(as Ocaml floats). Same for the write side.

libsndfile would however do the conversion between the ocaml 
level floats at whatever the disk file format required.

Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"The problem with using C++ ... is that there's already a strong
tendency in the language to require you to know everything before
you can do anything." -- Larry Wall


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04 10:01   ` Erik de Castro Lopo
@ 2006-12-04 10:35     ` Vu Ngoc San
  0 siblings, 0 replies; 8+ messages in thread
From: Vu Ngoc San @ 2006-12-04 10:35 UTC (permalink / raw)
  To: Erik de Castro Lopo; +Cc: caml-list, david.baelde

Erik de Castro Lopo a écrit :
> David Baelde wrote:
> 
>> Hi,
>>
>> It would be nice to have a binding of libsndfile for that kind of
>> purpose. Unfortunately I don't think we have one yet.
> 
> Since I (the main author of libsndfile) is also an Ocaml user
> I really should get around to doing that.




That would be great. I am in fact teaching some signal processing, and
showing off my demos using ocaml instead of (****bad***) would be wonderful.

San


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04  9:19 reading audio Vu Ngoc San
  2006-12-04  9:31 ` [Caml-list] " David Baelde
@ 2006-12-04 11:42 ` Richard Jones
  2006-12-04 19:30   ` Erik de Castro Lopo
  2006-12-04 14:20 ` Eric Cooper
  2 siblings, 1 reply; 8+ messages in thread
From: Richard Jones @ 2006-12-04 11:42 UTC (permalink / raw)
  To: Vu Ngoc San; +Cc: caml-list

On Mon, Dec 04, 2006 at 10:19:34AM +0100, Vu Ngoc San wrote:
> is there a library available for reading wav files in ocaml and, say,
> convert it to a bigarray or something equivalent ?

The WAV format is pretty simple.  Have you tried just mapping the
file?  You'll need to ignore the first "data samples" covering the
first 44 bytes of the file (the header).

http://ccrma.stanford.edu/courses/422/projects/WaveFormat/

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04  9:31 ` [Caml-list] " David Baelde
  2006-12-04 10:01   ` Erik de Castro Lopo
@ 2006-12-04 12:56   ` Vu Ngoc San
  1 sibling, 0 replies; 8+ messages in thread
From: Vu Ngoc San @ 2006-12-04 12:56 UTC (permalink / raw)
  To: david.baelde; +Cc: Caml Mailing List


> For what it's worth, there is a Wav module at
> <https://svn.sourceforge.net/svnroot/savonet/trunk/liquidsoap/src/tools/>.


Great. This looks like what I need.

San


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04  9:19 reading audio Vu Ngoc San
  2006-12-04  9:31 ` [Caml-list] " David Baelde
  2006-12-04 11:42 ` Richard Jones
@ 2006-12-04 14:20 ` Eric Cooper
  2 siblings, 0 replies; 8+ messages in thread
From: Eric Cooper @ 2006-12-04 14:20 UTC (permalink / raw)
  To: caml-list

On Mon, Dec 04, 2006 at 10:19:34AM +0100, Vu Ngoc San wrote:
> is there a library available for reading wav files in ocaml and, say,
> convert it to a bigarray or something equivalent ?

I wrote one a few years ago as part of a little application to display
WAV files graphically:
    http://www.cs.cmu.edu/~ecc/gwav.tar.gz

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] reading audio
  2006-12-04 11:42 ` Richard Jones
@ 2006-12-04 19:30   ` Erik de Castro Lopo
  0 siblings, 0 replies; 8+ messages in thread
From: Erik de Castro Lopo @ 2006-12-04 19:30 UTC (permalink / raw)
  To: caml-list

Richard Jones wrote:

> The WAV format is pretty simple.  Have you tried just mapping the
> file?  You'll need to ignore the first "data samples" covering the
> first 44 bytes of the file (the header).
> 
> http://ccrma.stanford.edu/courses/422/projects/WaveFormat/

Yes, the most common WAV files are easy to parse but there are
a gazzillion extensions and corner cases to take care of.

So *please* don't lead people down that path, bcause next thing
they will be writting WAV files as well and they will make
a mistake and not follow the spec (so called) correctly and their
software will become popular and I (as the author of libsndfile)
will have to add yet another hack to work around someone else's
broken WAV file (libsndfile is already full of these).

I'm busy ATM, but give me a couple of weeks and I will make an
ocaml-libsndfile.

Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"Whenever the C++ language designers had two competing ideas as to
how they should solve some problem, they said, "OK, we'll do them
both". So the language is too baroque for my taste." -- Donald E Knuth


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-12-04 19:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-04  9:19 reading audio Vu Ngoc San
2006-12-04  9:31 ` [Caml-list] " David Baelde
2006-12-04 10:01   ` Erik de Castro Lopo
2006-12-04 10:35     ` Vu Ngoc San
2006-12-04 12:56   ` Vu Ngoc San
2006-12-04 11:42 ` Richard Jones
2006-12-04 19:30   ` Erik de Castro Lopo
2006-12-04 14:20 ` Eric Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).