Module Audio

module Audio: sig .. end

Operations on audio data.


val samples_of_seconds : int -> float -> int

At given sample rate, number of samples in given amount of time.

val seconds_of_samples : int -> int -> float

At given sample rate, duration of given number of samples.

val lin_of_dB : float -> float

Convert decibels to linear coefficient.

val dB_of_lin : float -> float

Convert linear coefficient to decibels.

module Sample: sig .. end

Operations on samples.

module Note: sig .. end

Operations on notes.

module Mono: sig .. end

Operations on mono buffers (with only one channel).

type buffer = Mono.buffer array 

An audio buffer.

val create : int -> int -> buffer

create chans len creates a buffer with chans channels and len samples as duration.

val create_same : buffer -> buffer

Create a buffer with the same number of channels and duration as the given buffer.

val clear : buffer -> int -> int -> unit

Clear the buffer (sets all the samples to zero).

val copy : buffer -> buffer

Copy the given buffer.

val append : buffer -> buffer -> buffer
val channels : buffer -> int
val duration : buffer -> int

Duration of a buffer in samples.

val to_mono : buffer -> Mono.buffer

Convert a buffer to a mono buffer by computing the mean of all channels.

val of_mono : Mono.buffer -> buffer

Convert a mono buffer into a buffer. Notice that the original mono buffer is not copied an might thus be modified afterwards.

module U8: sig .. end
module S16LE: sig .. end
module S16BE: sig .. end
module S24LE: sig .. end
module S32LE: sig .. end
val resample : ?mode:[ `Linear | `Nearest ] ->
float -> buffer -> int -> int -> buffer
val blit : buffer -> int -> buffer -> int -> int -> unit

Same as Array.blit for audio data.

val clip : buffer -> int -> int -> unit
val amplify : float -> buffer -> int -> int -> unit

Amplify a portion of the buffer by a given coefficient.

val pan : float -> buffer -> int -> int -> unit

Pan a stereo buffer from left to right (the buffer should have exactly two channels!). The coefficient should be between -1. and 1..

val add : buffer -> int -> buffer -> int -> int -> unit
val add_coeff : buffer -> int -> float -> buffer -> int -> int -> unit
module Buffer_ext: sig .. end

Buffers of variable size.

module Ringbuffer: sig .. end

Circular ringbuffers.

module Ringbuffer_ext: sig .. end
module Analyze: sig .. end
module Effect: sig .. end

Audio effects.

module Generator: sig .. end

Sound generators.

module IO: sig .. end

Operation for reading and writing audio data from files, streams or devices.