I want to create a synth, use it in an IO (), then stop that and use it in
a different IO (). I'm close: The following code has the right type
signatures, and it compiles:
boop :: SynthDef '["note","amp"]
boop = sd ( (0 ,0.1 )
:: (I "note",I "amp")) $ do
s1 <- (V::V "amp") ~* sinOsc (freq_ (V::V "note"))
out 0 [s1, s1]
loop :: (Elem "note" sdArgs)
=> MVar Bool -- changing this MVar to False will stop the loop
-> Node sdArgs
-> IO () -- would it be better if this was a VividAction?
loop continue aSynth = do
c <- readMVar continue
if c
then do set aSynth (toI 500 :: I "note")
wait 0.1
loop continue aSynth
else return ()
But in order to call "loop", I've got to give it a synth for its second
argument. But if I call "a <- synth boop ()" in open code, I get stuck in
some sort of loop:
> a <- synth boop ()
^CInterrupted.
> :t a
<interactive>:1:1: error: Variable not in scope: a
>
--
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/> | Facebook
<https://www.facebook.com/mejeff.younotjeff> | LinkedIn
<https://www.linkedin.com/in/jeffreybenjaminbrown>(spammy, so I often miss
messages here) | Github <https://github.com/jeffreybenjaminbrown>
_______________________________________________
Livecode mailing list -- livecode_at_we.lurk.org
To unsubscribe send an email to livecode-leave_at_we.lurk.org
Received on Tue Jul 03 2018 - 03:36:31 BST