module Csound.Typed.Control.Vco(
saw, isaw, pulse, tri, sqr, blosc,
saw', isaw', pulse', tri', sqr', blosc'
) where
import Csound.Typed.GlobalState
import Csound.Typed.Types
saw :: Sig -> Sig
saw = noPhaseWave Saw
isaw :: Sig -> Sig
isaw = noPhaseWave IntegratedSaw
tri :: Sig -> Sig
tri = noPhaseWave Triangle
pulse :: Sig -> Sig
pulse = noPhaseWave Pulse
sqr :: Sig -> Sig
sqr = noPhaseWave Square
blosc :: Tab -> Sig -> Sig
blosc tab cps = hideGE $ do
gen <- fromPreTab $ getPreTabUnsafe "blosc: tab should be primitive, not an expression." tab
return $ noPhaseWave (UserGen gen) cps
saw' :: D -> Sig -> Sig
saw' = withPhaseWave Saw
isaw' :: D -> Sig -> Sig
isaw' = withPhaseWave IntegratedSaw
tri' :: D -> Sig -> Sig
tri' = withPhaseWave Triangle
pulse' :: D -> Sig -> Sig
pulse' = withPhaseWave Pulse
sqr' :: D -> Sig -> Sig
sqr' = withPhaseWave Square
blosc' :: Tab -> D -> Sig -> Sig
blosc' tab phs cps = hideGE $ do
gen <- fromPreTab $ getPreTabUnsafe "blosc: tab should be primitive, not an expression." tab
return $ withPhaseWave (UserGen gen) phs cps
noPhaseWave :: BandLimited -> Sig -> Sig
noPhaseWave waveType cps = fromGE $ do
expr <- toGE cps
waveId <- saveBandLimitedWave waveType
return $ readBandLimited Nothing waveId expr
withPhaseWave :: BandLimited -> D -> Sig -> Sig
withPhaseWave waveType phs cps = fromGE $ do
expr <- toGE cps
phsExpr <- toGE phs
waveId <- saveBandLimitedWave waveType
return $ readBandLimited (Just phsExpr) waveId expr