Csound Csound-dev Csound-tekno Search About

[Csnd] chns with more instances of same instr

Date2020-02-07 13:54
Fromjacqouemin
Subject[Csnd] chns with more instances of same instr
Hello everyone,

I tried to write a simple UDO in order to control directly every instrument
outlet for live coding. I'd like just write "stout("MyInstr")" and then (in
the future) have something like "stfx("MyInstr", "MyFx")" to connect the two
instruments.

There it is my UDO:

---

opcode	stout, 0, S
	Sinstr xin
	
	a1 chnget sprintf("%s-1", Sinstr)
	a2 chnget sprintf("%s-2", Sinstr)

	outs a1, a2
endop

---

Everything works fine, but the only big problem is that if I I have more
instances of the same instrument, I can only hear the last one in the
score..

I can't really figure out the issue (I also tried to check instances with
"active" opcode and create for each one a channel, but it didn't work and I
don't think it is the best approach).

Thank you,

p.s.
new update with remembered MACROs is life changing!! Thank you so much.

jacques



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2020-02-07 14:09
From"Jeanette C."
SubjectRe: [Csnd] chns with more instances of same instr
Hey hey Jacques,
Feb 7 2020, jacqouemin has written:
...
> Everything works fine, but the only big problem is that if I I have more
> instances of the same instrument, I can only hear the last one in the
> score..
...
What are you using to feed audio into the channel(s)? I have been at
fault with these opcodes before. :) You should use chnmix and clear the
channel once you've read the output from it.

HTH.

Best wishes,

JKeanette

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

You might think that I won't make it on my own,
But now I'm Stronger <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

Date2020-02-07 17:04
Fromjacqouemin
SubjectRe: [Csnd] chns with more instances of same instr
Hello Jeanette!
Thank you for your answer!

I am feeding with two "pluck" outlets. 
I am looking better in the doc, but at the same time I did not understand
well the problem.

This is my "schema":
Pluck instr (chnset) -> opcode stereo with chnget and direct outs

If I write a score like this:

                   p4(freq)
i "Pluck" 0 5 100 
i "Pluck" 1 5 200
i "Pluck" 2 5 300

I will always only hear the last one and the others will disappear.



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2020-02-07 17:13
From"Jeanette C."
SubjectRe: [Csnd] chns with more instances of same instr
Feb 7 2020, jacqouemin has written:

...
> This is my "schema":
> Pluck instr (chnset) -> opcode stereo with chnget and direct outs
...
Have you tried chnmix instead of chnset? I think you first need to
create the channel, one time only. Perhaps with an init instrument.

Then in your opcode after calling chnget call chnclear on a channel.

chnmix should solve the problem of only hearing the last instance of
your instrument and chnclear will avoid distortion or similar.

Best wishes,

Jeanette

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

Here I go, on my own now <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

Date2020-02-07 17:19
Fromfra
SubjectRe: [Csnd] chns with more instances of same instr
Hello,

i'm not really sure but when i use same instances of a instrument that 
overlap

i use fractional instrument number (i.e. calling instr 5 as 5.1, 5.2, etc).

Please note that i'm not so sure so i could be really wrong!

Ciao,

francesco.

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

Date2020-02-07 17:36
FromOeyvind Brandtsegg
SubjectRe: [Csnd] chns with more instances of same instr
Hi,

Just my 2 cents:
Jeanette is correct that you should use chnmix instead of chnset.
If you write to a channel named "amp" for example, and this happens in two instrument instances that run simultaneously, then the first instrument will write its signal into the chn, then the second instance of the instrument will write its signal to the same memory space. Effectively overwriting what the first instrument instance put in there. Chnset always overwrites, while chnmix just adds to what is already there. This also creates the need to zero the channel at some point (usually in the last instrument in the orchestra), otherwise we would continue adding to the same signal again on the next k-cycle, and this will quickly explode.

fre. 7. feb. 2020 kl. 18:19 skrev fra <francescoarmandoporta@gmail.com>:
Hello,

i'm not really sure but when i use same instances of a instrument that
overlap

i use fractional instrument number (i.e. calling instr 5 as 5.1, 5.2, etc).

Please note that i'm not so sure so i could be really wrong!

Ciao,

francesco.

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

Date2020-02-08 14:05
Fromjacqouemin
SubjectRe: [Csnd] chns with more instances of same instr
Thank you for all your answers!

I changed "chnset" with "chnmix" and it works!

Now it's clearer how the "chn" system works, but I've stil some issues with
the "chnclear" system. 
If I make a "chnclear" instrument at the end of everything, some channels
still explode (I think because of the inside routing of my chain). On the
contrary if I try to clear channels inside some instruments, the chain I
want to build breaks.

Is there a simple law in order to clear the channels?

Thank you again,
Best,

j



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2020-02-08 14:31
Fromjoachim heintz
SubjectRe: [Csnd] chns with more instances of same instr
what you must do, in general:  to have a chnlear instrument at the very 
end of your signal chain, and for each software channel you use.

if i got it right, you don't know in advance how many channels you will 
have, and how they are called.  perhaps it would work when you call an 
instrument in your UDO which clears the channel you create in this moment:

opcode	stout, 0, S
	Sinstr xin
	a1 chnget sprintf("%s-1", Sinstr)
	a2 chnget sprintf("%s-2", Sinstr)
	schedule "clear",0,99999,Sinstr
	outs a1, a2
endop

the instrument "clear" is then the last one in your csound instruments, 
and contains:

instr clear
  Sinstr strget p4
  chnclear sprintf("%s-1", Sinstr)
  chnclear sprintf("%s-2", Sinstr)
endin

this might work, although it does not really feel good for me because:
1) you create superfluous instances (only one is needed for one channel 
name).
	this could be solved by an if condition.
2) if you delete the channel, the "clear" instrument should be turned 
off, too.
	perhaps you don't delete channels at all, so this might not be an issue.

best -
	joachim


On 08/02/2020 15:05, jacqouemin wrote:
> Thank you for all your answers!
> 
> I changed "chnset" with "chnmix" and it works!
> 
> Now it's clearer how the "chn" system works, but I've stil some issues with
> the "chnclear" system.
> If I make a "chnclear" instrument at the end of everything, some channels
> still explode (I think because of the inside routing of my chain). On the
> contrary if I try to clear channels inside some instruments, the chain I
> want to build breaks.
> 
> Is there a simple law in order to clear the channels?
> 
> Thank you again,
> Best,
> 
> j
> 
> 
> 
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
> 
> 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

Date2020-02-08 15:44
Fromjacqouemin
SubjectRe: [Csnd] chns with more instances of same instr
Thank you joachim.

I tried what you said, but with sad results.

It works with this:

	opcode getmeout, 0, S
Sinstr	xin

S1	sprintf	"%s-1", Sinstr
S2	sprintf	"%s-2", Sinstr

	outs a1, a2

	chnclear sprintf("%s-1", Sinstr) <----------------!!!
	chnclear sprintf("%s-2", Sinstr) <----------------!!!

	endop

I made an instrument "clear", but it doesn't work. I think the problem is
the structure of my instruments: as I said, I am using this method for live
coding and so maybe there is my problem in the instrument chains.

Anyway if I want to build something more complex like this:

	opcode	nofx, 0, SSP
Sin, Sout, kgain xin

a1	chnget sprintf("%s-1", Sin)
a2	chnget sprintf("%s-2", Sin)

a1	*= a(kgain)
a2	*= a(kgain)

	chnmix a1, sprintf("%s-1", Sout)
	chnmix a2, sprintf("%s-2", Sout)

	endop

Everything explodes or there is no sound..! Because I use the two opcode
together and I think there is an accumulation somewhere!

Do you think there is a better way to obtain what I want?
I'd love to route all my instruments with some lines like:

opcode("Myinstr", "Myfx")
opcode("Myfx", "out")

I also checked out the "connect" opcode, but it doesn't work inside opcodes.

j





--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2020-02-08 17:32
Fromjacqouemin
SubjectRe: [Csnd] chns with more instances of same instr
Yes! It worked now, I had too many instrument and the "clear" instrument was
not at the end. I'm sorry!

Now the problem is that I have to increment the number of instances of my
clear instrument passing a string in p-field.

With schedule opcode the instrument doesn't increment his instances number,
am I wrong? Every time is initialised with the new variables. 
With event I cannot pass any string and scoreline doesn't receive variables
inside parenthesis..
I'm stuck!



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2020-02-08 18:15
Fromjoachim heintz
SubjectRe: [Csnd] chns with more instances of same instr
what i suggested was

1) to pass the string Sinstr (which is received in the call of the 
stout) to the call of the clear instrument:
	schedule "clear",0,99999,Sinstr
2) then receive this string and create the appropriate channel name and 
chnclear lines:
	instr clear
	 Sinstr strget p4
  	 chnclear sprintf("%s-1", Sinstr)
	 chnclear sprintf("%s-2", Sinstr)
	endin

when you really did it, i don't understand why you said:
 > Now the problem is that I have to increment the number of instances of my
 > clear instrument passing a string in p-field.


On 08/02/2020 18:32, jacqouemin wrote:
> Yes! It worked now, I had too many instrument and the "clear" instrument was
> not at the end. I'm sorry!
> 
> Now the problem is that I have to increment the number of instances of my
> clear instrument passing a string in p-field.
> 
> With schedule opcode the instrument doesn't increment his instances number,
> am I wrong? Every time is initialised with the new variables.
> With event I cannot pass any string and scoreline doesn't receive variables
> inside parenthesis..
> I'm stuck!
> 
> 
> 
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
> 
> 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