Strange issue turning off instanced instrument

Hey all,

I’m trying to figure out what exactly is going on here. I’m simply trying to disable an instrument instance, but for some reason when I attempt to do so I am getting an error that says “could not find playing instr 1.100000”

Initially I was sending the score event with the negative value instrument number as a score event, but I hard coded it just to verify that the issue wasn’t arising from my front end that was passing the string to csound. Even with the instrument number hardcoded it’s throwing the error

Here is the code with the score included:

<CsoundSynthesizer>
<CsOptions>
-o dac
-i adc
</CsOptions>
<CsInstruments>

sr        = 48000
ksmps     = 64
nchnls    = 2
0dbfs      = 1

instr TimeControls
    
endin

instr 10
    kIsPlaying init 0
    kPlayButton init 0
    kPauseButton init 0
    
    kTempo init 120
    kSwing init 0
    kPulse init 0
    kTempoSlider chnget "tempoSlider"
    kPlayButton chnget "playButton"
    if(kPlayButton > 0) then
        kIsPlaying = 1
    endif
    iFreqLfo init (0.01666667 * 16)
    if(kIsPlaying == 1) then
        kLfo lfo 1, (kTempo + kTempoSlider) * iFreqLfo, 3
        kPulse trigger kLfo, .5, 0
        ;chnset kTempo, "MasterClock"
        
    else
        kPulse = 0
    endif
    ;printk2 kTempoSlider
    chnset kPulse, "MasterClock"
endin

; Step8
instr 1
    i2 = frac(p1)
    printf_i  "'%1.7f'\n", 1, p1
    prints "TURDS START"
    kcount active 1
  ; Print the number of active instances.
  printk2 kcount

    kStepAdvance = 0
    kSteps[] init 8
    kCurStep init 0
    kCurPulse init 0
    kLastStep init 8
    kStepDiv init 16
    
    kClockPulse chnget "MasterClock"
    if(kClockPulse == 1) then
        kCurPulse = kCurPulse + 1
        if(kCurPulse % kStepDiv == 0) then
            kCurStep = kCurStep + 1
            kStepAdvance = 1
            if(kCurStep >= kLastStep) then
                kCurStep = 0
                kCurPulse = 0
            endif
        endif
    endif
    ;printk2 kCurPulse
    chnset kStepAdvance, "Seq8AdvancePulse"
endin

instr 2
kPulse init 0
kPulse chnget "Seq8AdvancePulse"
asig poscil 0.5 * kPulse, 240
outs asig , asig
endin

instr 4
asig poscil 0.5, 240
outs asig , asig
endin

</CsInstruments>
<CsScore>
i 10 0 10000
i 2 0 1000
i 1.1 0 10000
i -1.1 10 10000
</CsScore>
</CsoundSynthesizer>

Hi!

You can turn off only an instance with negative duration this way.
You should either change the score line to;

i 1.1 0 -1

Or use another instrument with turnoff2 opcode to do the stop job.

Best!
Tarmo

T, 4. juuli 2023 09:04 DespairBear via The Csound Community <noreply@forum.csound.com> kirjutas: