package flac

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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: * - Exceptions raised by the callbacks should be treated * as fatal. The behaviour of the FLAC encoding library is * unknown after interrupted by an exception. * - Encoded data should have the same number of channels as * specified in encoder's parameters and the same number of * samples in each channels. * - See FLAC documentation for informations about the callbacks. * Note in particular that some information about encoded data * such as md5 sum and total samples are only written when a * seek callback is given. * - Variant types for callbacks and encoder are used to make sure * that different type of callbacks (generic, file, ogg) are always * used with the corresponding decoder type.

Types

type 'a t

Type of an encoder.

type write = bytes -> unit

Type of a write callback

type 'a callbacks

Type of a set of callbacks

type generic

Generic type for an encoder

type params = {
  1. channels : int;
  2. bits_per_sample : int;
  3. sample_rate : int;
  4. compression_level : int option;
  5. 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

exception Invalid_metadata

Raised when initiating an encoder with * invalid metadata. You can use `vorbiscomment_entry_name_is_legal` * and `vorbiscomment_entry_value_is_legal` to check submitted metadata.

Functions

val get_callbacks : ?seek:(int64 -> unit) -> ?tell:(unit -> int64) -> write -> generic callbacks

Create a set of encoding callbacks

val vorbiscomment_entry_name_is_legal : string -> bool

Check if a comment label is valid

val vorbiscomment_entry_value_is_legal : string -> bool

Check if a comment value is valid

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

OCaml

Innovation. Community. Security.