Csound Csound-dev Csound-tekno Search About

[Csnd] New UDO syntax question

Date2026-04-25 12:23
FromJean Basile Sosa
Subject[Csnd] New UDO syntax question
Hello, 

I would like to ask you some explanations about the new UDO syntax.

In a UDP / OSC context, I send to Csound just simple messages as “/csound/event …” or “/csound/channel/…”.

This csound code works well:



-odac --port=7777



sr = 44100
ksmps = 128
nchnls = 2
0dbfs  = 1

gisquare ftgen 2, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09

opcode setget, k, i
pfield:i xin
chnidx:S = sprintf("%.02f_p%d", p1, pfield)
fieldvalue:i = pindex(pfield)
chnset(fieldvalue,chnidx)
value@global:k = chnget(chnidx)
xout(value)
puts(chnidx, 1)
endop

instr 1

asig = oscil(setget(5), setget(4), 2)

outs asig*a(setget(6)), asig*a(setget(6)) 

endin

For example, send a /csound/event "i1.01 0.0000 15.0000 51.0000 0.3390 1.0000” message provide a new instance of i1, and send after that for example a /csound/channel/1.01_p4 [val] massage control the setget(4) parameter / pfield associated. No Csound console warning such as "i1 uses 6 pfield but etc." too.

But you can see the opcode setget uses a mix of old and new syntax.

When I try to follow the new Csound 7 syntax approach this causes some errors and makes my mind noob again. 

Indeed, when I try to send the same messages with this udo: 

opcode setget2(pfield:i):(k)
chnidx:S = sprintf("%.02f_p%d", p1, pfield)
fieldvalue:i = pindex(pfield)
chnset(fieldvalue,chnidx)
value@global:k = chnget(chnidx)
xout(value)
puts(chnidx, 1)
endop

Csound receives an error. I’ve tried to write the udo otherwise but in vain…

I’m pretty sure that my misunderstanding of some basis causes this post.. So...

Thanks for your help Professors friends composers and others! 

Jb 

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

Date2026-04-25 13:43
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] New UDO syntax question
What is the error with the setget2()?

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 25 Apr 2026, at 12:23, Jean Basile Sosa  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.
>
> Hello,
>
> I would like to ask you some explanations about the new UDO syntax.
>
> In a UDP / OSC context, I send to Csound just simple messages as “/csound/event …” or “/csound/channel/…”.
>
> This csound code works well:
>
> 
> 
> -odac --port=7777
> 
> 
>
> sr = 44100
> ksmps = 128
> nchnls = 2
> 0dbfs  = 1
>
> gisquare ftgen 2, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09
>
> opcode setget, k, i
> pfield:i xin
> chnidx:S = sprintf("%.02f_p%d", p1, pfield)
> fieldvalue:i = pindex(pfield)
> chnset(fieldvalue,chnidx)
> value@global:k = chnget(chnidx)
> xout(value)
> puts(chnidx, 1)
> endop
>
> instr 1
>
> asig = oscil(setget(5), setget(4), 2)
>
> outs asig*a(setget(6)), asig*a(setget(6))
>
> endin
>
> For example, send a /csound/event "i1.01 0.0000 15.0000 51.0000 0.3390 1.0000” message provide a new instance of i1, and send after that for example a /csound/channel/1.01_p4 [val] massage control the setget(4) parameter / pfield associated. No Csound console warning such as "i1 uses 6 pfield but etc." too.
>
> But you can see the opcode setget uses a mix of old and new syntax.
>
> When I try to follow the new Csound 7 syntax approach this causes some errors and makes my mind noob again.
>
> Indeed, when I try to send the same messages with this udo:
>
> opcode setget2(pfield:i):(k)
> chnidx:S = sprintf("%.02f_p%d", p1, pfield)
> fieldvalue:i = pindex(pfield)
> chnset(fieldvalue,chnidx)
> value@global:k = chnget(chnidx)
> xout(value)
> puts(chnidx, 1)
> endop
>
> Csound receives an error. I’ve tried to write the udo otherwise but in vain…
>
> I’m pretty sure that my misunderstanding of some basis causes this post.. So...
>
> Thanks for your help Professors friends composers and others!
>
> Jb
>
> 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
The information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.

Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.

Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost seo ó do chóras.

Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.

Registered charity number 20037130



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