[I hope this is the right place to submit this] I had a need for 'turnoff2' (an instrument with a long release time was causing problems when played live) but it wasn't behaving as I expected -- I wanted to turn off the earliest instance, but it always turned them all off! So I turned to the example code. However, that didn't seem very helpful as it set up four instances, then turned them all off at once! Looking more closely, there seem to be a couple of inconsistencies in the example. First, it seems to want to use a 'ktrigger' to limit the invocation of turnoff2 (which actually was the key to why mine wasn't working!) but never actually resets it, so it doesn't do anything useful: turnoff2 is called every k-cycle. Then it immediately calls turnoff2 again to terminate everything remaining, which doesn't seem very illustrative to me. Line 48: "turnoff2 200, 1, 1 ;turn off must recently started instrument instance" is also actually a misstatement. That command actually turns off the *earliest* one! So, if I may, I'd like to submit a slightly modified example that I think shows things a bit better. I separated turning off one instance and all of them into separate instruments, and used sequential score events to invoke them. I used ktrigger (properly) in the first instrument, but just used turnoff in the other. I realize I could have used turnoff in both, but the ktrigger mechanism is more general. Revised code appended: ; Select audio/midi flags here according to platform -odac ;;;realtime audio out ;-iadc ;;;uncomment -iadc if realtime audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o sin.wav -W ;;; for file output any platform sr = 48000 ;samples per second for sound kr = 4800 nchnls = 1 0dbfs = 32767 gisine ftgen 1, 0, 131073, 9, 1, 1, 0 ;single sine tone ;----------------------------------------- instr 2 ;start ktrigger init 1 if (ktrigger = 1) then kMultiple = 1.414213 kHz = 220 kAmp = (0dbfs/10) ;startup four instances of instrument 200 event "i", 200, 0, 3000, kAmp, kHz kAmp = kAmp * 0.75 kHz = kHz * kMultiple event "i", 200, 0, 3000, kAmp, kHz kAmp = kAmp * 0.75 kHz = kHz * kMultiple event "i", 200, 0, 3000, kAmp, kHz kAmp = kAmp * 0.75 kHz = kHz * kMultiple event "i", 200, 0, 3000, kAmp, kHz kAmp = kAmp * 0.75 kHz = kHz * kMultiple ktrigger = 0 endif endin ;--------------------------------------------- instr 3 ; turn off the oldest instrument ktrigger init 1 if (ktrigger==1) then turnoff2 200, 1, 1 ; turn off earliest instrument instance kactive active 200 ; find out how many are still active printks "stopped one, %d instances left\n", 0, kactive ktrigger = 0 ; only do it once endif endin ;--------------------------------------------- instr 4 ;turn off all the rest of the instruments turnoff2 200, 0, 1 kactive active 200 ; find out how many are still active printks "stopped all, %d instances left\n", 0, kactive turnoff ; only need to do one cycle endin ;---------------------------------------------------- instr 200 ;play the tone kEnv linen 1, 0.1, p3, 0.1 ar oscil kEnv*p4, p5, 1 out ar print p4, p5 endin i2 0 0.1 ; turn on 4 instances i3 1 0.1 ;turn off a couple, one at a time i3 2 0.1 i4 5 0.1 ; turn off remaining instances