4 ** Copyright (c) 2006, 2007 Erik de Castro Lopo <erikd at mega-nerd dot com>
5 ** WWW: http://www.mega-nerd.com/libsndfile/Ocaml/
7 ** This library is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU Lesser General Public
9 ** License as published by the Free Software Foundation; either
10 ** version 2 of the License, or (at your option) any later version.
12 ** This library is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ** Lesser General Public License for more details.
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with this library; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
95 | Unsupported_encoding
98 exception Error of (error * string)
102 external format_e : major_format_t -> minor_format_t -> endianness_t -> file_format_t = "caml_sf_format_e"
104 let format major minor =
105 format_e major minor ENDIAN_FILE
107 external open_private :
108 string -> (* filename *)
111 int -> (* channels *)
112 int -> (* samplerate *)
113 t = "caml_sf_open_private"
115 let bad_format = format MAJOR_NONE MINOR_NONE
117 let openfile ?(info = (READ, bad_format, 0, 0)) filename =
118 let (mode, fmt, channels, samplerate) = info in
119 open_private filename mode fmt channels samplerate
121 external close : t -> unit = "caml_sf_close"
123 external read : t -> float array -> int = "caml_sf_read"
124 external write : t -> float array -> int = "caml_sf_write"
127 external frames : t -> Int64.t = "caml_sf_frames"
129 external samplerate : t -> int = "caml_sf_samplerate"
131 external channels : t -> int = "caml_sf_channels"
133 external seek : t -> Int64.t -> seek_mode_t -> Int64.t = "caml_sf_seek"
135 external compare : t -> t -> int = "caml_sf_compare"
138 Callback.register_exception "sndfile_open_exn" (Error (No_error, "No error."))