Csound Csound-dev Csound-tekno Search About

[Csnd] Instrument self instance / note management

Date2022-07-19 22:57
From"Jeanette C."
Subject[Csnd] Instrument self instance / note management
Hey hey,
I'm trying to implement a live MIDI orchestra. It has two vital instruments: 
one triggered by MIDI note and another one to be triggered multiple times from 
within the "master" instrument with slightly different parameters, called 
Play.

Now, I'd like to turn off the Play instances, once the Master instrument is 
released, but I can't manage that properly.

I tried calling Play with:
iId1 = nstance("Play", 0, -1, iP4, ...)
iId2 = nstance("Play", 0, -1, iP4, ...)
And then later:
if (release() == 1) then
   turnoff(iId1)
   turnoff(iId2)
endif

No joy. I worked with an i-time array of Ids first, when that failed, I 
switched to separate variables for each ID.

Before that I had a global counter for use with fractional instrument numbers 
and turnoff2. The problem: if MIDI notes were depressed simultaneously, not 
every note would play.

Due to some complexities the implementation with two instruments is the 
easiest and most maintainable solution.

Is there a way to overcome this? Have I missed a pitfall?

Best wishes and thanks,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Just hang around and you'll see,
There's nowhere I'd rather be <3
(Britney Spears)

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

Date2022-07-19 23:18
FromTarmo Johannes
SubjectRe: [Csnd] Instrument self instance / note management
Hi,

You need to use fractional instrument numbers like
nstrnum("Play")+0.1
nstrnum("Play")+0.2

otherwise you cannot have several instances with indefinite duration.

Hope it helps...

Tarmo


K, 20. juuli 2022 00:59 Jeanette C. <julien@mail.upb.de> kirjutas:
Hey hey,
I'm trying to implement a live MIDI orchestra. It has two vital instruments:
one triggered by MIDI note and another one to be triggered multiple times from
within the "master" instrument with slightly different parameters, called
Play.

Now, I'd like to turn off the Play instances, once the Master instrument is
released, but I can't manage that properly.

I tried calling Play with:
iId1 = nstance("Play", 0, -1, iP4, ...)
iId2 = nstance("Play", 0, -1, iP4, ...)
And then later:
if (release() == 1) then
   turnoff(iId1)
   turnoff(iId2)
endif

No joy. I worked with an i-time array of Ids first, when that failed, I
switched to separate variables for each ID.

Before that I had a global counter for use with fractional instrument numbers
and turnoff2. The problem: if MIDI notes were depressed simultaneously, not
every note would play.

Due to some complexities the implementation with two instruments is the
easiest and most maintainable solution.

Is there a way to overcome this? Have I missed a pitfall?

Best wishes and thanks,

Jeanette

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Just hang around and you'll see,
There's nowhere I'd rather be <3
(Britney Spears)

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

Date2022-07-19 23:33
From"Jeanette C."
SubjectRe: [Csnd] Instrument self instance / note management
Jul 20 2022, Tarmo Johannes has written:

> Hi,
>
> You need to use fractional instrument numbers like
> nstrnum("Play")+0.1
...
This is what I tried with the global counter. that's when I ran into the
simultaneous issues. The sound generation must be polyphonic. That's why
I wonder if there is a way to determine the fractional ID or nstance
handle of a playing instrument by itself, so the fractional numbers of
sound generators can be unique.

Best wishes and thanks,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Just hang around and you'll see,
There's nowhere I'd rather be <3
(Britney Spears)

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

Date2022-07-20 00:10
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Instrument self instance / note management
With -1 you will always replace the instance with a new one, unless a fractional p1 is used.

You could use a large p3 though, and that should behave as expected, with separate instances.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 19 Jul 2022, at 23:35, Jeanette C.  wrote:
> 
> *Warning*
> 
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> 
> Jul 20 2022, Tarmo Johannes has written:
> 
>> Hi,
>> 
>> You need to use fractional instrument numbers like
>> nstrnum("Play")+0.1
> ...
> This is what I tried with the global counter. that's when I ran into the
> simultaneous issues. The sound generation must be polyphonic. That's why
> I wonder if there is a way to determine the fractional ID or nstance
> handle of a playing instrument by itself, so the fractional numbers of
> sound generators can be unique.
> 
> Best wishes and thanks,
> 
> Jeanette
> 
> --
> * Website: https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fjuliencoder.de%2F&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C53d191f01c0d4be2b6cb08da69d6ec46%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C637938669059487410%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=kdFtztZP4%2FdsG2KNGCP4CBryWRyh30olJxy3atX5oO8%3D&reserved=0 - for summer is a state of sound
> * Youtube: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.youtube.com%2Fchannel%2FUCMS4rfGrTwz8W7jhC1Jnv7g&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C53d191f01c0d4be2b6cb08da69d6ec46%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C637938669059487410%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cIz%2Fq4BSSRBJvdNykvfg4oJQQvqgJQvRQyMcM9RTRRE%3D&reserved=0
> * Audiobombs: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.audiobombs.com%2Fusers%2Fjeanette_c&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C53d191f01c0d4be2b6cb08da69d6ec46%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C637938669059487410%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OKsP7RdHXlcfZDG537mnmvKY6d6WJ%2BPI7KcXzpMO1Js%3D&reserved=0
> * GitHub: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeanette-c&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C53d191f01c0d4be2b6cb08da69d6ec46%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C637938669059487410%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0A%2BDHt6EW6sTqMI7Y4HTg2w8aGO2qleuQljR2oEFJl4%3D&reserved=0
> 
> Just hang around and you'll see,
> There's nowhere I'd rather be <3
> (Britney Spears)
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C53d191f01c0d4be2b6cb08da69d6ec46%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C637938669059487410%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=a%2BxqtY%2BDk87ev%2BJHUYUdRw2%2BXfrDrmDy7%2FVUw%2B8WFJc%3D&reserved=0
> Send bugs reports to
>       https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C53d191f01c0d4be2b6cb08da69d6ec46%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C637938669059487410%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gdaBAh34GetFeozVATk%2FGNV4fO4%2BPZIc3WbEbxvd%2F0o%3D&reserved=0
> 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

Date2022-07-20 02:02
Fromthorin kerr
SubjectRe: [Csnd] Instrument self instance / note management
You also have to convert the irate handle to krate to get the k-rate turnoff.
This example works:

instr Master

ild1 nstance nstrnum("Play") + 0.1, 0, -1, ip4, ip5 ...
ild2 nstance nstrnum("Play") + 0.2, 0, -1, ip4, ip5 ...
kld1 = k(ild1)
kld2 = k(ild2)

if release() == 1 then
   turnoff(kld1)
   turnoff(kld2)
endif

endin


On Wed, Jul 20, 2022 at 7:59 AM Jeanette C. <julien@mail.upb.de> wrote:
Hey hey,
I'm trying to implement a live MIDI orchestra. It has two vital instruments:
one triggered by MIDI note and another one to be triggered multiple times from
within the "master" instrument with slightly different parameters, called
Play.

Now, I'd like to turn off the Play instances, once the Master instrument is
released, but I can't manage that properly.

I tried calling Play with:
iId1 = nstance("Play", 0, -1, iP4, ...)
iId2 = nstance("Play", 0, -1, iP4, ...)
And then later:
if (release() == 1) then
   turnoff(iId1)
   turnoff(iId2)
endif

No joy. I worked with an i-time array of Ids first, when that failed, I
switched to separate variables for each ID.

Before that I had a global counter for use with fractional instrument numbers
and turnoff2. The problem: if MIDI notes were depressed simultaneously, not
every note would play.

Due to some complexities the implementation with two instruments is the
easiest and most maintainable solution.

Is there a way to overcome this? Have I missed a pitfall?

Best wishes and thanks,

Jeanette

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Just hang around and you'll see,
There's nowhere I'd rather be <3
(Britney Spears)

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

Date2022-07-20 10:10
From"Jeanette C."
SubjectRe: [Csnd] Instrument self instance / note management
Hi Victor and Thorin,
thanks both of you for the clarification. Just when I woke up this morning I 
thought of another viable solution, i Hope.

I can create unique fractional p1 parts with each MIDI event based on the note 
number, since I won't play a note twice at the same time. It may cause some 
issues with release periods and note retriggered quickly. In this case it's a 
pad instrument and I know what I will play already. If that does cause more 
issues, I'll go with very long p3, as you suggested Victor.

Thanks again and best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

'Cause living in a dream of you and me
Is not the way my life should be... <3
(Britney Spears)

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