[Csnd] question about active

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] question about active

Dave Seidel
It seems that the "active" opcode does not distinguish between playing instruments whose numbers have the same base number but different fractional parts. For example, given instrument 23 with instances 23.001 and 23.002, if instance 23.001 is playing, active(23.002) returns 1, so apparently active() sees them both as instances of 23. But I need to distinguish between them. Is there any way to know if 23.002 is playing vs. 23.001?

- Dave
Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] question about active

joachim-3
just in a hurry: you could do something like this:

gkActive23[] init 1000

instr 23
  ;get fractional part
  iFrac = frac(p1)

  ;write 1 at start of the instrument in the gkActiv23 array
  if timeinstk() == 1 then
   gkActive23[round(frac(p1)*1000)] = 1
  endif

  ;write 0 at end
  if release:k() == 1 then
   gkActive23[round(frac(p1)*1000)] = 0
  endif
endin

in another instrument you can ask about the index / instance.

        joachim



On 14/04/18 04:10, Dave Seidel wrote:

> It seems that the "active" opcode does not distinguish between playing
> instruments whose numbers have the same base number but different
> fractional parts. For example, given instrument 23 with instances 23.001
> and 23.002, if instance 23.001 is playing, active(23.002) returns 1, so
> apparently active() sees them both as instances of 23. But I need to
> distinguish between them. Is there any way to know if 23.002 is playing
> vs. 23.001?
>
> - Dave
> Csound mailing list [hidden email]
> <mailto:[hidden email]>
> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] question about active

Dave Seidel
Thanks, Joachim, I think that would work, though in my particular particular case the release part would have to be a bit different. This is a MIDI-triggered instrument that starts other instruments, and the feature I'm trying to work out is to make it "sticky". In other words, press a key to start a note, and the note continues (past the normal key release) until the key is pressed again. This wasn't part of my original plan for the piece, but I need to be able to hold notes for a long time, and unfortunately I've found that if I do that the usual way (by holding down a key), it tends to provoke the tendinitis in my elbow -- I did this last weekend and have been paying the price since then.

In any case, thanks much for the practical idea, which I think is definitely adaptable to my project with slightly different logic for the release/re-trigger. If I was in some other language such as Python, I'd probably use a dictionary/hash instead of a numerically indexed array, but there are always trade-offs (space vs. speed, etc.). (I know I could use embedded Python or Lua, but I don't think it's worth it just for the sake of using a different data structure.) 

- Dave

On Sat, Apr 14, 2018 at 6:15 AM, joachim heintz <[hidden email]> wrote:
just in a hurry: you could do something like this:

gkActive23[] init 1000

instr 23
 ;get fractional part
 iFrac = frac(p1)

 ;write 1 at start of the instrument in the gkActiv23 array
 if timeinstk() == 1 then
  gkActive23[round(frac(p1)*1000)] = 1
 endif

 ;write 0 at end
 if release:k() == 1 then
  gkActive23[round(frac(p1)*1000)] = 0
 endif
endin

in another instrument you can ask about the index / instance.

        joachim




On 14/04/18 04:10, Dave Seidel wrote:
It seems that the "active" opcode does not distinguish between playing
instruments whose numbers have the same base number but different
fractional parts. For example, given instrument 23 with instances 23.001
and 23.002, if instance 23.001 is playing, active(23.002) returns 1, so
apparently active() sees them both as instances of 23. But I need to
distinguish between them. Is there any way to know if 23.002 is playing
vs. 23.001?

- Dave
Csound mailing list [hidden email]
<mailto:[hidden email]>
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
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] question about active

thorin kerr
In reply to this post by Dave Seidel
There's an ActiveFrac udo in Iain McCurdy's collection.



Thorin


On Sat, 14 Apr. 2018, 12:10 pm Dave Seidel, <[hidden email]> wrote:
It seems that the "active" opcode does not distinguish between playing instruments whose numbers have the same base number but different fractional parts. For example, given instrument 23 with instances 23.001 and 23.002, if instance 23.001 is playing, active(23.002) returns 1, so apparently active() sees them both as instances of 23. But I need to distinguish between them. Is there any way to know if 23.002 is playing vs. 23.001?

- Dave
Csound mailing list [hidden email] 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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] question about active

Dave Seidel
Aha, thanks Thorin! That looks like a nice encapsulation of essentially the same concept that Joachim proposed. Should be adaptable to my situation.

On Sat, Apr 14, 2018 at 8:31 AM, thorin kerr <[hidden email]> wrote:
There's an ActiveFrac udo in Iain McCurdy's collection.



Thorin


On Sat, 14 Apr. 2018, 12:10 pm Dave Seidel, <[hidden email]> wrote:
It seems that the "active" opcode does not distinguish between playing instruments whose numbers have the same base number but different fractional parts. For example, given instrument 23 with instances 23.001 and 23.002, if instance 23.001 is playing, active(23.002) returns 1, so apparently active() sees them both as instances of 23. But I need to distinguish between them. Is there any way to know if 23.002 is playing vs. 23.001?

- Dave
Csound mailing list [hidden email] 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 [hidden email] 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 [hidden email] 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