Safe Haskell | Safe-Inferred |
---|
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
- type X = RealTime
- type Y = TimeVector.UnboxedY
- type Signal = TimeVector.Unboxed
- head :: Signal -> Maybe (X, Y)
- last :: Signal -> Maybe (X, Y)
- at :: X -> Signal -> Y
- from_pairs :: [(X, Y)] -> Signal
- to_pairs :: Signal -> [(X, Y)]
- scalar_add :: Y -> Signal -> Signal
- clip_bounds :: Y -> Y -> Signal -> (Signal, [(X, X)])
- pitches_share :: Bool -> X -> X -> Midi.Key -> Signal -> Midi.Key -> Signal -> Bool
- signals_share :: (Y -> Y -> Bool) -> X -> TimeVector.Unboxed -> TimeVector.Unboxed -> Bool
- nns_share :: Midi.Key -> Midi.Key -> Y -> Y -> Bool
- data Sample y = Sample {}
- constant :: Vector v (Sample y) => y -> v (Sample y)
- drop_at_after :: Vector v (Sample y) => X -> v (Sample y) -> v (Sample y)
- drop_before :: Vector v (Sample y) => X -> v (Sample y) -> v (Sample y)
- within :: Vector v (Sample y) => X -> X -> v (Sample y) -> v (Sample y)
- map_y :: Vector v (Sample y) => (y -> y) -> v (Sample y) -> v (Sample y)
- map_err :: Vector v a => (a -> Either err a) -> v a -> (v a, [err])
Documentation
type Y = TimeVector.UnboxedY Source #
type Signal = TimeVector.Unboxed 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.
Instances
Storable (Sample Double) Source # | |
Defined in Util.TimeVectorStorable sizeOf :: Sample Double -> Int # alignment :: Sample Double -> Int # peekElemOff :: Ptr (Sample Double) -> Int -> IO (Sample Double) # pokeElemOff :: Ptr (Sample Double) -> Int -> Sample Double -> IO () # peekByteOff :: Ptr b -> Int -> IO (Sample Double) # pokeByteOff :: Ptr b -> Int -> Sample Double -> IO () # | |
Show y => Show (Sample y) Source # | |
CStorable (Sample Double) Source # | |
Defined in Util.TimeVectorStorable sizeOf :: Sample Double -> Int # alignment :: Sample Double -> Int # peekElemOff :: Ptr (Sample Double) -> Int -> IO (Sample Double) # pokeElemOff :: Ptr (Sample Double) -> Int -> Sample Double -> IO () # peekByteOff :: Ptr b -> Int -> IO (Sample Double) # pokeByteOff :: Ptr b -> Int -> Sample Double -> IO () # | |
Eq y => Eq (Sample y) Source # | |
Pretty y => Pretty (Sample y) Source # | |
Serialize y => Serialize (Sample y) Source # | |
FromJSON (Sample Double) Source # | |
ToJSON (Sample Double) 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.