I'm developing FRP application using Euterpea and got major problem in understanding how to do this one thing.
I got my own Signal function that I want to trigger when specific event occurs. Now my SigFun is just running from the start of the program.
Let's say I have a function that displays fourier transform of the signal on the graph and it works well: (string 1 is the function responsible for generating a waveform of a guitar string.)
d <- clockedSFToUISF 1 $ toFFT $ string 1
-< ()
let (s,fft) = unzip d
(a1,b1) = unzip s
_ <- realtimeGraph graLay 1 Black -< zip a1 fft
I tried if-then-else expression in toFFT function:
toFFT :: SigFun CtrRate b Double -> SigFun CtrRate b (Double, SEvent [Double])
toFFT sf = proc input -> do
sfOut <- sf -< input
fourierData <- fftA 100 256 -< sfOut
outA -< if ______ then (sfOut, fourierData) else (0.0, Nothing)
When if-flag is True everything displays properly and program resources ar OK. When the flag is false. The FFT is flat (which is ok), but programs starts consuming a lot of memory:
I know that in Yampa there are some functions called switches but I can't find them in Euterpea.
Is it at all possible to "trigger" a signal function the way I think it can? I read something about ArrowChoice but it's not clear to me how it may be helpful.
I feel like there is this basic stuff I'm not aware of.