Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Derive.Call.ControlUtil

Contents

Description

Utilities that emit Signal.Controls and ControlMods.

Synopsis

Documentation

type SRate = RealTime.RealTime Source #

Sampling rate.

type Curve = Double -> Double Source #

Interpolation function. This maps 0--1 to the desired curve, which is also normalized to 0--1.

interpolator call

type InterpolatorTime a = Either (Sig.Parser BaseTypes.Duration) (GetTime a, Text) Source #

Left for an explicit time arg. Right is for an implicit time, inferred from the args, along with an extra bit of documentation to describe it.

interpolator_call Source #

Arguments

:: CallName 
-> (Sig.Parser arg, arg -> Curve)

get args for the function and the interpolating function

-> InterpolatorTime Control 
-> Generator Control 

from_env :: Sig.Parser (Maybe Signal.Y) Source #

Use this for calls that start from the previous value, to give a way to override that behaviour.

curve_env :: Sig.Parser Curve Source #

For calls whose curve can be configured.

interpolator_variations_ :: Taggable a => (CallName -> get_arg -> InterpolatorTime a -> call) -> Expr.Symbol -> CallName -> get_arg -> [(Expr.Symbol, call)] Source #

Create the standard set of interpolator calls. Generic so it can be used by PitchUtil as well.

standard_interpolators :: (forall arg. Expr.Symbol -> CallName -> (Sig.Parser arg, arg -> Curve) -> [(Expr.Symbol, Generator result)]) -> CallMaps result Source #

control functions

cf_interpolater :: Text -> Curve -> BaseTypes.ControlFunction Source #

Stuff a curve function into a ControlFunction.

cf_to_curve :: BaseTypes.ControlFunction -> Curve Source #

Convert a ControlFunction back into a curve function.

interpolate

place_range :: Typecheck.Normalized -> ScoreTime -> BaseTypes.Duration -> Deriver (RealTime.RealTime, RealTime.RealTime) Source #

Given a placement, start, and duration, return the range thus implied.

segment Source #

Arguments

:: SRate 
-> Bool

include the initial sample

-> Bool

add a sample at end time if one doesn't naturally land there

-> Curve 
-> RealTime.RealTime 
-> Signal.Y 
-> RealTime.RealTime 
-> Signal.Y 
-> Signal.Control 

Interpolate between the given points.

slope

limited_slope :: SRate -> Maybe Signal.Y -> Maybe Signal.Y -> Signal.Y -> Double -> RealTime.RealTime -> RealTime.RealTime -> Signal.Control Source #

Make a linear sloped line, with optional lower and upper limits. TODO I could support Curve but it would make the intercept more complicated.

exponential

expon :: Double -> Curve Source #

Negative exponents produce a curve that jumps from the "starting point" which doesn't seem too useful, so so hijack the negatives as an easier way to write 1/n. That way n is smoothly departing, while -n is smoothly approaching.

expon2 :: Double -> Double -> Curve Source #

I could probably make a nicer curve of this general shape if I knew more math.

bezier

guess_x :: (Double -> (Double, Double)) -> Curve Source #

As far as I can tell, there's no direct way to know what value to give to the bezier function in order to get a specific x. So I guess with binary search.

sigmoid :: Double -> Double -> Double -> Point Source #

Generate a sigmoid curve. The first weight is the flatness at the start, and the second is the flatness at the end. Both should range from 0--1.

bezier3 :: Point -> Point -> Point -> Point -> Double -> Point Source #

Cubic bezier curve.

breakpoints

breakpoints :: SRate -> Curve -> [(RealTime.RealTime, Signal.Y)] -> Signal.Control Source #

Create line segments between the given breakpoints.

signal_breakpoints :: Monoid sig => ([(RealTime.RealTime, y)] -> sig) -> (RealTime.RealTime -> y -> RealTime.RealTime -> y -> sig) -> [(RealTime.RealTime, y)] -> sig Source #

distribute :: RealTime.RealTime -> RealTime.RealTime -> [a] -> [(RealTime.RealTime, a)] Source #

Distribute the values evenly over the given time range.

control mod