Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Erik de Castro Lopo <mle+ocaml@mega-nerd.com>
To: caml-list@yquem.inria.fr
Cc: matthieu.dubuget@laposte.net
Subject: Re: [Caml-list] ANNOUNCE : libsndfile-ocaml alpha
Date: Tue, 2 Jan 2007 06:58:45 +1100	[thread overview]
Message-ID: <20070102065845.c6558b18.mle+ocaml@mega-nerd.com> (raw)
In-Reply-To: <4599205A.7050802@laposte.net>

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


  reply	other threads:[~2007-01-01 19:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-22  4:54 Erik de Castro Lopo
2006-12-27  9:32 ` [Caml-list] " Vu Ngoc San
2006-12-27 10:10   ` Erik de Castro Lopo
2006-12-27 10:42     ` Erik de Castro Lopo
2006-12-30 21:07     ` Erik de Castro Lopo
2006-12-31  3:31       ` skaller
2006-12-31  4:23         ` Erik de Castro Lopo
2006-12-31 11:08           ` Richard Jones
2006-12-31 22:51             ` Erik de Castro Lopo
2007-01-01 14:53               ` Matthieu Dubuget
2007-01-01 19:58                 ` Erik de Castro Lopo [this message]
2007-01-02  0:51                   ` skaller
2007-01-02  1:14                     ` Erik de Castro Lopo
2007-01-02  5:26                       ` Erick Tryzelaar
2007-01-02  5:39                         ` Erik de Castro Lopo
     [not found]                       ` <1167765505.5341.12.camel@rosella.wigram>
2007-01-02 22:37                         ` Erik de Castro Lopo
2007-01-02 23:46                           ` Gerd Stolpmann
2007-01-03  1:59                             ` Pal-Kristian Engstad
2007-01-03  2:49                             ` Markus Mottl
2007-01-02  7:47                     ` Christoph Bauer
2006-12-31 19:05           ` skaller
2006-12-31 22:54             ` Erik de Castro Lopo
2007-01-02 10:56       ` Vu Ngoc San
2007-01-02 11:27         ` Erik de Castro Lopo
2007-01-02 19:39           ` David Baelde
2007-01-02 23:04             ` Erik de Castro Lopo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070102065845.c6558b18.mle+ocaml@mega-nerd.com \
    --to=mle+ocaml@mega-nerd.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=matthieu.dubuget@laposte.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox