{-# LANGUAGE NoImplicitPrelude #-}{-# LANGUAGE MultiParamTypeClasses #-}{-# LANGUAGE FlexibleInstances #-}moduleSynthesizer.Filter.OneWaywhereimportSynthesizer.Filter.BasicimportqualifiedSynthesizer.Plain.InterpolationasInterpolationimportqualifiedSynthesizer.Plain.Filter.NonRecursiveasFiltNRimportNumber.Complex(cis)importqualifiedAlgebra.ModuleasModuleimportqualifiedAlgebra.RingasRingimportqualifiedAlgebra.AdditiveasAdditiveimportAlgebra.Module(linearComb)importAlgebra.Additive(zero)importPreludeBaseimportNumericPreludetypeSignal=[]{-| shift signal in time -}delay::(Additive.Cv)=>Int->Signalv->Signalvdelay=FiltNR.delayPadzerodelayOnce::(Additive.Cv)=>Signalv->SignalvdelayOnce=(zero:){-| Unmodulated non-recursive filter -}nonRecursiveFilter::Module.Cav=>[a]->[v]->[v]nonRecursiveFilter=FiltNR.generic{-| Modulated non-recursive filter. -}nonRecursiveFilterMod::Module.Cav=>[[a]]->[v]->[v]nonRecursiveFilterModmsx=zipWithlinearCombms(tail(scanl(flip(:))[]x)){-| Description of a basic filter that can be used in larger networks. -}dataTtav=Mask[a]{-^ A static filter described by its mask -}|ModMask(Signal[a]){-^ A modulated filter described by a list of masks -}|FracDelay(Interpolation.Ttv)t{-^ Delay the signal by a fractional amount of samples.
This is achieved by interpolation. -}|ModFracDelay(Interpolation.Ttv)(Signalt){-^ Delay with varying delay times.
The delay times sequence must monotonically decrease.
(This includes constant parts!) -}|Delay[v]{-^ Delay the signal by prepending another one -}instanceFilter[]Twhereapply(Maskm)=nonRecursiveFiltermapply(ModMaskm)=nonRecursiveFilterModmapply(FracDelayipt)=Interpolation.multiRelativeZeroPadzeroip(-t)(repeat1)apply(ModFracDelayipts)=Interpolation.multiRelativeZeroPadzeroip(-headts)(repeat1-FiltNR.differentiatets)apply(Delayx)=(x++)transferFunction(Maskm)w=linearCombm(screw(negatew))transferFunction(FracDelay_t)w=cis(negatew*t)transferFunction(Delayx)w=cis(negatew*fromIntegral(lengthx))transferFunction__=error"transfer function can't be computed for modulated filters"