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

Perform.Midi.MSignal

Description

This is a piecewise-constant signal, with a subset of the TimeVector operations, as used by Perform.Midi.Perform.

Unlike the signals built on "Util.Segment', this signal shouldn't have samples with the same X.

Synopsis

Documentation

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

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

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

Clip the signal's Y values to lie between (0, 1), inclusive. Return the half-open ranges during which the Y was out of range, if any.

TODO return Y value too, maybe just each (X, Y) where it goes out of range, suppressing adjacent samples.

pitches_share :: Bool -> X -> X -> Midi.Key -> Signal -> Midi.Key -> Signal -> Bool Source #

Can the pitch signals share a channel within the given range?

Pitch is complicated. Like other controls, if the pitch curves are different they may not share a channel. However, if the pitch curves are integral transpositions of each other, and the transposition is not 0, they should share. Unless the overlap occurs during the decay of one or both notes, at which point 0 transposition is ok.

signals_share :: (Y -> Y -> Bool) -> X -> TimeVector.Unboxed -> TimeVector.Unboxed -> Bool Source #

I need to sample points from start to end, including the start and the end. Unfortunately it's not as simple as it seems it should be, especially since this function is a hotspot and must be efficient.

Segment.within may return samples before start to get the proper value so I ignore samples before the start. Start itself is tested explicitly above.

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

constant :: Vector v (Sample y) => y -> v (Sample y) Source #

drop_at_after :: Vector v (Sample y) => X -> v (Sample y) -> v (Sample y) Source #

Truncate a signal so it doesn't include the given X - RealTime.eta. It's just a view of the old signal, so it doesn't allocate a new signal.

drop_before :: Vector v (Sample y) => X -> v (Sample y) -> v (Sample y) Source #

Like TimeVector.drop_before_strict, except if there is no sample at x, keep one sample before it to preserve the value at x. If there are multiple samples at x, drop all but the last one. This is because they indicate a discontinuity, but if you don't care about the previous value, then you don't need the discontinuity.

within :: Vector v (Sample y) => X -> X -> v (Sample y) -> v (Sample y) Source #

Return samples to set the value at start and until end. This means samples start <= t < end, along with one < start if necessary to set the initial value, and the end sample if start == end.

map_y :: Vector v (Sample y) => (y -> y) -> v (Sample y) -> v (Sample y) Source #

map_err :: Vector v a => (a -> Either err a) -> v a -> (v a, [err]) Source #

A map that can return error msgs.