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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 15986BC0A for ; Mon, 1 Jan 2007 20:58:50 +0100 (CET) Received: from smtp.syd.people.net.au (smtp.syd.people.net.au [218.214.225.98]) by discorde.inria.fr (8.13.6/8.13.6) with SMTP id l01JwlCk006865 for ; Mon, 1 Jan 2007 20:58:48 +0100 Received: (qmail 18566 invoked from network); 1 Jan 2007 19:58:47 -0000 Received: from unknown (HELO coltrane.mega-nerd.net) (218.214.64.136) by smtp.syd.people.net.au with SMTP; 1 Jan 2007 19:58:47 -0000 Received: from coltrane (coltrane [192.168.1.101]) by coltrane.mega-nerd.net (Postfix) with SMTP id 54EC07B6B; Tue, 2 Jan 2007 06:58:45 +1100 (EST) Date: Tue, 2 Jan 2007 06:58:45 +1100 From: Erik de Castro Lopo To: caml-list@yquem.inria.fr Cc: matthieu.dubuget@laposte.net Subject: Re: [Caml-list] ANNOUNCE : libsndfile-ocaml alpha Message-Id: <20070102065845.c6558b18.mle+ocaml@mega-nerd.com> In-Reply-To: <4599205A.7050802@laposte.net> 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> <1167535885.27287.66.camel@rosella.wigram> <20061231152305.694fd3e9.mle+ocaml@mega-nerd.com> <20061231110831.GA21198@furbychan.cocan.org> <20070101095114.911ca90d.mle+ocaml@mega-nerd.com> <4599205A.7050802@laposte.net> 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 discorde with ID 459967F7.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 matthieu:01 dubuget:01 bigarray:01 arrays:01 buffer:01 buffer:01 ocaml:01 bigarray:01 read-only:01 bigarrays:01 chunks:01 wrote:01 caml-list:01 data:02 Matthieu Dubuget wrote: > Is it really the case? I thought that it was possible to create a > bigarray wrapping a C array without > copying datas. I do not know how to achieve this for float arrays? When reading files libsndfile always does at least one copy; from the disk to the array supplied by the caller. This single copy only occurs if the data requested by the caller is the same format and endian-ness as the format requested by the caller. When the data formats are not the same two copies are required; from the disk to and buffer internal to libsndfile and then a copy/data conversion to the buffer suppiled by the caller. The above doesn't change regardless of whether the caller supplies an Ocaml float array or a bigarray. In addition, I also regard the most common case to be the one where a data convesion takes place between the file format and the format requested by the caller. > This could be interesting for read-only access or in-place modifications? I don't see how this would be different float array vs bigarray. > Another very interesting feature of bigarrays is the memory mapping of a > file as a big array, very useful to work with BIG files. Firstly, libsndfile doesn't use mem-mapping because the most common case is where the disk format is different from the file format. Secondly I consider a big file to be one containing say an hour of multiple channels (say 8) of 32 bit float data at high sample rates (say 96kHz). That file is: 96000 * 60 * 60 * 8 * 4 bytes => 11059.200 Mbytes => 11.059 Gbytes Nobody is going to load the whole of that file into memory at once. Instead, the most sensible and most general approach is to load it in in chunks. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "I saw `cout' being shifted "Hello world" times to the left and stopped right there." -- Steve Gonedes