Breakthrough! yay, got a looper to work. Thanks for the help. Code below.
-- attempt at all-in-one. loopster name buf busfrom busto = let sig = in' 1 AR busfrom -- one channel of input. rec = control KR "record" 0 -- make this 1.0 to record. play = control KR "play" 0 -- make this 1.0 to play. r_reset = tr_control "r_reset" 0 -- reset to start of record buffer. p_reset = tr_control "p_reset" 0 -- reset to start of play buffer. -- recphas starts at 0 up to end of buf. -- only changes when rec != 0 recphas = phasor AR r_reset rec 0 (bufFrames AR buf) 0 bfwr = bufWr buf recphas Loop sig -- play phasor ranges from 0 to last known recphas. -- only plays when 'play' is != 0. playphas = phasor AR p_reset play 0 recphas 0 bfrd = bufRd 1 AR buf playphas Loop NoInterpolation -- buffer loop. -- out signal is 'in' sig plus loop sound. -- mult by 'play' to mute the loop when not in use. outs = out busto (sig + (bfrd * play)) in synthdef name (mrg [outs, bfwr]) During initialization: -- create looper buffer. withSC3 (send (b_alloc (fromIntegral gLoopBufId) (44100 * 120) 1)) -- create the looper synthdef, and a synth from that. withSC3 (async (d_recv (loopster "looper" gLoopBufId gDelayOut 1))) withSC3 (send (s_new "looper" gLoopSynthId AddToTail 1 [])) Function called by the looper button: doloopster :: SoundState -> Bool -> IO SoundState doloopster soundstate False = return soundstate doloopster soundstate True = -- each time the button is pressed, iterate to the next -- looper state: Passthrough -> Record -> Playback case (ss_looperState soundstate) of Passthrough -> do print "loopster - record" -- go to record mode. withSC3 (send (F.n_set1 gLoopSynthId "r_reset" 1.0)) withSC3 (send (F.n_set1 gLoopSynthId "record" 1.0)) return $ soundstate { ss_looperState = Record } Record -> do print "loopster - play" -- go to playback mode. withSC3 (send (F.n_set1 gLoopSynthId "record" 0.0)) withSC3 (send (F.n_set1 gLoopSynthId "p_reset" 1.0)) withSC3 (send (F.n_set1 gLoopSynthId "play" 1.0)) return $ soundstate { ss_looperState = Play } Play -> do print "loopster - passthrough" -- go to passthrough mode. withSC3 (send (F.n_set1 gLoopSynthId "play" 0.0)) return $ soundstate { ss_looperState = Passthrough } -- Read the whole topic here: Haskell Art: http://lurk.org/r/topic/1FeOtZ0PvgKboWZY82eWVv To leave Haskell Art, email haskell-...@group.lurk.org with the following email subject: unsubscribe