hsc3-0.19.1: Haskell SuperCollider
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.SC3.Common.Envelope

Description

Envelope generators.

Synopsis

Curve

data Envelope_Curve a Source #

Envelope curve indicator input.

Constructors

EnvStep 
EnvLin 
EnvExp 
EnvSin 
EnvWelch

Note: not implemented at SC3

EnvNum a 
EnvSqr 
EnvCub 
EnvHold 

Instances

Instances details
Eq a => Eq (Envelope_Curve a) Source # 
Instance details

Defined in Sound.SC3.Common.Envelope

Show a => Show (Envelope_Curve a) Source # 
Instance details

Defined in Sound.SC3.Common.Envelope

type Envelope_Curve_2 a = T2 (Envelope_Curve a) Source #

Envelope curve pair.

type Envelope_Curve_3 a = T3 (Envelope_Curve a) Source #

Envelope curve triple.

type Envelope_Curve_4 a = T4 (Envelope_Curve a) Source #

Envelope curve quadruple.

env_curve_shape :: Num a => Envelope_Curve a -> a Source #

Convert Envelope_Curve to shape value.

map env_curve_shape [EnvSin,EnvSqr] == [3,6]

env_curve_value :: Num a => Envelope_Curve a -> a Source #

The value of EnvCurve is non-zero for EnvNum.

map env_curve_value [EnvWelch,EnvNum 2] == [0,2]

env_curve_coerce :: (a -> b) -> Envelope_Curve a -> Envelope_Curve b Source #

Apply f to EnvNum value.

Envelope

data Envelope a Source #

SC3 envelope segment model

Constructors

Envelope 

Fields

Instances

Instances details
Functor Envelope Source #

fmap = envelope_coerce

Instance details

Defined in Sound.SC3.Common.Envelope

Methods

fmap :: (a -> b) -> Envelope a -> Envelope b #

(<$) :: a -> Envelope b -> Envelope a #

Eq a => Eq (Envelope a) Source # 
Instance details

Defined in Sound.SC3.Common.Envelope

Methods

(==) :: Envelope a -> Envelope a -> Bool #

(/=) :: Envelope a -> Envelope a -> Bool #

Show a => Show (Envelope a) Source # 
Instance details

Defined in Sound.SC3.Common.Envelope

Methods

showsPrec :: Int -> Envelope a -> ShowS #

show :: Envelope a -> String #

showList :: [Envelope a] -> ShowS #

envelope_coerce :: (a -> b) -> Envelope a -> Envelope b Source #

Apply f to all a at Envelope.

envelope :: Num a => [a] -> [a] -> [Envelope_Curve a] -> Envelope a Source #

Variant without release and loop node inputs (defaulting to nil).

Sound.SC3.Plot.plotEnvelope [envelope [0,1,0] [3,2] [EnvSin,EnvSin]]

envelope_duration :: Num n => Envelope n -> n Source #

Duration of Envelope, ie. sum . env_times.

envelope_n_segments :: Integral i => Envelope n -> i Source #

Number of segments at Envelope, ie. length . env_times.

envelope_segment_ix :: (Ord a, Num a) => Envelope a -> a -> Maybe Int Source #

Determine which envelope segment a given time t falls in.

type Envelope_Segment t = (t, t, t, t, Envelope_Curve t) Source #

A set of start time, start level, end time, end level and curve.

envelope_segment :: Num t => Envelope t -> Int -> Envelope_Segment t Source #

Extract envelope segment given at index i.

envelope_segments :: Num t => Envelope t -> [Envelope_Segment t] Source #

Extract all segments.

pack_envelope_segments :: Num t => [Envelope_Segment t] -> ([t], [t], [Envelope_Curve t]) Source #

Transform list of Envelope_Segments into lists (env_levels,env_times,env_curves).

envelope_is_normal :: (Eq n, Num n) => Envelope n -> Bool Source #

An envelope is normal if it has no segments with zero duration.

envelope_normalise :: (Num a, Ord a) => Envelope a -> Envelope a Source #

Normalise envelope by deleting segments of zero duration.

envelope_at :: (Ord t, Floating t) => Envelope t -> t -> t Source #

Get value for Envelope at time t, or zero if t is out of range. By convention if the envelope has a segment of zero duration we give the rightmost value.

envelope_render :: (Ord t, Floating t, Enum t) => Int -> Envelope t -> [(t, t)] Source #

Render Envelope to breakpoint set of n equi-distant places.

envelope_table :: (Ord t, Floating t, Enum t) => Int -> Envelope t -> [t] Source #

Contruct a lookup table of n places from Envelope.

envelope_curves :: Envelope a -> [Envelope_Curve a] Source #

Variant on env_curves that expands the, possibly empty, user list by cycling (if not empty) or by filling with EnvLin.

envelope_sc3_array :: Num a => Envelope a -> Maybe [a] Source #

Linear SC3 form of Envelope data.

Form is: l0 #t reset loop l1 t0 c0 c0' ...

envelope_sc3_array (envelope [0,1] [0.1] [EnvLin]) == Just [0,1,-99,-99,1,0.1,1,0]

let {l = [0,0.6,0.3,1.0,0]
    ;t = [0.1,0.02,0.4,1.1]
    ;c = [EnvLin,EnvExp,EnvNum (-6),EnvSin]
    ;e = Envelope l t c Nothing Nothing
    ;r = [0,4,-99,-99,0.6,0.1,1,0,0.3,0.02,2,0,1,0.4,5,-6,0,1.1,3,0]}
in envelope_sc3_array e == Just r

envelope_sc3_ienvgen_array :: Num a => Envelope a -> Maybe [a] Source #

IEnvGen SC3 form of Envelope data.

l = [0,0.6,0.3,1.0,0]
t = [0.1,0.02,0.4,1.1]
c = [EnvLin,EnvExp,EnvNum (-6),EnvSin]
e = Envelope l t c Nothing Nothing 0
r = [0,0,4,1.62,0.1,1,0,0.6,0.02,2,0,0.3,0.4,5,-6,1,1.1,3,0,0]
envelope_sc3_ienvgen_array e == Just r

env_delay :: Envelope a -> a -> Envelope a Source #

Delay the onset of the envelope (add initial segment).

env_circle_z :: Fractional a => a -> a -> Envelope_Curve a -> Envelope a -> Envelope a Source #

Connect releaseNode (or end) to first node of envelope. z is a value that is first zero and thereafter one. tc & cc are time and curve from first to last.

env_circle_0 :: Fractional a => Envelope a -> Envelope a Source #

env_circle_z with cycle time of zero.

Construct

envTrapezoid_f :: Num t => (t -> t -> t, t -> t -> t) -> t -> t -> t -> t -> Envelope t Source #

Trapezoidal envelope generator.

Requires (and (=) functions returning 1 for true and 0 for false.

The arguments are: 1. shape determines the sustain time as a proportion of dur, zero is a triangular envelope, one a rectangular envelope; 2. skew determines the attack/decay ratio, zero is an immediate attack and a slow decay, one a slow attack and an immediate decay; 3. duration in seconds; 4. amplitude as linear gain.

envCoord :: Num n => [(n, n)] -> n -> n -> Envelope_Curve n -> Envelope n Source #

Coordinate based static envelope generator. Points are (time,value) pairs.

let e = envCoord [(0,0),(1/4,1),(1,0)] 1 1 EnvLin
envelope_sc3_array e == Just [0,2,-99,-99,1,1/4,1,0,0,3/4,1,0]
import Sound.SC3.Plot 
plotEnvelope [envCoord [(0,0),(1/4,1),(1,0)] 1 1 EnvLin]

envPairs :: (Num n, Ord n) => [(n, n)] -> Envelope_Curve n -> Envelope n Source #

Segments given as pairs of (time,level). The input is sorted by time before processing.

envPairs [(0, 1), (3, 1.4), (2.1, 0.5)] EnvSin

envPerc_c :: Num a => a -> a -> a -> Envelope_Curve_2 a -> Envelope a Source #

Variant envPerc with user specified 'Envelope_Curve a'.

envPerc :: Num a => a -> a -> Envelope a Source #

Percussive envelope, with attack, release, level and curve inputs.

envTriangle :: Fractional a => a -> a -> Envelope a Source #

Triangular envelope, with duration and level inputs.

let e = envTriangle 1 0.1
in envelope_sc3_array e = Just [0,2,-99,-99,0.1,0.5,1,0,0,0.5,1,0]

envSine :: Fractional a => a -> a -> Envelope a Source #

Sine envelope, with duration and level inputs.

let e = envSine 0 0.1
in envelope_sc3_array e == Just [0,2,-99,-99,0.1,0,3.0,0,0,0,3,0]

data LINEN a Source #

Parameters for LINEN envelopes.

linen_def :: Fractional t => LINEN t Source #

SC3 defaults for LINEN.

envLinen_r :: Num a => LINEN a -> Envelope a Source #

Record (LINEN) variant of envLinen.

envLinen_c :: Num a => a -> a -> a -> a -> Envelope_Curve_3 a -> Envelope a Source #

Variant of envLinen with user specified 'Envelope_Curve a'.

envLinen :: Num a => a -> a -> a -> a -> Envelope a Source #

Linear envelope parameter constructor.

e = envLinen 0 1 0 1
s = envelope_segments e
p = pack_envelope_segments s
p == (env_levels e,env_times e,env_curves e)

data ADSR a Source #

Parameters for ADSR envelopes. The sustain level is given as a proportion of the peak level.

adsr_def :: Fractional n => ADSR n Source #

SC3 defaults for ADSR.

envADSR :: Num a => a -> a -> a -> a -> a -> Envelope_Curve a -> a -> Envelope a Source #

Attack, decay, sustain, release envelope parameter constructor.

envADSR_def :: Num a => a -> a -> a -> a -> Envelope a Source #

Variant with defaults for pL, c and b.

envADSR_r :: Num a => ADSR a -> Envelope a Source #

Record (ADSR) variant of envADSR.

data ADSSR a Source #

Parameters for Roland type ADSSR envelopes.

envADSSR :: Num a => a -> a -> a -> a -> a -> a -> a -> Envelope_Curve a -> a -> Envelope a Source #

Attack, decay, slope, sustain, release envelope parameter constructor.

envADSSR_r :: Num a => ADSSR a -> Envelope a Source #

Record (ADSSR) variant of envADSSR.

data ASR a Source #

Parameters for ASR envelopes.

Constructors

ASR 

asr_def :: Fractional t => ASR t Source #

SC3 default values for ASR.

envASR_c :: Num a => a -> a -> a -> Envelope_Curve_2 a -> Envelope a Source #

SC3 .asr has singular curve argument, hence _c suffix.

envASR :: Num a => a -> a -> a -> Envelope_Curve a -> Envelope a Source #

Attack, sustain, release envelope parameter constructor.

c = 3
r = Just [0,2,1,-99,0.1,3,c,0,0,2,c,0]
envelope_sc3_array (envASR 3 0.1 2 EnvSin) == r

envASR_r :: Num a => ASR a -> Envelope a Source #

Record (ASR) variant of envASR.

envStep :: Num a => [a] -> [a] -> Maybe Int -> Maybe Int -> Envelope a Source #

All segments are horizontal lines.

envXYC :: Num n => [(n, n, Envelope_Curve n)] -> Envelope n Source #

Segments given as triples of (time,level,curve). The final curve is ignored.

envXYC [(0, 1, EnvSin), (2.1, 0.5, EnvLin), (3, 1.4, EnvLin)]

envXYC_sort :: (Num n, Ord n) => [(n, n, Envelope_Curve n)] -> Envelope n Source #

Variant where the input is sorted by time before processing.

envXYC_sort [(0, 1, EnvSin), (3, 1.4, EnvLin), (2.1, 0.5, EnvLin)]