Csound Csound-dev Csound-tekno Search About

[Csnd] Error Printing and opcode termination

Date2025-03-20 13:16
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] Error Printing and opcode termination
Hello everybody,

I’m working on some UDOs and instruments for algorithmic purposes.
I’m used to checking the input of algorithms to ensure they are usable and meet the conditions of the code.
In Lisp, I use error printing for this use case.
Is there an equivalent in Csound that allows me to check input variables to UDOs and interrupt the program with a proper error message?

All the best,
Philipp
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

Date2025-03-20 13:25
FromRory Walsh
SubjectRe: [Csnd] Error Printing and opcode termination
I guess you could use exitnow to return as soon as an error occurs? 

On Thu, 20 Mar 2025 at 13:16, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
Hello everybody,

I’m working on some UDOs and instruments for algorithmic purposes.
I’m used to checking the input of algorithms to ensure they are usable and meet the conditions of the code.
In Lisp, I use error printing for this use case.
Is there an equivalent in Csound that allows me to check input variables to UDOs and interrupt the program with a proper error message?

All the best,
Philipp
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

Date2025-03-20 14:04
FromSteven Yi
SubjectRe: [Csnd] Error Printing and opcode termination
I wrote an assert UDO that's in the unit tests for csound:

https://github.com/csound/csound/blob/23540c213447c6b7c8c68eccc9d7853d506a028b/tests/commandline/udo/pass_by_ref.csd#L19

I had been meaning to make this more of a developed UDO library but haven't done so yet, but the general idea works. 

On Thu, Mar 20, 2025 at 9:22 AM Rory Walsh <rorywalsh@ear.ie> wrote:
I guess you could use exitnow to return as soon as an error occurs? 

On Thu, 20 Mar 2025 at 13:16, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
Hello everybody,

I’m working on some UDOs and instruments for algorithmic purposes.
I’m used to checking the input of algorithms to ensure they are usable and meet the conditions of the code.
In Lisp, I use error printing for this use case.
Is there an equivalent in Csound that allows me to check input variables to UDOs and interrupt the program with a proper error message?

All the best,
Philipp
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

Date2025-03-24 09:17
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Error Printing and opcode termination
Thank you both!

I will use exitnow for this.

Philipp

> Am 20.03.2025 um 15:04 schrieb Steven Yi :
> 
> I wrote an assert UDO that's in the unit tests for csound:
> 
> https://github.com/csound/csound/blob/23540c213447c6b7c8c68eccc9d7853d506a028b/tests/commandline/udo/pass_by_ref.csd#L19
> 
> I had been meaning to make this more of a developed UDO library but haven't done so yet, but the general idea works. 
> 
> On Thu, Mar 20, 2025 at 9:22 AM Rory Walsh  wrote:
> I guess you could use exitnow to return as soon as an error occurs? 
> 
> On Thu, 20 Mar 2025 at 13:16, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> Hello everybody,
> 
> I’m working on some UDOs and instruments for algorithmic purposes.
> I’m used to checking the input of algorithms to ensure they are usable and meet the conditions of the code.
> In Lisp, I use error printing for this use case.
> Is there an equivalent in Csound that allows me to check input variables to UDOs and interrupt the program with a proper error message?
> 
> All the best,
> Philipp
> 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

Date2025-03-24 10:35
FromEduardo Moguillansky
SubjectRe: [Csnd] Error Printing and opcode termination
An alternative to just exiting the csound process is to throw an error and terminate the current event. See https://csound-plugins.github.io/csound-plugins/opcodes/initerror.html or https://csound-plugins.github.io/csound-plugins/opcodes/throwerror.html

On Mon, Mar 24, 2025 at 10:17 AM Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
Thank you both!

I will use exitnow for this.

Philipp

> Am 20.03.2025 um 15:04 schrieb Steven Yi <stevenyi@GMAIL.COM>:
>
> I wrote an assert UDO that's in the unit tests for csound:
>
> https://github.com/csound/csound/blob/23540c213447c6b7c8c68eccc9d7853d506a028b/tests/commandline/udo/pass_by_ref.csd#L19
>
> I had been meaning to make this more of a developed UDO library but haven't done so yet, but the general idea works.
>
> On Thu, Mar 20, 2025 at 9:22 AM Rory Walsh <rorywalsh@ear.ie> wrote:
> I guess you could use exitnow to return as soon as an error occurs?
>
> On Thu, 20 Mar 2025 at 13:16, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> Hello everybody,
>
> I’m working on some UDOs and instruments for algorithmic purposes.
> I’m used to checking the input of algorithms to ensure they are usable and meet the conditions of the code.
> In Lisp, I use error printing for this use case.
> Is there an equivalent in Csound that allows me to check input variables to UDOs and interrupt the program with a proper error message?
>
> All the best,
> Philipp
> 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