[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
        GitHub · Where software is built
Discussions of bugs and features can be posted here

I guess you could use exitnow to return as soon as an error occurs?

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.

Thank you both!

I will use exitnow for this.

Philipp

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