module Decoder:Decode native FLAC datasig
..end
(* Raise this when streams has ended. *) exception End_of_stream (* Define a read function *) let input = (..a function of type read..) in (* Define a write function *) let output = (..a function of type write..) in (* Create callbacks *) let callbacks = Flac.Decoder.get_callbacks input write in (* Create an unitialized decoder *) let decoder = Flac.Decoder.create in (* Initialize decoder *) let decoder,info,comments = Flac.Decoder.init decoder in (..do something with info and comments..) (* Decode data *) match Flac.Decoder.state decoder c with | `Search_for_metadata | `Read_metadata | `Search_for_frame_sync | `Read_frame -> Flac.Decoder.process decoder callbacks | _ -> raise End_of_stream
Some remarks:
Ogg.Not_enough_data
.process
. Termination may not be detected nor raise an
exception so it is the caller's responsibility to check
on this. type 'a
dec
type 'a
t
typewrite =
float array array -> unit
typeread =
int -> string * int
type 'a
callbacks
type
generic
type
info = {
|
sample_rate : |
|
channels : |
|
bits_per_sample : |
|
total_samples : |
|
md5sum : |
typecomments =
string * (string * string) list
typestate =
[ `Aborted
| `End_of_stream
| `Memory_allocation_error
| `Ogg_error
| `Read_frame
| `Read_metadata
| `Search_for_frame_sync
| `Search_for_metadata
| `Seek_error
| `Uninitialized ]
exception Lost_sync
exception Bad_header
exception Frame_crc_mismatch
exception Unparseable_stream
exception Not_flac
val get_callbacks : ?seek:(int64 -> unit) ->
?tell:(unit -> int64) ->
?length:(unit -> int64) ->
?eof:(unit -> bool) ->
read ->
write -> generic callbacks
val create : 'a callbacks -> 'a dec
val init : 'a dec ->
'a callbacks ->
'a t * info * comments option
val process : 'a t -> 'a callbacks -> unit
val seek : 'a t -> 'a callbacks -> Int64.t -> bool
false
.
Furthermore, if the decoder state is `Seek_error
then the decoder must be flushed or reset
before decoding can continue.val flush : 'a t -> 'a callbacks -> bool
`Search_for_frame_sync
. This will also turn
off MD5 checking.val reset : 'a t -> 'a callbacks -> bool
`Search_for_metadata
. MD5 checking will be restored to its original
setting.
If the decoder is seekable, the decoder will also attempt to seek to
the beginning of the stream. If this rewind fails, this function will
return false
. It follows that reset
cannot be used when decoding
from stdin
.
If the decoder is not seekable (i.e. no seek callback was provided)
it is the duty of the client to start feeding data from the beginning
of the stream on the next process
.
val state : 'a t -> 'a callbacks -> state
val to_s16le : float array array -> string
module File:sig
..end