You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A million years ago on an extinct mailing list (Haskell Art), you gave me an example of how to use envelopes. Yesterday I discovered it works like a charm. I've tweaked it a little and added comments. It might make a good piece of documentation to add somewhere, maybe at the top of Vivid.Envelopes.
{-# LANGUAGE DataKinds, ExtendedDefaultRules #-}
import Vivid
main :: IO ()
main = do
s <- synth foo ()
wait 1
putStrLn "Now we fade in!"
set s (1 ::I "gate")
wait 4 -- because the envelope below lasts 1+2+1 seconds
free s
e :: EnvLiterally '["gate"]
e = env 0 -- The level to start at.
[ -- These are (level, time in seconds to reach that level) pairs.
(1, 1)
, (1, 2) -- Since the last level was also 1, this pair causes
-- the envelope to stay at 1 for 2 seconds after reaching it.
, (0, 1)]
Curve_Lin
-- This has a default gate of 0, so the envelope doesn't trigger when
-- the voice is created; rather, the user must send a positive gate value
-- to trigger it. (If they then send another 0, they gain the opportunity
-- to retrigger it with another positive gate value.)
-- If instead the default was 1, then the user would not need to send
-- the initial gate value separately (but they could still send 0
-- to make it ready to retrigger).
foo :: SynthDef '["gate"]
foo = sd (0 ::I "gate") $ do
e' <- envGen_wGate (V::V "gate") 1 e DoNothing
s <- sinOsc (freq_ 440) ~* e'
out 0 [s,s]
The text was updated successfully, but these errors were encountered:
A million years ago on an extinct mailing list (Haskell Art), you gave me an example of how to use envelopes. Yesterday I discovered it works like a charm. I've tweaked it a little and added comments. It might make a good piece of documentation to add somewhere, maybe at the top of Vivid.Envelopes.
The text was updated successfully, but these errors were encountered: