Module Flac.Encoder


module Encoder: sig .. end
Encode native FLAC data


Usage



A typical use of the FLAC encoder is the following:
 (* A function to write encoded data *)
 let write = (..a function of type write..) in
 (* Create the encoding callbacks *)
 let callbacks = Flac.Encoder.get_callbacks write in
 (* Define the parameters and comments *)
 let params = (..a value of type params ..) in
 let comments = [("title","FLAC encoding example")] in
 (* Create an encoder *)
 let enc = Flac.Encoder.create ~comments params callbacks in
 (* Encode data *)
 let data = (..a value of type float array array.. in 
  Flac.Encoder.process enc callbacks data ;
 (..repeat encoding process..)
 (* Close encoder *)
 Flac.Encoder.finish enc callbacks

Remarks:



Types


type 'a t 
Type of an encoder.
type write = string -> unit 
Type of a write callback
type 'a callbacks 
Type of a set of callbacks
type generic 
Generic type for an encoder

type params = {
   channels : int;
   bits_per_sample : int;
   sample_rate : int;
   compression_level : int option;
   total_samples : int64 option;
}
Type of encoding parameters
type comments = (string * string) list 
(Vorbis) comments for encoding

Exceptions


exception Invalid_data
Raised when submiting invalid data to encode

Functions


val get_callbacks : ?seek:(int64 -> unit) ->
?tell:(unit -> int64) ->
write -> generic callbacks
Create a set of encoding callbacks
val create : ?comments:comments ->
params -> 'a callbacks -> 'a t
Create an encoder
val process : 'a t -> 'a callbacks -> float array array -> unit
Encode some data
val finish : 'a t -> 'a callbacks -> unit
Terminate an encoder. Causes the encoder to flush remaining encoded data. The encoder should not be used anymore afterwards.

Convenience


val from_s16le : string -> int -> float array array
Convert S16LE pcm data to an audio array for encoding WAV and raw PCM to flac.
module File: sig .. end
Encode to a local file