Csound Csound-dev Csound-tekno Search About

[Csnd] Turning off instances

Date2017-10-24 20:31
FromSteven Yi
Subject[Csnd] Turning off instances
Hi All,

I'm finding that turning off instruments while live coding a bit
tricky.  What I found:

* turnoff2 has all the features one would want but it performs at
perf-time and is, thus, not usable in instr 0 (which would happen if
one just sent a line of code on its own to Csound)

* For devs: turnoff looks like it will just crash or not do anything.
I don't understand the opcode: it can be called with no arguments and,
if so, ends up calling insert.c:kill_instance() and exits without
problem. If a number is given, I guess it is supposed to be some
pointer stored in a MYFLT val returned from nstance?  What I found is
that I was trying to use turnoff like turnoff2 giving it an instrument
number and that it would just crash Csound horribly since it would try
to treat the instrument number as an INSDS.  Not sure how there's any
way to fix this situation...


Anyways, I've just worked out a workaround using a UDO and instrument
combination:

instr KillImpl
  Sinstr = p4
  ktrig init 0

  if(ktrig == 0) then
    turnoff2(Sinstr, 0, 0)
    ktrig += 1
  endif
endin

opcode kill, 0,S
  Sinstr xin
  schedule("KillImpl", 0, 0.01, Sinstr)
endop


and I can kill all instance of an instrument by evaluating lines of code like:

kill("S1")

Thanks,
steven

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-10-24 20:46
Fromjpff
SubjectRe: [Csnd] Turning off instances
turnoff could check if the argumet is less tha/eqal to the higest instr 
number, 0f could ceck if it is equal to a instr umbe that exists; small 
chace of tis casing wit an INSD whic should be allocated via memalloc; 
could als scan mem chain.....  or scan instat list to ceck arg s valid.

Is it wort it?



On Tue, 24 Oct 2017, Steven Yi wrote:

> Hi All,
>
> I'm finding that turning off instruments while live coding a bit
> tricky.  What I found:
>
> * turnoff2 has all the features one would want but it performs at
> perf-time and is, thus, not usable in instr 0 (which would happen if
> one just sent a line of code on its own to Csound)
>
> * For devs: turnoff looks like it will just crash or not do anything.
> I don't understand the opcode: it can be called with no arguments and,
> if so, ends up calling insert.c:kill_instance() and exits without
> problem. If a number is given, I guess it is supposed to be some
> pointer stored in a MYFLT val returned from nstance?  What I found is
> that I was trying to use turnoff like turnoff2 giving it an instrument
> number and that it would just crash Csound horribly since it would try
> to treat the instrument number as an INSDS.  Not sure how there's any
> way to fix this situation...
>
>
> Anyways, I've just worked out a workaround using a UDO and instrument
> combination:
>
> instr KillImpl
>  Sinstr = p4
>  ktrig init 0
>
>  if(ktrig == 0) then
>    turnoff2(Sinstr, 0, 0)
>    ktrig += 1
>  endif
> endin
>
> opcode kill, 0,S
>  Sinstr xin
>  schedule("KillImpl", 0, 0.01, Sinstr)
> endop
>
>
> and I can kill all instance of an instrument by evaluating lines of code like:
>
> kill("S1")
>
> Thanks,
> steven
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-10-24 20:51
FromSteven Yi
SubjectRe: [Csnd] Turning off instances
Are you saying to check against instrument instances to see if the
memory address is equal to the value of the p->inst pointer?  Seems
like the only way to ensure that it isn't going to crash.  I'd rather
like an opcode that works just as turnoff2 does but at i-time, but I'm
not sure what's the best way forward for that.

On Tue, Oct 24, 2017 at 3:46 PM, jpff  wrote:
> turnoff could check if the argumet is less tha/eqal to the higest instr
> number, 0f could ceck if it is equal to a instr umbe that exists; small
> chace of tis casing wit an INSD whic should be allocated via memalloc; could
> als scan mem chain.....  or scan instat list to ceck arg s valid.
>
> Is it wort it?
>
>
>
>
> On Tue, 24 Oct 2017, Steven Yi wrote:
>
>> Hi All,
>>
>> I'm finding that turning off instruments while live coding a bit
>> tricky.  What I found:
>>
>> * turnoff2 has all the features one would want but it performs at
>> perf-time and is, thus, not usable in instr 0 (which would happen if
>> one just sent a line of code on its own to Csound)
>>
>> * For devs: turnoff looks like it will just crash or not do anything.
>> I don't understand the opcode: it can be called with no arguments and,
>> if so, ends up calling insert.c:kill_instance() and exits without
>> problem. If a number is given, I guess it is supposed to be some
>> pointer stored in a MYFLT val returned from nstance?  What I found is
>> that I was trying to use turnoff like turnoff2 giving it an instrument
>> number and that it would just crash Csound horribly since it would try
>> to treat the instrument number as an INSDS.  Not sure how there's any
>> way to fix this situation...
>>
>>
>> Anyways, I've just worked out a workaround using a UDO and instrument
>> combination:
>>
>> instr KillImpl
>>  Sinstr = p4
>>  ktrig init 0
>>
>>  if(ktrig == 0) then
>>    turnoff2(Sinstr, 0, 0)
>>    ktrig += 1
>>  endif
>> endin
>>
>> opcode kill, 0,S
>>  Sinstr xin
>>  schedule("KillImpl", 0, 0.01, Sinstr)
>> endop
>>
>>
>> and I can kill all instance of an instrument by evaluating lines of code
>> like:
>>
>> kill("S1")
>>
>> Thanks,
>> steven
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>>
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-10-24 21:03
FromRory Walsh
SubjectRe: [Csnd] Turning off instances
I vaguely recall Victor presenting some way of doing this in the past? Victor? 

On 24 October 2017 at 20:51, Steven Yi <stevenyi@gmail.com> wrote:
Are you saying to check against instrument instances to see if the
memory address is equal to the value of the p->inst pointer?  Seems
like the only way to ensure that it isn't going to crash.  I'd rather
like an opcode that works just as turnoff2 does but at i-time, but I'm
not sure what's the best way forward for that.

On Tue, Oct 24, 2017 at 3:46 PM, jpff <jpff@codemist.co.uk> wrote:
> turnoff could check if the argumet is less tha/eqal to the higest instr
> number, 0f could ceck if it is equal to a instr umbe that exists; small
> chace of tis casing wit an INSD whic should be allocated via memalloc; could
> als scan mem chain.....  or scan instat list to ceck arg s valid.
>
> Is it wort it?
>
>
>
>
> On Tue, 24 Oct 2017, Steven Yi wrote:
>
>> Hi All,
>>
>> I'm finding that turning off instruments while live coding a bit
>> tricky.  What I found:
>>
>> * turnoff2 has all the features one would want but it performs at
>> perf-time and is, thus, not usable in instr 0 (which would happen if
>> one just sent a line of code on its own to Csound)
>>
>> * For devs: turnoff looks like it will just crash or not do anything.
>> I don't understand the opcode: it can be called with no arguments and,
>> if so, ends up calling insert.c:kill_instance() and exits without
>> problem. If a number is given, I guess it is supposed to be some
>> pointer stored in a MYFLT val returned from nstance?  What I found is
>> that I was trying to use turnoff like turnoff2 giving it an instrument
>> number and that it would just crash Csound horribly since it would try
>> to treat the instrument number as an INSDS.  Not sure how there's any
>> way to fix this situation...
>>
>>
>> Anyways, I've just worked out a workaround using a UDO and instrument
>> combination:
>>
>> instr KillImpl
>>  Sinstr = p4
>>  ktrig init 0
>>
>>  if(ktrig == 0) then
>>    turnoff2(Sinstr, 0, 0)
>>    ktrig += 1
>>  endif
>> endin
>>
>> opcode kill, 0,S
>>  Sinstr xin
>>  schedule("KillImpl", 0, 0.01, Sinstr)
>> endop
>>
>>
>> and I can kill all instance of an instrument by evaluating lines of code
>> like:
>>
>> kill("S1")
>>
>> Thanks,
>> steven
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>>
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2017-10-24 21:51
FromVictor Lazzarini
SubjectRe: [Csnd] Turning off instances
I probably wrote the code that takes the instance handle as returned by nstance. The manual
says that’s how it works. Probably it’s not protected against a non-existent handle.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 24 Oct 2017, at 21:03, Rory Walsh  wrote:
> 
> I vaguely recall Victor presenting some way of doing this in the past? Victor? 
> 
> On 24 October 2017 at 20:51, Steven Yi  wrote:
> Are you saying to check against instrument instances to see if the
> memory address is equal to the value of the p->inst pointer?  Seems
> like the only way to ensure that it isn't going to crash.  I'd rather
> like an opcode that works just as turnoff2 does but at i-time, but I'm
> not sure what's the best way forward for that.
> 
> On Tue, Oct 24, 2017 at 3:46 PM, jpff  wrote:
> > turnoff could check if the argumet is less tha/eqal to the higest instr
> > number, 0f could ceck if it is equal to a instr umbe that exists; small
> > chace of tis casing wit an INSD whic should be allocated via memalloc; could
> > als scan mem chain.....  or scan instat list to ceck arg s valid.
> >
> > Is it wort it?
> >
> >
> >
> >
> > On Tue, 24 Oct 2017, Steven Yi wrote:
> >
> >> Hi All,
> >>
> >> I'm finding that turning off instruments while live coding a bit
> >> tricky.  What I found:
> >>
> >> * turnoff2 has all the features one would want but it performs at
> >> perf-time and is, thus, not usable in instr 0 (which would happen if
> >> one just sent a line of code on its own to Csound)
> >>
> >> * For devs: turnoff looks like it will just crash or not do anything.
> >> I don't understand the opcode: it can be called with no arguments and,
> >> if so, ends up calling insert.c:kill_instance() and exits without
> >> problem. If a number is given, I guess it is supposed to be some
> >> pointer stored in a MYFLT val returned from nstance?  What I found is
> >> that I was trying to use turnoff like turnoff2 giving it an instrument
> >> number and that it would just crash Csound horribly since it would try
> >> to treat the instrument number as an INSDS.  Not sure how there's any
> >> way to fix this situation...
> >>
> >>
> >> Anyways, I've just worked out a workaround using a UDO and instrument
> >> combination:
> >>
> >> instr KillImpl
> >>  Sinstr = p4
> >>  ktrig init 0
> >>
> >>  if(ktrig == 0) then
> >>    turnoff2(Sinstr, 0, 0)
> >>    ktrig += 1
> >>  endif
> >> endin
> >>
> >> opcode kill, 0,S
> >>  Sinstr xin
> >>  schedule("KillImpl", 0, 0.01, Sinstr)
> >> endop
> >>
> >>
> >> and I can kill all instance of an instrument by evaluating lines of code
> >> like:
> >>
> >> kill("S1")
> >>
> >> Thanks,
> >> steven
> >>
> >> Csound mailing list
> >> Csound@listserv.heanet.ie
> >> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> >> Send bugs reports to
> >>        https://github.com/csound/csound/issues
> >> Discussions of bugs and features can be posted here
> >>
> >
> > Csound mailing list
> > Csound@listserv.heanet.ie
> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> > Send bugs reports to
> >        https://github.com/csound/csound/issues
> > Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> 
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here