Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Perform.Signal

Description

Sample values are doubles, which means each point in the signal is 8*2 bytes. The double resolution is overkill for the value, but float would be too small for time given the time stretching.

TODO split this into Float and Double versions since only Warp really needs Double. Or does Warp really need Double?

Synopsis

types

data Signal kind Source #

A Signal is a Segment.Signal of Y values, which are just Doubles. It takes a phantom type parameter to make the signal's intended uses a little clearer. There are type aliases for the various flavors of signal below, but it really is just documentation and anyone who wants to operate on a generic signal can take a Signal kind.

Instances

Instances details
Show Builtins Source # 
Instance details

Defined in Derive.Deriver.Monad

Show Library Source # 
Instance details

Defined in Derive.Library

Cacheable Control Source # 
Instance details

Defined in Derive.Cache

Taggable Control Source # 
Instance details

Defined in Derive.Deriver.Monad

ToVal ControlRef Source # 
Instance details

Defined in Derive.REnv

ShowVal ControlRef Source # 
Instance details

Defined in Derive.DeriveT

ShowVal ControlDeriver Source # 
Instance details

Defined in Derive.Deriver.Monad

ToVal ControlRef Source # 
Instance details

Defined in Derive.Typecheck

ToVal TypedSignal Source #

Signal.Control has ToVal but not Typecheck, because calls should be using Function.

Instance details

Defined in Derive.Typecheck

Typecheck ControlDeriver Source # 
Instance details

Defined in Derive.Sig

Typecheck TypedSignal Source # 
Instance details

Defined in Derive.Typecheck

Typecheck Control Source # 
Instance details

Defined in Derive.Typecheck

Pretty.Pretty ControlRef Source # 
Instance details

Defined in Derive.DeriveT

Monoid (Stream Control) Source #

Signal.Control streams don't need sorted order.

Instance details

Defined in Derive.Stream

Semigroup (Stream Control) Source # 
Instance details

Defined in Derive.Stream

Callable (Generator Control) Source # 
Instance details

Defined in Derive.Deriver.Monad

Callable (TrackCall Control) Source # 
Instance details

Defined in Derive.Deriver.Monad

Callable (Transformer Control) Source # 
Instance details

Defined in Derive.Deriver.Monad

ToLibrary (Generator Control) Source # 
Instance details

Defined in Derive.Library

ToLibrary (TrackCall Control) Source # 
Instance details

Defined in Derive.Library

ToLibrary (Transformer Control) Source # 
Instance details

Defined in Derive.Library

ShowVal (Typed Control) Source # 
Instance details

Defined in Derive.DeriveT

Monoid (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

mempty :: Signal kind #

mappend :: Signal kind -> Signal kind -> Signal kind #

mconcat :: [Signal kind] -> Signal kind #

Semigroup (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

(<>) :: Signal kind -> Signal kind -> Signal kind #

sconcat :: NonEmpty (Signal kind) -> Signal kind #

stimes :: Integral b => b -> Signal kind -> Signal kind #

Show (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

showsPrec :: Int -> Signal kind -> ShowS #

show :: Signal kind -> String #

showList :: [Signal kind] -> ShowS #

DeepSeq.NFData (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

rnf :: Signal kind -> () #

Eq (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

(==) :: Signal kind -> Signal kind -> Bool #

(/=) :: Signal kind -> Signal kind -> Bool #

Pretty.Pretty (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

pretty :: Signal kind -> Text Source #

format :: Signal kind -> Doc Source #

formatList :: [Signal kind] -> Doc Source #

Serialize.Serialize (Signal kind) Source # 
Instance details

Defined in Perform.Signal

Methods

put :: Putter (Signal kind) Source #

get :: Serialize.Get (Signal kind) Source #

data Sample y Source #

Constructors

Sample 

Fields

Instances

Instances details
Storable (Sample Double) Source # 
Instance details

Defined in Util.TimeVectorStorable

Show y => Show (Sample y) Source # 
Instance details

Defined in Util.TimeVectorStorable

Methods

showsPrec :: Int -> Sample y -> ShowS #

show :: Sample y -> String #

showList :: [Sample y] -> ShowS #

CStorable (Sample Double) Source # 
Instance details

Defined in Util.TimeVectorStorable

Eq y => Eq (Sample y) Source # 
Instance details

Defined in Util.TimeVectorStorable

Methods

(==) :: Sample y -> Sample y -> Bool #

(/=) :: Sample y -> Sample y -> Bool #

Pretty.Pretty y => Pretty.Pretty (Sample y) Source # 
Instance details

Defined in Util.TimeVector

Serialize.Serialize y => Serialize.Serialize (Sample y) Source # 
Instance details

Defined in Util.TimeVectorStorable

FromJSON (Sample Double) Source # 
Instance details

Defined in Util.TimeVectorStorable

ToJSON (Sample Double) Source # 
Instance details

Defined in Util.TimeVectorStorable

type Y = Double Source #

x_to_y :: X -> Y Source #

y_to_x :: Y -> X Source #

y_to_score :: Y -> ScoreTime.ScoreTime Source #

Some control signals may be interpreted as score time.

type Tempo = Signal TempoSig Source #

A tempo is a normal Control signal, except that instead of going into the control map, it gets turned into a Warp and goes into the warp map.

type Warp = Signal WarpSig Source #

A tempo warp maps score time to real time. Of course the type is still (ScoreTime, Y), so functions that process Warps have to convert.

type Control = Signal ControlSig Source #

This is the type of performer-interpreted controls that go into the event's control map.

type NoteNumber = Signal NoteNumberSig Source #

This is the type of pitch signals used by the performer, after the scale has been factored out.

type Display = Signal DisplaySig Source #

This is the type of signals which are sent to the UI for display.

construct / destruct

from_sample :: X -> Y -> Signal kind Source #

from_pairs :: [(X, Y)] -> Signal kind Source #

to_pairs :: Signal kind -> [(X, Y)] Source #

to_pairs_desc :: Signal kind -> [(X, Y)] Source #

constant :: Y -> Signal kind Source #

constant_val :: Signal kind -> Maybe Y Source #

Just if the signal is constant.

zero_or_below :: Signal kind -> Bool Source #

True if the signal becomes <=0 at any point. This assumes the signal starts at X==0, which is true of signals from control tracks only.

prepend :: Signal kind -> Signal kind -> Signal kind Source #

unfoldr :: (state -> Maybe ((X, Y), state)) -> state -> Signal kind Source #

coerce :: Signal kind1 -> Signal kind2 Source #

Sometimes signal types need to be converted.

query

null :: Signal kind -> Bool Source #

at :: Signal kind -> X -> Y Source #

at_maybe :: Signal kind -> X -> Maybe Y Source #

head :: Signal kind -> Maybe (X, Y) Source #

last :: Signal kind -> Maybe (X, Y) Source #

minimum :: Signal kind -> Y Source #

maximum :: Signal kind -> Y Source #

find :: (X -> Y -> Bool) -> Signal kind -> Maybe (X, Y) Source #

transform

drop_after :: X -> Signal kind -> Signal kind Source #

drop_before :: X -> Signal kind -> Signal kind Source #

clip_after :: X -> Signal kind -> Signal kind Source #

clip_before :: X -> Signal kind -> Signal kind Source #

clip_before_pairs :: X -> Signal kind -> [(X, Y)] Source #

clip_after_keep_last :: X -> Signal kind -> Signal kind Source #

Like clip_after, but always put a sample at the end time, even if it's flat. This is not necessary if you keep this as a Signal since (<>) will extend the final sample, but might be if you go to breakpoints via to_pairs.

shift :: X -> Signal kind -> Signal kind Source #

invert :: Signal kind -> Signal kind Source #

scale :: Y -> Y -> Y Source #

hacks

scalar transformation

scalar_max :: Y -> Signal kind -> Signal kind Source #

Clip signal to never go below the given value.

This is way more complicated than the piecewise constant version.

scalar_add :: Y -> Signal kind -> Signal kind Source #

scalar_subtract :: Y -> Signal kind -> Signal kind Source #

scalar_multiply :: Y -> Signal kind -> Signal kind Source #

scalar_divide :: Y -> Signal kind -> Signal kind Source #

scalar_scale :: Y -> Signal kind -> Signal kind Source #

map_x :: (X -> X) -> Signal kind -> Signal kind Source #

Map Xs. The slopes will definitely change unless the function is adding a constant, but presumably that's what you want.

map_y :: X -> (Y -> Y) -> Signal kind -> Signal kind Source #

Map Ys. This resamples the signal, so it's valid for a nonlinear function.

map_y_linear :: (Y -> Y) -> Signal kind -> Signal kind Source #

If the function is linear, there's no need to resample.

map_err :: (Sample Y -> Either err (Sample Y)) -> Signal kind -> (Signal kind, [err]) Source #

special functions

integrate :: Tempo -> Warp Source #

Integrate the signal.

Since the output will have more samples than the input, this needs a sampling rate. The sampling rate determines the resolution of the tempo track. So it can probably be fairly low resolution before having a noticeable impact.

TODO this is only called after map_y at srate, so it's already been resampled. Maybe it would be more efficient to remove srate from Segment.integrate.