Csound Csound-dev Csound-tekno Search About

[Csnd] question about active

Date2018-04-14 03:10
FromDave Seidel
Subject[Csnd] question about active
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 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

Date2018-04-14 11:15
Fromjoachim heintz
SubjectRe: [Csnd] question about active
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 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

Date2018-04-14 12:55
FromDave Seidel
SubjectRe: [Csnd] question about active
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 <jh@joachimheintz.de> 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 Csound@listserv.heanet.ie
<mailto: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

Date2018-04-14 13:31
Fromthorin kerr
SubjectRe: [Csnd] question about active
There's an ActiveFrac udo in Iain McCurdy's collection.



Thorin


On Sat, 14 Apr. 2018, 12:10 pm Dave Seidel, <dave.seidel@gmail.com> 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 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

Date2018-04-14 13:38
FromDave Seidel
SubjectRe: [Csnd] question about active
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 <thorin.kerr@gmail.com> wrote:
There's an ActiveFrac udo in Iain McCurdy's collection.



Thorin


On Sat, 14 Apr. 2018, 12:10 pm Dave Seidel, <dave.seidel@gmail.com> 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 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