Csound Csound-dev Csound-tekno Search About

[Csnd-dev] setoption not overriding when compileCsd used

Date2025-11-05 23:14
FromSteven Yi
Subject[Csnd-dev] setoption not overriding when compileCsd used
Hi All,

Not sure if it's just me but I'm working on a webaudio example and
found that if I had "-Wooutput.wav" in CsOptions in a csd, then in my
code used:

cs.setOption("-odac")
cs.compileCsd("test.csd", 0)

the setOption would not override the csd's CsOptions. I was expecting
setOption to override in the same way that:

csound -odac test.csd

would have the command-line option override the CsOptions.

Wondering if this is a bug in the API?

Steven

Date2025-11-05 23:59
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] setoption not overriding when compileCsd used
I think the call order may be the factor here.
csoundSetOption() is called and then the CSD is read, setting the options again. I think that if it is called after the CSD is read, then it will override it, but not before.

If you look at the code, csoundSetOption() calls argdecode to set the options passed to it.
Then the csoundCompileCSD() reads the CSD and calls argdecode to do the same. So I think basically it can override previously set options.

As far as I can remember, this was also how the 6.x API worked (the functions did not change in that regard).


Prof. Victor Lazzarini
Maynooth University
Ireland

> On 5 Nov 2025, at 23:14, Steven Yi  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.
> 
> Hi All,
> 
> Not sure if it's just me but I'm working on a webaudio example and
> found that if I had "-Wooutput.wav" in CsOptions in a csd, then in my
> code used:
> 
> cs.setOption("-odac")
> cs.compileCsd("test.csd", 0)
> 
> the setOption would not override the csd's CsOptions. I was expecting
> setOption to override in the same way that:
> 
> csound -odac test.csd
> 
> would have the command-line option override the CsOptions.
> 
> Wondering if this is a bug in the API?
> 
> Steven

Date2025-11-06 00:44
FromSteven Yi
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] setoption not overriding when compileCsd used
Setting it after compileCsd looks to be working. It's odd as in other
scenarios where I use compileOrc with string text, I usually call
setOption() prior to compileOrc. I'll review some things and sort it
out. Thanks for that!

On Wed, Nov 5, 2025 at 6:59 PM Victor Lazzarini
<000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
>
> I think the call order may be the factor here.
> csoundSetOption() is called and then the CSD is read, setting the options again. I think that if it is called after the CSD is read, then it will override it, but not before.
>
> If you look at the code, csoundSetOption() calls argdecode to set the options passed to it.
> Then the csoundCompileCSD() reads the CSD and calls argdecode to do the same. So I think basically it can override previously set options.
>
> As far as I can remember, this was also how the 6.x API worked (the functions did not change in that regard).
>
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
> > On 5 Nov 2025, at 23:14, Steven Yi  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.
> >
> > Hi All,
> >
> > Not sure if it's just me but I'm working on a webaudio example and
> > found that if I had "-Wooutput.wav" in CsOptions in a csd, then in my
> > code used:
> >
> > cs.setOption("-odac")
> > cs.compileCsd("test.csd", 0)
> >
> > the setOption would not override the csd's CsOptions. I was expecting
> > setOption to override in the same way that:
> >
> > csound -odac test.csd
> >
> > would have the command-line option override the CsOptions.
> >
> > Wondering if this is a bug in the API?
> >
> > Steven

Date2025-11-06 06:34
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd-dev] [EXTERNAL] [Csnd-dev] setoption not overriding when compileCsd used
I guess that's ok because compileOrc does not set any options. If we call compile() a similar thing happens to compileCSD().

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 6 Nov 2025, at 00:44, Steven Yi  wrote:
> 
> Setting it after compileCsd looks to be working. It's odd as in other
> scenarios where I use compileOrc with string text, I usually call
> setOption() prior to compileOrc. I'll review some things and sort it
> out. Thanks for that!
> 
>> On Wed, Nov 5, 2025 at 6:59 PM Victor Lazzarini
>> <000010b17ddd988e-dmarc-request@listserv.heanet.ie> wrote:
>> 
>> I think the call order may be the factor here.
>> csoundSetOption() is called and then the CSD is read, setting the options again. I think that if it is called after the CSD is read, then it will override it, but not before.
>> 
>> If you look at the code, csoundSetOption() calls argdecode to set the options passed to it.
>> Then the csoundCompileCSD() reads the CSD and calls argdecode to do the same. So I think basically it can override previously set options.
>> 
>> As far as I can remember, this was also how the 6.x API worked (the functions did not change in that regard).
>> 
>> 
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>> 
>>>> On 5 Nov 2025, at 23:14, Steven Yi  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.
>>> 
>>> Hi All,
>>> 
>>> Not sure if it's just me but I'm working on a webaudio example and
>>> found that if I had "-Wooutput.wav" in CsOptions in a csd, then in my
>>> code used:
>>> 
>>> cs.setOption("-odac")
>>> cs.compileCsd("test.csd", 0)
>>> 
>>> the setOption would not override the csd's CsOptions. I was expecting
>>> setOption to override in the same way that:
>>> 
>>> csound -odac test.csd
>>> 
>>> would have the command-line option override the CsOptions.
>>> 
>>> Wondering if this is a bug in the API?
>>> 
>>> Steven