Msynth.Stream
Streams.
type 'a t = dt -> 'a
The stream monad.
type 'a stream = 'a t
Alias for the stream monad.
Bind four arguments.
Functoriality in two arguments of the stream monad.
val dt : float t
Current infinitesimal variation of a stream.
val get : 'a t -> 'a
Current value of a stream (this function might be removed in the future).
module Operations : sig ... end
Notations for usual operations of the stream monad. You usually want to open this module when dealing with streams.
include module type of struct include Operations end
Notations for usual operations of the stream monad. You usually want to open this module when dealing with streams.
val return : 'a -> 'a t
Return.
val drop : 'a -> unit t
Forget the result of the stream (this is ignore
for streams).
val map : ('a -> 'b) -> 'c -> 'd t
Map a function on every sample of a stream.
val iter : ('a -> unit) -> 'b -> 'c t
Iterate a function on every sample of a stream.
val seq : (unit -> 'a) -> 'b t
Create a stream from a function indicating its value at each call.
val prev : 'a -> 'a0 -> 'a1 t
Value of the stream at previous instant.
val initialize : 'a list -> 'b -> 'c t
Set the first values of a stream. This is useful to allocate the buffers in operators which have some.
Stream duplication. Once the left part has been evaluated, the right part can be used as many times as wanted. This has to be used if you need to use a stream more than once, in order to avoid each copy asking for a different sample.
val stream_ref : 'a Stdlib.ref -> 'b t
Stream the current value of a reference.
val iterative : (float -> 'a -> 'b) -> 'c -> 'd t
Generate a stream according to dt and previous value.
module StreamList : sig ... end
Operations on lists of streams.
module Event : sig ... end
Event hubs. On those, handlers can be registered and will be called each time a new event is emitted.
val cst : 'a -> 'b t
Create a constant stream.
val blank : float t
The constantly zero stream.
val bmul : bool -> float -> float t
Multiply a stream by a boolean (interpreted as 0 / 1 for false / true).
Switched multiplication by a constant: if the first is 0, the second stream is not evaluated.
val mul : float -> float -> float t
Multiply two streams.
val amp : float -> float -> float t
Amplify a stream.
val add : float -> float -> float t
Add two streams.
val mix : float list -> float t
Add a list of streams.
val clip : float -> float t
Clip a stream in the interval -1., 1.
.
val octaves : float -> float t
Convert octave numbers to multiplicative coefficient for frequency.
val samples : float -> int t
Number of samples in a given amount of time.
val integrate :
?kind:[< `Euler | `Trapezoidal Euler ] ->
?event:[< `Reset | `Set of float ] Event.t ->
?on_reset:(unit -> unit) ->
?init:float ->
?periodic:bool ->
unit ->
float ->
float t
Integrate a stream.
val periodic :
?init:float ->
?on_reset:(unit -> unit) ->
unit ->
float ->
float t
Current time for a periodic function.
val timed : ?tempo:float -> ?loop:bool -> (float * 'a) list -> 'b list t
Create a stream from timed events, supposed to be sorted. If tempo is not specified, time is assumed in seconds (otherwise, in notes).
val activates : unit -> bool -> bool t
When a stream becomes true.
val changes : unit -> bool -> bool t
When a stream changes value.
Zero-crossing: is true when the stream was negative and becomes positive.
val at : unit -> float -> bool t
Check whether we are at a particular instant.
val frequently : unit -> float -> bool t
Generate an event at a given frequency.
val every : unit -> float -> bool t
Generate an event every period of time.
val is_first : unit -> unit -> bool t
Whether this is the first sample of the stream.
val on : (unit -> unit) -> bool -> unit t
Execute an action when a stream is true.
val sample_and_hold : unit -> bool -> 'a -> 'b t
Sample when a condition is true and hold the sample the rest of the time.
Resample a source from given sampling rate to master sampling rate. The mode
parameter controls the resampling method: `Last
means take the last available value.
val on_change : ?first:bool -> ('a -> unit) -> 'b -> 'c t
Execute a function when a stream change its value.
val random : unit -> ?min:float -> ?max:float -> float -> float t
Generate a random value at given frequency.
module Sample : sig ... end
Operations with samples as unit time.
module Osc : sig ... end
Oscillators.
val sampler :
?interpolation:[ `Closest ] ->
?freq:float ->
'a array ->
float ->
'b t
Play a sample stored in a buffer at various speeds.
module Spectral : sig ... end
val fm :
?carrier:[< `Noise | `Saw | `Sine | `Square | `Triangle Sine ] ->
?modulator:[< `Noise | `Saw | `Sine | `Square | `Triangle Sine ] ->
unit ->
?ratio:float ->
float ->
float ->
float t
Frequency modulation synthesis.
val random_zero : unit -> ?attraction:float -> float -> float t
module Envelope : sig ... end
val smooth :
?init:float ->
?kind:[< `Exponential | `Linear Exponential ] ->
unit ->
float ->
float ->
float t
Smoothen the stream. This is useful to avoid big jumps in controllers. The parmeter is roughly the time taken to reach the desired value.
module Filter : sig ... end
Filters.
module Ringbuffer : sig ... end
val delay :
unit ->
?dry:float ->
?wet:float ->
?feedback:float ->
float ->
float ->
float t
Delay effect on the stream.
val comb :
?kind:[< `Feedback | `Feedforward Feedback ] ->
unit ->
float ->
float ->
sample ->
sample t
A comb filter.
val agc :
?period:float ->
?up:float ->
?down:float ->
?blank:float ->
?target:float ->
?clipping:bool ->
unit ->
float ->
float t
Auto gain control.
module Slicer : sig ... end
Slicers: those regularly mute the stream according to various patterns.
module Distortion : sig ... end
Distortion effects.
val print : ?first:bool -> ?changes:bool -> string -> float -> float t
Print value of stream.
val blink_tempo :
(unit -> unit) ->
(unit -> unit) ->
?duration:float ->
float ->
unit t
Blink a led on tempo.
val ms : float -> (float -> unit) -> float -> unit t
Power (mean square) of a stream.
val is_blank : float -> float -> float -> bool t
Is a stream blank?
module Stereo : sig ... end
Operations on stereo streams.
val stereo : 'a -> 'a Stereo.t
Duplicate a mono stream to become a stereo stream.
module B : sig ... end
Binded functions: those operate on streams instead of samples.