Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone

Perform.Signal

Contents

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
Show Builtins # 
Instance details

Defined in Derive.Deriver.Monad

Show Library # 
Instance details

Defined in Derive.Library

Pretty ControlRef # 
Instance details

Defined in Derive.BaseTypes

ShowVal ControlRef #

This can only represent constant signals, since there's no literal for an arbitrary signal. Non-constant signals will turn into a constant of whatever was at 0.

Instance details

Defined in Derive.BaseTypes

ToVal ControlRef # 
Instance details

Defined in Derive.RestrictedEnviron

Taggable Control # 
Instance details

Defined in Derive.Deriver.Monad

ToVal ControlRef # 
Instance details

Defined in Derive.Typecheck

Typecheck ControlRef #

Use a TypedFunction or Function instead of this.

Instance details

Defined in Derive.Typecheck

Cacheable Control # 
Instance details

Defined in Derive.Cache

Eq (Signal kind) # 
Instance details

Defined in Perform.Signal

Methods

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

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

Show (Signal kind) # 
Instance details

Defined in Perform.Signal

Methods

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

show :: Signal kind -> String #

showList :: [Signal kind] -> ShowS #

Semigroup (Signal kind) # 
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 #

Semigroup (Stream Control) # 
Instance details

Defined in Derive.Stream

Monoid (Signal kind) # 
Instance details

Defined in Perform.Signal

Methods

mempty :: Signal kind #

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

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

Monoid (Stream Control) #

Signal.Control streams don't need sorted order.

Instance details

Defined in Derive.Stream

DeepSeq.NFData (Signal kind) # 
Instance details

Defined in Perform.Signal

Methods

rnf :: Signal kind -> () #

CRC32.CRC32 (Signal kind) # 
Instance details

Defined in Perform.Signal

Methods

crc32 :: Signal kind -> Word32 #

crc32Update :: Word32 -> Signal kind -> Word32 #

Pretty (Signal kind) # 
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) # 
Instance details

Defined in Perform.Signal

Methods

put :: Putter (Signal kind) Source #

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

Callable (Transformer Control) # 
Instance details

Defined in Derive.Deriver.Monad

Callable (Generator Control) # 
Instance details

Defined in Derive.Deriver.Monad

Callable (TrackCall Control) # 
Instance details

Defined in Derive.Deriver.Monad

ToLibrary (Transformer Control) # 
Instance details

Defined in Derive.Library

ToLibrary (Generator Control) # 
Instance details

Defined in Derive.Library

ToLibrary (TrackCall Control) # 
Instance details

Defined in Derive.Library

data Sample y Source #

Constructors

Sample 

Fields

Instances
CRC32.CRC32 TimeVector.Unboxed # 
Instance details

Defined in Util.TimeVector

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

Defined in Util.TimeVectorStorable

Methods

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

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

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

Defined in Util.TimeVectorStorable

Methods

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

show :: Sample y -> String #

showList :: [Sample y] -> ShowS #

Storable (Sample Double) # 
Instance details

Defined in Util.TimeVectorStorable

CStorable (Sample Double) # 
Instance details

Defined in Util.TimeVectorStorable

ToJSON (Sample Double) # 
Instance details

Defined in Util.TimeVectorStorable

FromJSON (Sample Double) # 
Instance details

Defined in Util.TimeVectorStorable

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

Defined in Util.TimeVector

Serialize.Serialize y => Serialize.Serialize (Sample y) # 
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_unique :: Signal kind -> [(X, Y)] Source #

Like to_pairs, but filter out explicit discontinuities. This is because tests were written before they existed, so a lot will break. TODO update the tests

constant :: Y -> Signal kind Source #

constant_val :: Signal kind -> Maybe Y Source #

Just if the signal is constant.

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 :: X -> Signal kind -> Y Source #

at_maybe :: X -> Signal kind -> 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 #

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_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 #

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.

flat_duration :: Warp -> ScoreTime.ScoreTime Source #

Total duration of horizontal segments in the warp signal. These are the places where compose_hybrid will emit a 1/1 line.