Msynth.StreamStreams.
type 'a t = dt -> 'aThe stream monad.
type 'a stream = 'a tAlias for the stream monad.
Bind four arguments.
Functoriality in two arguments of the stream monad.
val dt : float tCurrent infinitesimal variation of a stream.
val get : 'a t -> 'aCurrent value of a stream (this function might be removed in the future).
module Operations : sig ... endNotations 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 endNotations for usual operations of the stream monad. You usually want to open this module when dealing with streams.
val return : 'a -> 'a tReturn.
val drop : 'a -> unit tForget the result of the stream (this is ignore for streams).
val map : ('a -> 'b) -> 'a -> 'b tMap a function on every sample of a stream.
val iter : ('a -> unit) -> 'a -> 'a tIterate a function on every sample of a stream.
val seq : (unit -> 'a) -> 'a tCreate a stream from a function indicating its value at each call.
val prev : 'a -> 'a -> 'a tValue of the stream at previous instant.
val initialize : 'a list -> 'a -> 'a tSet 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 -> 'a tStream the current value of a reference.
val iterative : (float -> 'a -> 'a) -> 'a -> 'a tGenerate a stream according to dt and previous value.
module StreamList : sig ... endOperations on lists of streams.
module Event : sig ... endEvent hubs. On those, handlers can be registered and will be called each time a new event is emitted.
val cst : 'a -> 'a tCreate a constant stream.
val blank : float tThe constantly zero stream.
val bmul : bool -> float -> float tMultiply 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 tMultiply two streams.
val amp : float -> float -> float tAmplify a stream.
val add : float -> float -> float tAdd two streams.
val mix : float list -> float tAdd a list of streams.
val clip : float -> float tClip a stream in the interval -1., 1..
val octaves : float -> float tConvert octave numbers to multiplicative coefficient for frequency.
val samples : float -> int tNumber 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 tIntegrate a stream.
val periodic :
?init:float ->
?on_reset:(unit -> unit) ->
unit ->
float ->
float tCurrent time for a periodic function.
val timed : ?tempo:float -> ?loop:bool -> (float * 'a) list -> 'a list tCreate 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 tWhen a stream becomes true.
val changes : unit -> bool -> bool tWhen a stream changes value.
Zero-crossing: is true when the stream was negative and becomes positive.
val at : unit -> float -> bool tCheck whether we are at a particular instant.
val frequently : unit -> float -> bool tGenerate an event at a given frequency.
val every : unit -> float -> bool tGenerate an event every period of time.
val is_first : unit -> unit -> bool tWhether this is the first sample of the stream.
val on : (unit -> unit) -> bool -> unit tExecute an action when a stream is true.
val sample_and_hold : unit -> bool -> 'a -> 'a tSample 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) -> 'a -> 'a tExecute a function when a stream change its value.
val random : unit -> ?min:float -> ?max:float -> float -> float tGenerate a random value at given frequency.
module Sample : sig ... endOperations with samples as unit time.
module Osc : sig ... endOscillators.
val sampler :
?interpolation:[ `Closest ] ->
?freq:float ->
'a array ->
float ->
'a tPlay a sample stored in a buffer at various speeds.
module Spectral : sig ... endval fm :
?carrier:[< `Noise | `Saw | `Sine | `Square | `Triangle Sine ] ->
?modulator:[< `Noise | `Saw | `Sine | `Square | `Triangle Sine ] ->
unit ->
?ratio:float ->
float ->
float ->
float tFrequency modulation synthesis.
val random_zero : unit -> ?attraction:float -> float -> float tmodule Envelope : sig ... endval smooth :
?init:float ->
?kind:[< `Exponential | `Linear Exponential ] ->
unit ->
float ->
float ->
float tSmoothen 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 ... endFilters.
module Ringbuffer : sig ... endval delay :
unit ->
?dry:float ->
?wet:float ->
?feedback:float ->
float ->
float ->
float tDelay effect on the stream.
val comb :
?kind:[< `Feedback | `Feedforward Feedback ] ->
unit ->
float ->
float ->
sample ->
sample tA comb filter.
val agc :
?period:float ->
?up:float ->
?down:float ->
?blank:float ->
?target:float ->
?clipping:bool ->
unit ->
float ->
float tAuto gain control.
module Slicer : sig ... endSlicers: those regularly mute the stream according to various patterns.
module Distortion : sig ... endDistortion effects.
val print : ?first:bool -> ?changes:bool -> string -> float -> float tPrint value of stream.
val blink_tempo :
(unit -> unit) ->
(unit -> unit) ->
?duration:float ->
float ->
unit tBlink a led on tempo.
val ms : float -> (float -> unit) -> float -> unit tPower (mean square) of a stream.
val is_blank : float -> float -> float -> bool tIs a stream blank?
module Stereo : sig ... endOperations on stereo streams.
val stereo : 'a -> 'a Stereo.tDuplicate a mono stream to become a stereo stream.
module B : sig ... endBinded functions: those operate on streams instead of samples.