Csound Csound-dev Csound-tekno Search About

[Csnd] chnset understanding problems

Date2024-10-09 15:49
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] chnset understanding problems
hello everybody,

i have a problem with using the chnset and chnget opcodes.

i want to send an array of k values with chnset to a destination which also expects a k-array.
but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.

this is my sketch. what do i do wrong?

// sending
  kMidiData[] ctrlsave 1,\
    0,1,2,3,4,5,6,7,8,9,10,\
    11,12,13,14,15
  chnset kMidiData, "midiData_faderfoxec4“ 

// receiving
  kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")

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

Date2024-10-09 16:00
Fromjoachim heintz
SubjectRe: [Csnd] chnset understanding problems
i don't think you can send / receive an array.
rory added the array version, but is has different names:
https://csound.com/docs/manual/chnset.html

best -
	joachim


On 09/10/2024 16:49, Philipp Neumann wrote:
> hello everybody,
> 
> i have a problem with using the chnset and chnget opcodes.
> 
> i want to send an array of k values with chnset to a destination which also expects a k-array.
> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
> 
> this is my sketch. what do i do wrong?
> 
> // sending
>    kMidiData[] ctrlsave 1,\
>      0,1,2,3,4,5,6,7,8,9,10,\
>      11,12,13,14,15
>    chnset kMidiData, "midiData_faderfoxec4“
> 
> // receiving
>    kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
> 
> 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

Date2024-10-09 16:20
FromRory Walsh
SubjectRe: [Csnd] chnset understanding problems

On Wed, 9 Oct 2024 at 16:00, joachim heintz <jh@joachimheintz.de> wrote:
i don't think you can send / receive an array.
rory added the array version, but is has different names:
https://csound.com/docs/manual/chnset.html

best -
        joachim


On 09/10/2024 16:49, Philipp Neumann wrote:
> hello everybody,
>
> i have a problem with using the chnset and chnget opcodes.
>
> i want to send an array of k values with chnset to a destination which also expects a k-array.
> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
>
> this is my sketch. what do i do wrong?
>
> // sending
>    kMidiData[] ctrlsave 1,\
>      0,1,2,3,4,5,6,7,8,9,10,\
>      11,12,13,14,15
>    chnset kMidiData, "midiData_faderfoxec4“
>
> // receiving
>    kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
>
> 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

Date2024-10-10 18:04
FromRisto Kuusisto
SubjectRe: [Csnd] chnset understanding problems
From that .csd:

instr 1; send k-values
    SChan[] init 2
    SChan[0] = "kChan1"
    SChan[1] = "kChan2"
    kArr[] fillarray 1, 2
    chnsetk kArr, SChan
endin

If I understand correctly the example above arrays are "unsymmetric". Is it so that an array "kArr[]" in Csound requires separate
scalar channels "kChan1" and "kChan2" as a counterpart in e.g. java-code ?
Is it possible that both sides, Csound and e.g. java,  could be arrays ?

--Risto

ke 9. lokak. 2024 klo 18.17 Rory Walsh (rorywalsh@ear.ie) kirjoitti:

On Wed, 9 Oct 2024 at 16:00, joachim heintz <jh@joachimheintz.de> wrote:
i don't think you can send / receive an array.
rory added the array version, but is has different names:
https://csound.com/docs/manual/chnset.html

best -
        joachim


On 09/10/2024 16:49, Philipp Neumann wrote:
> hello everybody,
>
> i have a problem with using the chnset and chnget opcodes.
>
> i want to send an array of k values with chnset to a destination which also expects a k-array.
> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
>
> this is my sketch. what do i do wrong?
>
> // sending
>    kMidiData[] ctrlsave 1,\
>      0,1,2,3,4,5,6,7,8,9,10,\
>      11,12,13,14,15
>    chnset kMidiData, "midiData_faderfoxec4“
>
> // receiving
>    kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
>
> 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
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

Date2024-10-10 22:53
FromEduardo Moguillansky
SubjectRe: [Csnd] chnset understanding problems
I made an opcode pair (ref/deref) which can be used to pass an array by reference (https://csound-plugins.github.io/csound-plugins/opcodes/ref.html). In this case you can use a scalar channel:

<CsoundSynthesizer>
<CsOptions>
--nosound

</CsOptions>

<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 2
0dbfs  = 1

instr 1
  karr[] fillarray 1, 2, 3, 4
  chnset ref(karr), "mychan"
  turnoff
endin

instr 2
  karr2[] deref chnget("mychan")
  printarray karr2
  turnoff
endin

</CsInstruments>

<CsScore>

i 1 0 1
i 2 0 1

</CsScore>
</CsoundSynthesizer>


On Wed, Oct 9, 2024 at 4:50 PM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
hello everybody,

i have a problem with using the chnset and chnget opcodes.

i want to send an array of k values with chnset to a destination which also expects a k-array.
but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.

this is my sketch. what do i do wrong?

// sending
  kMidiData[] ctrlsave 1,\
    0,1,2,3,4,5,6,7,8,9,10,\
    11,12,13,14,15
  chnset kMidiData, "midiData_faderfoxec4“

// receiving
  kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")

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

Date2024-10-10 23:06
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] chnset understanding problems
These opcodes are using normal control channels. In Csound 7 there are array channels, so complete arrays can be passed in and out of channels.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 10 Oct 2024, at 18:04, Risto Kuusisto <rjzkuusisto@gmail.com> wrote:


From that .csd:

instr 1; send k-values
    SChan[] init 2
    SChan[0] = "kChan1"
    SChan[1] = "kChan2"
    kArr[] fillarray 1, 2
    chnsetk kArr, SChan
endin

If I understand correctly the example above arrays are "unsymmetric". Is it so that an array "kArr[]" in Csound requires separate
scalar channels "kChan1" and "kChan2" as a counterpart in e.g. java-code ?
Is it possible that both sides, Csound and e.g. java,  could be arrays ?

--Risto

ke 9. lokak. 2024 klo 18.17 Rory Walsh (rorywalsh@ear.ie) kirjoitti:

On Wed, 9 Oct 2024 at 16:00, joachim heintz <jh@joachimheintz.de> wrote:
i don't think you can send / receive an array.
rory added the array version, but is has different names:
https://csound.com/docs/manual/chnset.html

best -
        joachim


On 09/10/2024 16:49, Philipp Neumann wrote:
> hello everybody,
>
> i have a problem with using the chnset and chnget opcodes.
>
> i want to send an array of k values with chnset to a destination which also expects a k-array.
> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
>
> this is my sketch. what do i do wrong?
>
> // sending
>    kMidiData[] ctrlsave 1,\
>      0,1,2,3,4,5,6,7,8,9,10,\
>      11,12,13,14,15
>    chnset kMidiData, "midiData_faderfoxec4“
>
> // receiving
>    kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
>
> 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
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

Date2024-10-11 13:31
FromRisto Kuusisto
SubjectRe: [Csnd] chnset understanding problems
Thanks Eduardo
This seems to be half of the solution. But what does this mean in java-code ...
I suppose you can do almost any kind of tricks utilising pointers and casting in c-code.
I'm not sure how to do the same in java...
Here are some pieces of code in java and the question after that.

First object creation:
CsoundMYFLTArray CtNbrChannel = new CsoundMYFLTArray();
...
c.GetChannelPtr(CtNbrChannel.GetPtr(), "CtNbr", ....
...

And usage, setting a single value e.g.:

CtNbrChannel.SetValue(0, (double) 0);

As you can guess the Channel requires double as the actual value java data-type and some
integer argument 0.
The java-help (in Eclipse) tells about that method:
    void csnd6.CsoundMYFLTArray.SetValue(int arg0, double arg1)

So now the question is how is it possible to feed a double-array as an argument instead of a double scalar here ?

One guess that I have in mind is that it could be enough to use the 1'st element of a double array as the value-argument.
If the internal behaviour of the API is such that only pointers are in use, then referring to the first element of a double-array
would point to the whole array at the same time ...hmmm, just guessing.

Then I could have in java:

     // an array definition
double[] Cnbr = { 71,72,73,74,75,76,77,78 };
...

And usage:

CtNbrChannel.SetValue(0, Cnbr[0]);

Still wondering what should the value of the arg0 ?

Does anyone have better information about this ?

--Risto






pe 11. lokak. 2024 klo 0.54 Eduardo Moguillansky (eduardo.moguillansky@gmail.com) kirjoitti:
I made an opcode pair (ref/deref) which can be used to pass an array by reference (https://csound-plugins.github.io/csound-plugins/opcodes/ref.html). In this case you can use a scalar channel:

<CsoundSynthesizer>
<CsOptions>
--nosound

</CsOptions>

<CsInstruments>
sr     = 44100
ksmps  = 64
nchnls = 2
0dbfs  = 1

instr 1
  karr[] fillarray 1, 2, 3, 4
  chnset ref(karr), "mychan"
  turnoff
endin

instr 2
  karr2[] deref chnget("mychan")
  printarray karr2
  turnoff
endin

</CsInstruments>

<CsScore>

i 1 0 1
i 2 0 1

</CsScore>
</CsoundSynthesizer>


On Wed, Oct 9, 2024 at 4:50 PM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
hello everybody,

i have a problem with using the chnset and chnget opcodes.

i want to send an array of k values with chnset to a destination which also expects a k-array.
but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.

this is my sketch. what do i do wrong?

// sending
  kMidiData[] ctrlsave 1,\
    0,1,2,3,4,5,6,7,8,9,10,\
    11,12,13,14,15
  chnset kMidiData, "midiData_faderfoxec4“

// receiving
  kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")

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

Date2024-10-15 10:06
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] chnset understanding problems
Thanks Eduardo for this link!
Looks very interesting!

Does this mean i can pass a array to an UDO and change this array outside and get these changes updated inside an UDO?

Do i need to deref the array inside the UDO?

Greetings,
Philipp

> Am 10.10.2024 um 23:53 schrieb Eduardo Moguillansky :
> 
> I made an opcode pair (ref/deref) which can be used to pass an array by reference (https://csound-plugins.github.io/csound-plugins/opcodes/ref.html). In this case you can use a scalar channel:
> 
> 
> 
> --nosound
> 
> 
> 
> 
> sr     = 44100
> ksmps  = 64
> nchnls = 2
> 0dbfs  = 1
> 
> instr 1
>   karr[] fillarray 1, 2, 3, 4
>   chnset ref(karr), "mychan"
>   turnoff
> endin
> 
> instr 2
>   karr2[] deref chnget("mychan")
>   printarray karr2
>   turnoff
> endin
> 
> 
> 
> 
> 
> i 1 0 1
> i 2 0 1
> 
> 
> 
> 
> On Wed, Oct 9, 2024 at 4:50 PM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> hello everybody,
> 
> i have a problem with using the chnset and chnget opcodes.
> 
> i want to send an array of k values with chnset to a destination which also expects a k-array.
> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
> 
> this is my sketch. what do i do wrong?
> 
> // sending
>   kMidiData[] ctrlsave 1,\
>     0,1,2,3,4,5,6,7,8,9,10,\
>     11,12,13,14,15
>   chnset kMidiData, "midiData_faderfoxec4“ 
> 
> // receiving
>   kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
> 
> 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

Date2024-10-15 10:21
FromEduardo Moguillansky
SubjectRe: [Csnd] chnset understanding problems


On Tue, Oct 15, 2024 at 11:06 AM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
Thanks Eduardo for this link!
Looks very interesting!

Does this mean i can pass a array to an UDO and change this array outside and get these changes updated inside an UDO?

Yes, they share the same memory. In particular, any change to the array inside the UDO will be reflected in the original array.

opcode arrayadd_inplace, 0, ii
  ; in place 
  iref, ix xin
  iIn[] deref iref
  iIn += ix
endop

You would call this with

iMyArray[] fillarray 0, 1, 2, 3
arrayadd_inplace(ref(iMyArray), 5)

After this iMyArray would hold 5, 6, 7, 8

Do i need to deref the array inside the UDO?

Greetings,
Philipp

> Am 10.10.2024 um 23:53 schrieb Eduardo Moguillansky <eduardo.moguillansky@GMAIL.COM>:
>
> I made an opcode pair (ref/deref) which can be used to pass an array by reference (https://csound-plugins.github.io/csound-plugins/opcodes/ref.html). In this case you can use a scalar channel:
>
> <CsoundSynthesizer>
> <CsOptions>
> --nosound
>
> </CsOptions>
>
> <CsInstruments>
> sr     = 44100
> ksmps  = 64
> nchnls = 2
> 0dbfs  = 1
>
> instr 1
>   karr[] fillarray 1, 2, 3, 4
>   chnset ref(karr), "mychan"
>   turnoff
> endin
>
> instr 2
>   karr2[] deref chnget("mychan")
>   printarray karr2
>   turnoff
> endin
>
> </CsInstruments>
>
> <CsScore>
>
> i 1 0 1
> i 2 0 1
>
> </CsScore>
> </CsoundSynthesizer>
>
> On Wed, Oct 9, 2024 at 4:50 PM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> hello everybody,
>
> i have a problem with using the chnset and chnget opcodes.
>
> i want to send an array of k values with chnset to a destination which also expects a k-array.
> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
>
> this is my sketch. what do i do wrong?
>
> // sending
>   kMidiData[] ctrlsave 1,\
>     0,1,2,3,4,5,6,7,8,9,10,\
>     11,12,13,14,15
>   chnset kMidiData, "midiData_faderfoxec4“
>
> // receiving
>   kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
>
> 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
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

Date2024-10-15 21:29
FromSteven Yi
SubjectRe: [Csnd] chnset understanding problems
FYI: the equivalent code in CS7 using new-style UDOs which implement
pass-by-ref:

opcode arrayadd_inplace(arrayRef:i[], ix):void
  arrayRef += ix
endop

instr 1
  myArray:i[] = [0, 1, 2, 3]
  printarray(myArray)
  arrayadd_inplace(myArray, 5)
  printarray(myArray)
endin

prints the following:

0.0000 1.0000 2.0000 3.0000
5.0000 6.0000 7.0000 8.0000


On Tue, Oct 15, 2024 at 5:22 AM Eduardo Moguillansky
 wrote:
>
>
>
> On Tue, Oct 15, 2024 at 11:06 AM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>>
>> Thanks Eduardo for this link!
>> Looks very interesting!
>>
>> Does this mean i can pass a array to an UDO and change this array outside and get these changes updated inside an UDO?
>
>
> Yes, they share the same memory. In particular, any change to the array inside the UDO will be reflected in the original array.
>
> opcode arrayadd_inplace, 0, ii
>   ; in place
>   iref, ix xin
>   iIn[] deref iref
>   iIn += ix
> endop
>
> You would call this with
>
> iMyArray[] fillarray 0, 1, 2, 3
>
> arrayadd_inplace(ref(iMyArray), 5)
>
> After this iMyArray would hold 5, 6, 7, 8
>>
>>
>> Do i need to deref the array inside the UDO?
>>
>> Greetings,
>> Philipp
>>
>> > Am 10.10.2024 um 23:53 schrieb Eduardo Moguillansky :
>> >
>> > I made an opcode pair (ref/deref) which can be used to pass an array by reference (https://csound-plugins.github.io/csound-plugins/opcodes/ref.html). In this case you can use a scalar channel:
>> >
>> > 
>> > 
>> > --nosound
>> >
>> > 
>> >
>> > 
>> > sr     = 44100
>> > ksmps  = 64
>> > nchnls = 2
>> > 0dbfs  = 1
>> >
>> > instr 1
>> >   karr[] fillarray 1, 2, 3, 4
>> >   chnset ref(karr), "mychan"
>> >   turnoff
>> > endin
>> >
>> > instr 2
>> >   karr2[] deref chnget("mychan")
>> >   printarray karr2
>> >   turnoff
>> > endin
>> >
>> > 
>> >
>> > 
>> >
>> > i 1 0 1
>> > i 2 0 1
>> >
>> > 
>> > 
>> >
>> > On Wed, Oct 9, 2024 at 4:50 PM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>> > hello everybody,
>> >
>> > i have a problem with using the chnset and chnget opcodes.
>> >
>> > i want to send an array of k values with chnset to a destination which also expects a k-array.
>> > but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
>> >
>> > this is my sketch. what do i do wrong?
>> >
>> > // sending
>> >   kMidiData[] ctrlsave 1,\
>> >     0,1,2,3,4,5,6,7,8,9,10,\
>> >     11,12,13,14,15
>> >   chnset kMidiData, "midiData_faderfoxec4“
>> >
>> > // receiving
>> >   kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
>> >
>> > 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
>
> 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

Date2024-10-16 06:54
Fromjoachim heintz
SubjectRe: [Csnd] chnset understanding problems
thanks for the very instructive example!!
	j


On 15/10/2024 22:29, Steven Yi wrote:
> opcode arrayadd_inplace(arrayRef:i[], ix):void
>    arrayRef += ix
> endop
> 
> instr 1
>    myArray:i[] = [0, 1, 2, 3]
>    printarray(myArray)
>    arrayadd_inplace(myArray, 5)
>    printarray(myArray)
> endin

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

Date2024-10-16 07:43
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] chnset understanding problems
ah, csound 7 looks very promissing!
looking forward to the release!



> Am 15.10.2024 um 22:29 schrieb Steven Yi :
> 
> FYI: the equivalent code in CS7 using new-style UDOs which implement
> pass-by-ref:
> 
> opcode arrayadd_inplace(arrayRef:i[], ix):void
>  arrayRef += ix
> endop
> 
> instr 1
>  myArray:i[] = [0, 1, 2, 3]
>  printarray(myArray)
>  arrayadd_inplace(myArray, 5)
>  printarray(myArray)
> endin
> 
> prints the following:
> 
> 0.0000 1.0000 2.0000 3.0000
> 5.0000 6.0000 7.0000 8.0000
> 
> 
> On Tue, Oct 15, 2024 at 5:22 AM Eduardo Moguillansky
>  wrote:
>> 
>> 
>> 
>> On Tue, Oct 15, 2024 at 11:06 AM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>>> 
>>> Thanks Eduardo for this link!
>>> Looks very interesting!
>>> 
>>> Does this mean i can pass a array to an UDO and change this array outside and get these changes updated inside an UDO?
>> 
>> 
>> Yes, they share the same memory. In particular, any change to the array inside the UDO will be reflected in the original array.
>> 
>> opcode arrayadd_inplace, 0, ii
>>  ; in place
>>  iref, ix xin
>>  iIn[] deref iref
>>  iIn += ix
>> endop
>> 
>> You would call this with
>> 
>> iMyArray[] fillarray 0, 1, 2, 3
>> 
>> arrayadd_inplace(ref(iMyArray), 5)
>> 
>> After this iMyArray would hold 5, 6, 7, 8
>>> 
>>> 
>>> Do i need to deref the array inside the UDO?
>>> 
>>> Greetings,
>>> Philipp
>>> 
>>>> Am 10.10.2024 um 23:53 schrieb Eduardo Moguillansky :
>>>> 
>>>> I made an opcode pair (ref/deref) which can be used to pass an array by reference (https://csound-plugins.github.io/csound-plugins/opcodes/ref.html). In this case you can use a scalar channel:
>>>> 
>>>> 
>>>> 
>>>> --nosound
>>>> 
>>>> 
>>>> 
>>>> 
>>>> sr     = 44100
>>>> ksmps  = 64
>>>> nchnls = 2
>>>> 0dbfs  = 1
>>>> 
>>>> instr 1
>>>>  karr[] fillarray 1, 2, 3, 4
>>>>  chnset ref(karr), "mychan"
>>>>  turnoff
>>>> endin
>>>> 
>>>> instr 2
>>>>  karr2[] deref chnget("mychan")
>>>>  printarray karr2
>>>>  turnoff
>>>> endin
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> i 1 0 1
>>>> i 2 0 1
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Wed, Oct 9, 2024 at 4:50 PM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>>>> hello everybody,
>>>> 
>>>> i have a problem with using the chnset and chnget opcodes.
>>>> 
>>>> i want to send an array of k values with chnset to a destination which also expects a k-array.
>>>> but the console tells me i do something wrong with at leats chnset and the examples in the manual did not help me.
>>>> 
>>>> this is my sketch. what do i do wrong?
>>>> 
>>>> // sending
>>>>  kMidiData[] ctrlsave 1,\
>>>>    0,1,2,3,4,5,6,7,8,9,10,\
>>>>    11,12,13,14,15
>>>>  chnset kMidiData, "midiData_faderfoxec4“
>>>> 
>>>> // receiving
>>>>  kPreset ctrlpreset p4, chnget("midiData_faderfoxec4")
>>>> 
>>>> 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
>> 
>> 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

Date2024-10-16 07:47
FromEduardo Moguillansky
SubjectRe: [Csnd] chnset understanding problems
Steven, thanks for the clarification regarding pass by ref in csound7. Is there any reference regarding this anywhere? In particular, are return arrays also passed by ref? What happens if an udo changes the size of an array? And the last: is there any mechanism to pass an array to an instr?

On Wed, Oct 16, 2024 at 7:54 AM joachim heintz <jh@joachimheintz.de> wrote:
thanks for the very instructive example!!
        j


On 15/10/2024 22:29, Steven Yi wrote:
> opcode arrayadd_inplace(arrayRef:i[], ix):void
>    arrayRef += ix
> endop
>
> instr 1
>    myArray:i[] = [0, 1, 2, 3]
>    printarray(myArray)
>    arrayadd_inplace(myArray, 5)
>    printarray(myArray)
> endin

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

Date2024-10-16 12:26
FromSi Mills
SubjectRe: [Csnd] chnset understanding problems
That reduction in boilerplate is great! The code looks nice and succinct.

Is there any form of documentation for csound7 yet I can take a look at?

Cheers

On 16 Oct 2024, at 07:47, Eduardo Moguillansky <eduardo.moguillansky@GMAIL.COM> wrote:

Steven, thanks for the clarification regarding pass by ref in csound7. Is there any reference regarding this anywhere? In particular, are return arrays also passed by ref? What happens if an udo changes the size of an array? And the last: is there any mechanism to pass an array to an instr?

On Wed, Oct 16, 2024 at 7:54 AM joachim heintz <jh@joachimheintz.de> wrote:
thanks for the very instructive example!!
        j


On 15/10/2024 22:29, Steven Yi wrote:
> opcode arrayadd_inplace(arrayRef:i[], ix):void
>    arrayRef += ix
> endop
>
> instr 1
>    myArray:i[] = [0, 1, 2, 3]
>    printarray(myArray)
>    arrayadd_inplace(myArray, 5)
>    printarray(myArray)
> endin

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


Date2024-10-16 12:53
Fromvlz
SubjectRe: [Csnd] chnset understanding problems
I don’t think this is exactly reduction in boilerplate but something that offers other
styles of programming which we did not before. It is important to know that with this
we have a situation where side-effects are explicit and it may require some careful
thought.

Regarding documentation, we don’t have anything beyond the CSD examples under
tests/commandline but hopefully we will have something in the new manual that is
being worked at slowly.

> On 16 Oct 2024, at 12:26, Si Mills  wrote:
> 
> That reduction in boilerplate is great! The code looks nice and succinct.
> 
> Is there any form of documentation for csound7 yet I can take a look at?
> 
> Cheers
> 
>> On 16 Oct 2024, at 07:47, Eduardo Moguillansky  wrote:
>> 
>> Steven, thanks for the clarification regarding pass by ref in csound7. Is there any reference regarding this anywhere? In particular, are return arrays also passed by ref? What happens if an udo changes the size of an array? And the last: is there any mechanism to pass an array to an instr? 
>> 
>> On Wed, Oct 16, 2024 at 7:54 AM joachim heintz  wrote:
>> thanks for the very instructive example!!
>>         j
>> 
>> 
>> On 15/10/2024 22:29, Steven Yi wrote:
>> > opcode arrayadd_inplace(arrayRef:i[], ix):void
>> >    arrayRef += ix
>> > endop
>> > 
>> > instr 1
>> >    myArray:i[] = [0, 1, 2, 3]
>> >    printarray(myArray)
>> >    arrayadd_inplace(myArray, 5)
>> >    printarray(myArray)
>> > endin
>> 
>> 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

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

Date2024-10-17 16:39
FromSteven Yi
SubjectRe: [Csnd] chnset understanding problems
Hi Eduardo,

At the moment the implementation is merged into the develop branch and
can be used with CS7 build. There's an open issue to optimize the
parsing out of xin/xout for pass-by-ref UDOs, but the main mechanism
to search opcodes for vars that match xin/xout and set the pointers is
working and should work for returned arrays. I have not tested for
array size changes but *should* work fine. I think at this point it's
in a state where getting users to test it out and help with
identifying any remaining issues would be invaluable.

As of the moment, pass-by-ref will be used when using new-style UDOs
with the exception that if there is a difference in local sr or ksmps
compared to the parent (i.e., calling code), it will fall back to pass
by value. There's an opportunity to do some optimization there but it
was the safest thing to do right now considering the complexity in
that area of processing.

As for passing arrays to instruments, there's no mechanism at the
moment. There's been a long-standing todo to modify the event data
structure to use CS_VAR_MEM instead of numeric pointers (+ magic code
for strings) for pfields. I'm unsure about the implications for memory
allocations and runtime but we would need to go this route if we want
to pass any data type as a pfield argument.

Let me know if you have any further questions!

Steven

On Wed, Oct 16, 2024 at 2:48 AM Eduardo Moguillansky
 wrote:
>
> Steven, thanks for the clarification regarding pass by ref in csound7. Is there any reference regarding this anywhere? In particular, are return arrays also passed by ref? What happens if an udo changes the size of an array? And the last: is there any mechanism to pass an array to an instr?
>
> On Wed, Oct 16, 2024 at 7:54 AM joachim heintz  wrote:
>>
>> thanks for the very instructive example!!
>>         j
>>
>>
>> On 15/10/2024 22:29, Steven Yi wrote:
>> > opcode arrayadd_inplace(arrayRef:i[], ix):void
>> >    arrayRef += ix
>> > endop
>> >
>> > instr 1
>> >    myArray:i[] = [0, 1, 2, 3]
>> >    printarray(myArray)
>> >    arrayadd_inplace(myArray, 5)
>> >    printarray(myArray)
>> > endin
>>
>> 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

Date2024-10-18 12:43
FromSi Mills
SubjectRe: [Csnd] chnset understanding problems
Hey Steven

If in any case you’d want to pass an array by value to a UDO in CS7, would you just use the old-style UDO?

This is a great development in any case!

Cheers

> On 17 Oct 2024, at 16:39, Steven Yi  wrote:
> 
> Hi Eduardo,
> 
> At the moment the implementation is merged into the develop branch and
> can be used with CS7 build. There's an open issue to optimize the
> parsing out of xin/xout for pass-by-ref UDOs, but the main mechanism
> to search opcodes for vars that match xin/xout and set the pointers is
> working and should work for returned arrays. I have not tested for
> array size changes but *should* work fine. I think at this point it's
> in a state where getting users to test it out and help with
> identifying any remaining issues would be invaluable.
> 
> As of the moment, pass-by-ref will be used when using new-style UDOs
> with the exception that if there is a difference in local sr or ksmps
> compared to the parent (i.e., calling code), it will fall back to pass
> by value. There's an opportunity to do some optimization there but it
> was the safest thing to do right now considering the complexity in
> that area of processing.
> 
> As for passing arrays to instruments, there's no mechanism at the
> moment. There's been a long-standing todo to modify the event data
> structure to use CS_VAR_MEM instead of numeric pointers (+ magic code
> for strings) for pfields. I'm unsure about the implications for memory
> allocations and runtime but we would need to go this route if we want
> to pass any data type as a pfield argument.
> 
> Let me know if you have any further questions!
> 
> Steven
> 
> On Wed, Oct 16, 2024 at 2:48 AM Eduardo Moguillansky
>  wrote:
>> 
>> Steven, thanks for the clarification regarding pass by ref in csound7. Is there any reference regarding this anywhere? In particular, are return arrays also passed by ref? What happens if an udo changes the size of an array? And the last: is there any mechanism to pass an array to an instr?
>> 
>> On Wed, Oct 16, 2024 at 7:54 AM joachim heintz  wrote:
>>> 
>>> thanks for the very instructive example!!
>>>        j
>>> 
>>> 
>>> On 15/10/2024 22:29, Steven Yi wrote:
>>>> opcode arrayadd_inplace(arrayRef:i[], ix):void
>>>>   arrayRef += ix
>>>> endop
>>>> 
>>>> instr 1
>>>>   myArray:i[] = [0, 1, 2, 3]
>>>>   printarray(myArray)
>>>>   arrayadd_inplace(myArray, 5)
>>>>   printarray(myArray)
>>>> endin
>>> 
>>> 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

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