module Synthesizer.Dimensional.Map where
import qualified Synthesizer.Dimensional.Sample as Sample
import qualified Synthesizer.Dimensional.Arrow as ArrowD
import qualified Synthesizer.Dimensional.Signal.Private as SigA
import qualified Synthesizer.Dimensional.Amplitude.Flat as Flat
import qualified Synthesizer.Dimensional.Amplitude as Amp
import Control.Arrow (Arrow, )
import Control.Category (Category, )
import qualified Synthesizer.Generic.Signal as SigG
import qualified Number.DimensionTerm as DN
import qualified Algebra.DimensionTerm as Dim
import qualified Algebra.Module as Module
import qualified Algebra.Field as Field
import qualified Data.Function as Func
import qualified Data.Tuple as Tuple
import Data.Tuple.HT as TupleHT (swap, )
import Prelude hiding (map, fst, snd, id, )
type T = ArrowD.T (->)
type Single amp0 amp1 yv0 yv1 =
ArrowD.Single (->) amp0 amp1 yv0 yv1
consFlip ::
(Sample.Amplitude sample0 ->
(Sample.Amplitude sample1,
Sample.Displacement sample0 ->
Sample.Displacement sample1)) ->
T sample0 sample1
consFlip f =
ArrowD.Cons $ TupleHT.swap . f
apply ::
(SigG.Transform sig yv0, SigG.Transform sig yv1) =>
Single amp0 amp1 yv0 yv1 ->
SigA.T rate amp0 (sig yv0) ->
SigA.T rate amp1 (sig yv1)
apply = ArrowD.apply
applyFlat ::
(Flat.C yv0 amp0,
SigG.Transform sig yv0, SigG.Transform sig yv1) =>
Single (Amp.Flat yv0) amp1 yv0 yv1 ->
SigA.T rate amp0 (sig yv0) ->
SigA.T rate amp1 (sig yv1)
applyFlat = ArrowD.applyFlat
forceDimensionalAmplitude ::
(Dim.C v, Field.C y, Module.C y yv, Arrow arrow) =>
DN.T v y ->
ArrowD.Single arrow (Amp.Dimensional v y) (Amp.Dimensional v y) yv yv
forceDimensionalAmplitude =
ArrowD.forceDimensionalAmplitude
forcePrimitiveAmplitude ::
(Amp.Primitive amp, Arrow arrow) =>
ArrowD.Single arrow amp amp yv yv
forcePrimitiveAmplitude =
independent (const Amp.primitive) Func.id
mapAmplitude ::
(Amp.C amp0, Amp.C amp1, Arrow arrow) =>
(amp0 -> amp1) ->
ArrowD.Single arrow amp0 amp1 yv yv
mapAmplitude f =
independent f Func.id
mapAmplitudeSameType ::
(Arrow arrow) =>
(Sample.Amplitude sample -> Sample.Amplitude sample) ->
ArrowD.T arrow sample sample
mapAmplitudeSameType f =
independent f Func.id
independent ::
(Arrow arrow) =>
(Sample.Amplitude sample0 -> Sample.Amplitude sample1) ->
(Sample.Displacement sample0 -> Sample.Displacement sample1) ->
ArrowD.T arrow sample0 sample1
independent =
ArrowD.independentMap
id ::
(Category arrow) =>
ArrowD.T arrow sample sample
id = ArrowD.id
double ::
(Arrow arrow) =>
ArrowD.T arrow sample (sample, sample)
double =
ArrowD.double
fst ::
(Arrow arrow) =>
ArrowD.T arrow (sample0,sample1) sample0
fst =
let aux = Tuple.fst
in independent aux aux
snd ::
(Arrow arrow) =>
ArrowD.T arrow (sample0,sample1) sample1
snd =
let aux = Tuple.snd
in independent aux aux
swap ::
(Arrow arrow) =>
ArrowD.T arrow (sample0,sample1) (sample1,sample0)
swap =
let aux = TupleHT.swap
in independent aux aux
balanceRight ::
(Arrow arrow) =>
ArrowD.T arrow
((sample0,sample1), sample2) (sample0, (sample1,sample2))
balanceRight =
let aux = \((a,b), c) -> (a, (b,c))
in independent aux aux
balanceLeft ::
(Arrow arrow) =>
ArrowD.T arrow
(sample0, (sample1,sample2)) ((sample0,sample1), sample2)
balanceLeft =
let aux = \(a, (b,c)) -> ((a,b), c)
in independent aux aux
packTriple ::
(Arrow arrow) =>
ArrowD.T arrow
(sample0,(sample1,sample2)) (sample0,sample1,sample2)
packTriple =
let aux = \(a,(b,c)) -> (a,b,c)
in independent aux aux
unpackTriple ::
(Arrow arrow) =>
ArrowD.T arrow
(sample0,sample1,sample2) (sample0,(sample1,sample2))
unpackTriple =
let aux = \(a,b,c) -> (a,(b,c))
in independent aux aux