csound-expression-typed 0.0.7.6 → 0.0.7.7
raw patch · 4 files changed
+69/−24 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Csound.Typed.Control: blosc' :: Tab -> D -> Sig -> Sig
+ Csound.Typed.Control: isaw' :: D -> Sig -> Sig
+ Csound.Typed.Control: pulse' :: D -> Sig -> Sig
+ Csound.Typed.Control: saw' :: D -> Sig -> Sig
+ Csound.Typed.Control: sqr' :: D -> Sig -> Sig
+ Csound.Typed.Control: tri' :: D -> Sig -> Sig
Files
- csound-expression-typed.cabal +1/−1
- src/Csound/Typed/Control/Vco.hs +52/−11
- src/Csound/Typed/GlobalState/Elements.hs +3/−6
- src/Csound/Typed/GlobalState/Opcodes.hs +13/−6
csound-expression-typed.cabal view
@@ -1,5 +1,5 @@ Name: csound-expression-typed-Version: 0.0.7.6+Version: 0.0.7.7 Cabal-Version: >= 1.6 License: BSD3 License-file: LICENSE
src/Csound/Typed/Control/Vco.hs view
@@ -1,40 +1,81 @@ -- | Band-limited oscillators module Csound.Typed.Control.Vco(- saw, isaw, pulse, tri, sqr, blosc + saw, isaw, pulse, tri, sqr, blosc,+ saw', isaw', pulse', tri', sqr', blosc' ) where import Csound.Typed.GlobalState import Csound.Typed.Types +--------------------------------------------------------------+-- no phase+ -- | A sawtooth. saw :: Sig -> Sig-saw = wave Saw+saw = noPhaseWave Saw -- | Integrated sawtooth: 4 * x * (1 - x). isaw :: Sig -> Sig-isaw = wave IntegratedSaw+isaw = noPhaseWave IntegratedSaw -- | A triangle wave. tri :: Sig -> Sig-tri = wave Triangle+tri = noPhaseWave Triangle -- | Pulse (not normalized). pulse :: Sig -> Sig -pulse = wave Pulse+pulse = noPhaseWave Pulse -- | A square wave. sqr :: Sig -> Sig-sqr = wave Square+sqr = noPhaseWave Square -- | A band-limited oscillator with user defined waveform (it's stored in the table). blosc :: Tab -> Sig -> Sig blosc tab cps = hideGE $ do gen <- fromPreTab $ getPreTabUnsafe "blosc: tab should be primitive, not an expression." tab- return $ wave (UserGen gen) cps+ return $ noPhaseWave (UserGen gen) cps -wave :: BandLimited -> Sig -> Sig-wave waveType cps = fromGE $ do+--------------------------------------------------------------+-- with phase++-- | A sawtooth.+saw' :: D -> Sig -> Sig+saw' = withPhaseWave Saw++-- | Integrated sawtooth: 4 * x * (1 - x).+isaw' :: D -> Sig -> Sig+isaw' = withPhaseWave IntegratedSaw++-- | A triangle wave.+tri' :: D -> Sig -> Sig+tri' = withPhaseWave Triangle++-- | Pulse (not normalized).+pulse' :: D -> Sig -> Sig +pulse' = withPhaseWave Pulse++-- | A square wave.+sqr' :: D -> Sig -> Sig+sqr' = withPhaseWave Square++-- | A band-limited oscillator with user defined waveform (it's stored in the table).+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 waveId expr- + 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
src/Csound/Typed/GlobalState/Elements.hs view
@@ -9,7 +9,7 @@ -- ** Band-limited waveforms BandLimited(..), BandLimitedMap, saveBandLimited, renderBandLimited,- readBandLimited, readBandLimitedConstCps,+ readBandLimited, -- ** String arguments StringMap, newString, -- * Midi@@ -187,11 +187,8 @@ toDummy = writeVar dummyVar -readBandLimited :: Int -> E -> E-readBandLimited n cps = oscilikt 1 cps (vco2ft cps (int n))--readBandLimitedConstCps :: Int -> E -> E-readBandLimitedConstCps n cps = oscili 1 cps (vco2ift cps (int n))+readBandLimited :: Maybe E -> Int -> E -> E+readBandLimited mphase n cps = oscilikt 1 cps (vco2ft cps (int n)) mphase ---------------------------------------------------------- -- Midi
src/Csound/Typed/GlobalState/Opcodes.hs view
@@ -238,19 +238,26 @@ -- ares oscilikt xamp, xcps, kfn [, iphs] [, istor] -- kres oscilikt kamp, kcps, kfn [, iphs] [, istor]-oscilikt :: E -> E -> E -> E-oscilikt amp cps fn = opcs "oscilikt" +oscilikt :: E -> E -> E -> Maybe E -> E+oscilikt amp cps fn mphase = opcs "oscilikt" [ (Ar, [Xr, Xr, Kr, Ir, Ir]) , (Kr, [Kr, Kr, Kr, Ir, Ir])] - [amp, cps, fn]+ (case mphase of+ Nothing -> [amp, cps, fn]+ Just phs -> [amp, cps, fn, phs]+ ) -- ares oscili xamp, xcps, ifn [, iphs] -- kres oscili kamp, kcps, ifn [, iphs]-oscili :: E -> E -> E -> E-oscili amp cps fn = opcs "oscili"+oscili :: E -> E -> E -> Maybe E -> E+oscili amp cps fn mphase = opcs "oscili" [ (Ar, [Xr, Xr, Ir, Ir, Ir]) , (Kr, [Kr, Kr, Ir, Ir, Ir])] - [amp, cps, fn]+ (case mphase of+ Nothing -> [amp, cps, fn]+ Just phs -> [amp, cps, fn, phs]+ )+ -- kfn vco2ft kcps, iwave [, inyx] vco2ft :: E -> E -> E