Cabbage Logo
Back to Cabbage Site

A way to figure out 'instr' duration has passed

Hi there!

I’m starting new instruments from the main instruments using event, with a duration. When they are stopped or duration is over, I would like to get ‘a signal’, or a way to figure out they are not playing anymore. Counting at k-rate is one way, but I wonder if there is a better solution within the CSound language itself.


Hi @Airell, welcome to the forum. You can use the release opcode, or the more modern lastcycle opcode :+1:

Hi, thanks! Looks promising, however I’m ‘stuck’ at CSound 6.10 for now, the lastcycle opcode came in 6.14 . However, ‘lastcycle’ is the last k-rate cycle I believe. It looks at what I have build right now, comparing timeinstk with the p3 of the events kdelay parameter. It also has the issue described for lastcycle it does not signal when it’s turned off outside the instrument.

I was looking ate some ‘running state’ of an instrument function. I’ll try the release, but it looks like I need to create a line segment for the lengths of the duration (A=0, D=0, S=Duration, R=0) and then trigger on the release?

release should kick in regardless of defining an actual release segment. try it out. btw, why stuck to 6.10? that’s pretty ancient at this stage?

Yes 6.10 ancient, but I’m limited of what my hardware is offering. :frowning:

But… whilst searching for release, I found the following: active, which might probably is what I’m looking for: “Returns the number of active instances of an instrument.”.

When 0, the instrument stopped playing :smiley:

1 Like

you can use active opcode to check how many instruments is running, if 0 the its off