From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8D7F1BC0A for ; Wed, 3 Jan 2007 00:04:28 +0100 (CET) Received: from smtp.syd.people.net.au (smtp.syd.people.net.au [218.214.225.98]) by concorde.inria.fr (8.13.6/8.13.6) with SMTP id l02N4PEr022563 for ; Wed, 3 Jan 2007 00:04:27 +0100 Received: (qmail 19475 invoked from network); 2 Jan 2007 23:04:26 -0000 Received: from unknown (HELO coltrane.mega-nerd.net) (218.214.64.136) by smtp.syd.people.net.au with SMTP; 2 Jan 2007 23:04:26 -0000 Received: from coltrane (coltrane [192.168.1.101]) by coltrane.mega-nerd.net (Postfix) with SMTP id 2812C7B6B for ; Wed, 3 Jan 2007 10:04:21 +1100 (EST) Date: Wed, 3 Jan 2007 10:04:20 +1100 From: Erik de Castro Lopo To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] ANNOUNCE : libsndfile-ocaml alpha Message-Id: <20070103100420.41ae28a4.mle+ocaml@mega-nerd.com> In-Reply-To: <53c655920701021139u76c4bdd9p22efb30a0e44c07@mail.gmail.com> References: <20061222155407.ebe6c272.mle+ocaml@mega-nerd.com> <45923DC2.9000504@ujf-grenoble.fr> <20061227211046.656615d0.mle+ocaml@mega-nerd.com> <20061231080756.66e89d6c.mle+ocaml@mega-nerd.com> <459A3A44.2050700@ujf-grenoble.fr> <20070102222710.9d2e3538.mle+ocaml@mega-nerd.com> <53c655920701021139u76c4bdd9p22efb30a0e44c07@mail.gmail.com> Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed version 2.3.0beta5 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 459AE4F9.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocamldoc:01 val:01 buffer:01 buffer:01 byte:01 byte:01 libs:01 arrays:01 datatypes:01 decoding:01 decoding:01 neck:98 paging:98 sourceforge:01 David Baelde wrote: > Ocaml-vorbis and ocaml-mad take strings as input. Personally, I consider that a mistake :-). I've looked a little at these interfaces say: http://savonet.sourceforge.net/ocamldoc/ocaml-vorbis/Vorbis.html and just picking a single function: val encode_buffer : encoder -> string -> string Encode a wav buffer into ogg. WARNING: the size of the input buffer should be less than or equal to 1024 bytes. and there is no information about how the data is to be stored in the input buffer. As someone reasonably knowledgable in audio processing and audio file formats, I assume the the input string is pairs of bytes, with each pair being a low byte and a high byte of a 16 bit C short, with the endian-ness specified when the encoder is created. So, the above interface you have created is perfectly adequate if all you want to do is read from one file and write to another file. If you want to do more than that; say read from a file, process the data and then write to another file, then this interface is a pain in the neck because you need to convert from the string data to an array of into ot float, process and then convert back to a string. > Reading data from > libsndfile as string would allow a straightforward use of these libs > together. That is an argument that libsndfile should add read_string/write_string methods. I am yet to be convinced. > One might argue that having vorbis and mad work on float arrays would > be better. That's a point. But on the other hand, the current > datatypes avoid some conversions -- at least on the vorbis/mad side. Conversion from short to float and from float to short (done right) is very, very cheap incomparison to the vorbis/mad encoding and decoding. I would argue that you would be unable to measure the difference between decoding to string and decoding to float array because the noise of other factors like disk accesss, paging and other activity on the system would swamp the conversion time. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "To me C++ seems to be a language that has sacrificed orthogonality and elegance for random expediency." -- Meilir Page-Jones