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

Synth.Shared.Signal

Description

Signal implementation.

Synopsis

Documentation

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 y => Pretty (Sample y) Source # 
Instance details

Defined in Util.TimeVector

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

Defined in Util.TimeVectorStorable

Methods

put :: Putter (Sample y) Source #

get :: Get (Sample y) Source #

FromJSON (Sample Double) Source # 
Instance details

Defined in Util.TimeVectorStorable

ToJSON (Sample Double) Source # 
Instance details

Defined in Util.TimeVectorStorable

type NoteNumber = Signal.Signal Signal.NoteNumberSig Source #

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

type Y = Double Source #

x_to_y :: X -> Y Source #

y_to_x :: Y -> X Source #

y_to_score :: Y -> ScoreTime Source #

Some control signals may be interpreted as score time.

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

constant_val :: Signal.Signal kind -> Maybe Y Source #

Just if the signal is constant.

zero_or_below :: Signal.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.

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

coerce :: Signal.Signal kind1 -> Signal.Signal kind2 Source #

Sometimes signal types need to be converted.

with_ptr :: Signal.Display -> (X -> Ptr (Sample Y) -> Int -> IO a) -> IO a Source #

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

clip_after_keep_last :: X -> Signal.Signal kind -> Signal.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.

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

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

Clip signal to never go below the given value.

This is way more complicated than the piecewise constant version.

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

map_x :: (X -> X) -> Signal.Signal kind -> Signal.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.Signal kind -> Signal.Signal kind Source #

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

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

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

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

integrate :: Signal.Tempo -> Signal.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.