cl-patterns
cl-patterns copied to clipboard
How to stop a running pattern
Hi,
I'm trying to stop a running pseq:
(defparameter *7s*
(pseq
(list
(pseq (list (ppar (list sub kick))) 4)
(pseq (list (ppar (list sub kick door))) 4)
(pseq (list (ppar (list hi sub kick city))) 4)
(pseq (list (ppar (list hi sub kick cello city))) 4)
(pseq (list (ppar (list hi sub kick cello city vox))) 4)
(pseq (list (ppar (list pink hi sub kick door cello))) 4)
(pseq (list (ppar (list pink hi sub kick rim))) 4)
(pseq (list (ppar (list hi sub kick rim door city))) 4)
(pseq (list (ppar (list hi sub kick rim pad cello vox))) 8)
(pseq (list (ppar (list sub kick))) 4)
(pseq (list (ppar (list sub kick door))) 4)
(pseq (list (ppar (list hi sub kick city))) 4)
(pseq (list (ppar (list hi sub kick cello city))) 4)
(pseq (list (ppar (list hi sub kick cello city vox))) 4)
(pseq (list (ppar (list pink hi sub kick door cello))) 4)
(pseq (list (ppar (list pink hi sub kick rim))) 4)
(pseq (list (ppar (list hi sub kick rim door city))) 4))
1))
(play *7s*)
but if I run (stop *7s*) I get this:
There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION CL-PATTERNS:STOP (7)>
when called with arguments
(#<PSEQ (#<PSEQ (#<PPAR (#1=#<PFINDUR (PBIND :INSTRUMENT :PM-FB-PERC-2 :DB #<PSEQ (-20
(PREST 1)
-23
(PREST 1)
-25
(PREST 1)
(PREST 1)) :INF 0> :OCTAVE (1
2) :DEGREE 0 :PM-INDEX #<PWHITE 0.1 0.8 :INF> :ATTACK 0.5 :MOD-ATTAC #<PK :ATTACK :INF> :PAN 0 :WIDTH 4 :RELEASE (1.0
[ .... truncated] 1/8) :INF 0>) 7 0>)>) 4 0>
#<PSEQ (#<PPAR (#11=#<PFINDUR (PBIND :INSTRUMENT :PINK-PERC-2 :DUR #<PSEQ (1/4
1/4
1/4
1/4
1/8
..
[Condition of type SB-PCL::NO-APPLICABLE-METHOD-ERROR]
Is this expected behavior? And if so, how do I go about actually stopping the thing?
Sorry for the delay in responding. Unlike pdef (and functionality that utilizes it like the pb macro), regular patterns don't keep a reference to their task on the clock when they are being played. So the solution here would be to either wrap your pseq in a pdef:
(pdef :7s (pseq ...))
and use (stop (pdef :7s)) to stop it, or if you've already started a non-pdef pattern on the clock, you can find its task with (clock-tasks) and then call stop on that task, which should stop it as expected.