Csound Csound-dev Csound-tekno Search About

[Csnd] OSClisten and why I need to do a loop

Date2026-04-25 22:23
FromBrandon Hale
Subject[Csnd] OSClisten and why I need to do a loop
Hello all,

I'm sure this has been asked before, but I'm trying to understand the 
reason why OSClisten needs a loop. Take a simple example from my orchestra:

gioscserver OSCinit 9999

instr 1

   kamp init 0
   kfreq init 0
   kampxy init 0
   kfreqxy init 0

nxtmsg:
   koscparams OSClisten gioscserver, "/params", "ff", kamp, kfreq
   kxypad OSClisten gioscserver, "/xy_1", "ff", kampxy, kfreqxy
   if (koscparams == 0) goto ex
   	printk .1, kampxy
   	printk .1, kfreqxy
   	kgoto nxtmsg

ex:
   augen oscili kampxy, kfreqxy*2000, 1
   out augen


endin


I'm trying to understand why I need these loops and goto statements from 
the manual when I use OSClisten and what I should do when I want to use 
multiple osc inputs. This example above does work, but I don't really 
understand why I need to do the goto statements at all.

Would someone be willing to explain? Once I figure it out, I plan on 
making a user-defined opcode so I no longer have to think about this...

Thank you for your help,
Brandon Hale

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 22:39
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] OSClisten and why I need to do a loop
If more than one OSC messages arrive in one kcycle, then you need to loop over them to retrieve them
all in a single kcycle. It may work without the loop, but I guess this is the recommended approach.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland






> On 25 Apr 2026, at 22:23, Brandon Hale  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 all,
>
> I'm sure this has been asked before, but I'm trying to understand the
> reason why OSClisten needs a loop. Take a simple example from my orchestra:
>
> gioscserver OSCinit 9999
>
> instr 1
>
>  kamp init 0
>  kfreq init 0
>  kampxy init 0
>  kfreqxy init 0
>
> nxtmsg:
>  koscparams OSClisten gioscserver, "/params", "ff", kamp, kfreq
>  kxypad OSClisten gioscserver, "/xy_1", "ff", kampxy, kfreqxy
>  if (koscparams == 0) goto ex
>       printk .1, kampxy
>       printk .1, kfreqxy
>       kgoto nxtmsg
>
> ex:
>  augen oscili kampxy, kfreqxy*2000, 1
>  out augen
>
>
> endin
>
>
> I'm trying to understand why I need these loops and goto statements from
> the manual when I use OSClisten and what I should do when I want to use
> multiple osc inputs. This example above does work, but I don't really
> understand why I need to do the goto statements at all.
>
> Would someone be willing to explain? Once I figure it out, I plan on
> making a user-defined opcode so I no longer have to think about this...
>
> Thank you for your help,
> Brandon Hale
>
> 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

Date2026-04-25 22:40
From"Jeanette C." <000015cdd0ffa6cd-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] OSClisten and why I need to do a loop
Hi Brandon,
ha, I see why. From the manual, the section on the output parameter kans:
If multiple messages are received in a single control period, the messages are 
buffered, and OSClisten can be called again until zero is returned.

So you run the while - or any other - loop, for that eventuality.

Personally, I would use a while loop, perhaps:
while kans != 0 do
   kans, kdata[] osclisten ...
   ; handle your data somehow
done

HTH.

Best wishes,

Jeanette

--
  * PeerTube: https://makertube.net/@jeanette_c
  * GitHub: https://github.com/jeanette-c
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g

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