module Synthesizer.Dimensional.Cyclic.Signal where
import qualified Synthesizer.Format as Format
import qualified Synthesizer.Dimensional.RatePhantom as RP
import qualified Synthesizer.Dimensional.Straight.Signal as SigS
import qualified Synthesizer.State.Signal as Sig
import qualified Algebra.Additive as Additive
import NumericPrelude
import PreludeBase
import Prelude ()
newtype T seq yv =
Cons {
samples :: seq yv
}
instance Functor seq => Functor (T seq) where
fmap f = Cons . fmap f . samples
instance Format.C seq => Format.C (T seq) where
format p = Format.format p . samples
instance (Format.C seq, Show y) => Show (T seq y) where
showsPrec = Format.format
type R s yv = RP.T s (T Sig.T) yv
fromPeriod :: Sig.T yv -> R s yv
fromPeriod = RP.fromSignal . Cons
fromPeriodList :: [yv] -> R s yv
fromPeriodList = fromPeriod . Sig.fromList
toPeriod :: R s yv -> Sig.T yv
toPeriod = samples . RP.toSignal
fromSignal :: Additive.C yv => Int -> SigS.R s yv -> R s yv
fromSignal n =
fromPeriod . sum . Sig.sliceVert n . SigS.toSamples
toSignal :: Additive.C yv => R s yv -> SigS.R s yv
toSignal =
SigS.fromSamples . Sig.cycle . toPeriod