Csound Csound-dev Csound-tekno Search About

[Csnd] Building opcode arguments dynamically

Date2020-08-02 00:50
FromAlex Weiss
Subject[Csnd] Building opcode arguments dynamically
For opcodes with a variable number of arguments, is it possible to build the argument list dynamically at runtime? Say I have an array or a table containing all arguments (in order) for an opcode like 'expsega' -- is there a way to use the array/table as a list of arguments?
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

Date2020-08-02 10:38
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
yes, that's what ftgen with array input does, and the new version of schedule (and possibly others I forget)

Prof. Victor Lazzarini
Maynooth University
Ireland

On 2 Aug 2020, at 00:51, Alex Weiss <alexweiss86@gmail.com> 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.

For opcodes with a variable number of arguments, is it possible to build the argument list dynamically at runtime? Say I have an array or a table containing all arguments (in order) for an opcode like 'expsega' -- is there a way to use the array/table as a list of arguments?
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

Date2020-08-02 19:05
FromAlex Weiss
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
Thanks Victor. So does that mean the opcode itself needs to support this feature (or possibly be rewritten/extended to support it) rather than there being a generic opcode-agnostic way of doing this?

On Sun, Aug 2, 2020 at 2:38 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
yes, that's what ftgen with array input does, and the new version of schedule (and possibly others I forget)

Prof. Victor Lazzarini
Maynooth University
Ireland

On 2 Aug 2020, at 00:51, Alex Weiss <alexweiss86@gmail.com> 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.

For opcodes with a variable number of arguments, is it possible to build the argument list dynamically at runtime? Say I have an array or a table containing all arguments (in order) for an opcode like 'expsega' -- is there a way to use the array/table as a list of arguments?
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

Date2020-08-02 19:42
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
Yes, the opcode has to have an overload that takes an array type as argument.
Of course you may create a UDO that unpacks an array and passes its contents
as arguments to an opcode.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 2 Aug 2020, at 19:05, Alex Weiss  wrote:
> 
> Thanks Victor. So does that mean the opcode itself needs to support this feature (or possibly be rewritten/extended to support it) rather than there being a generic opcode-agnostic way of doing this?
> 
> On Sun, Aug 2, 2020 at 2:38 AM Victor Lazzarini  wrote:
> yes, that's what ftgen with array input does, and the new version of schedule (and possibly others I forget)
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 2 Aug 2020, at 00:51, Alex Weiss  wrote:
>> 
>> 
>> WARNINGThis 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.
>> For opcodes with a variable number of arguments, is it possible to build the argument list dynamically at runtime? Say I have an array or a table containing all arguments (in order) for an opcode like 'expsega' -- is there a way to use the array/table as a list of arguments?
>> 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

Date2020-08-02 20:00
FromAlex Weiss
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
I see. Might be a good way for me then to finally get my feet wet with csound development and add these overloads to some opcodes!

On Sun, Aug 2, 2020, 11:42 Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Yes, the opcode has to have an overload that takes an array type as argument.
Of course you may create a UDO that unpacks an array and passes its contents
as arguments to an opcode.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 2 Aug 2020, at 19:05, Alex Weiss <alexweiss86@GMAIL.COM> wrote:
>
> Thanks Victor. So does that mean the opcode itself needs to support this feature (or possibly be rewritten/extended to support it) rather than there being a generic opcode-agnostic way of doing this?
>
> On Sun, Aug 2, 2020 at 2:38 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
> yes, that's what ftgen with array input does, and the new version of schedule (and possibly others I forget)
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 2 Aug 2020, at 00:51, Alex Weiss <alexweiss86@gmail.com> wrote:
>>
>> 
>> WARNINGThis 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.
>> For opcodes with a variable number of arguments, is it possible to build the argument list dynamically at runtime? Say I have an array or a table containing all arguments (in order) for an opcode like 'expsega' -- is there a way to use the array/table as a list of arguments?
>> 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

Date2020-08-02 20:34
FromSteven Yi
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
This sounds to me like an apply operation that you would find in functional programming?  Something like:

asig = apply(oscil, [0.5, 440])

I think this is something that would be nice in CS7 as it would be a system-wide way to handle the situation rather than having to do it opcode-by-opcode.  

On Sun, Aug 2, 2020 at 3:00 PM Alex Weiss <alexweiss86@gmail.com> wrote:
I see. Might be a good way for me then to finally get my feet wet with csound development and add these overloads to some opcodes!

On Sun, Aug 2, 2020, 11:42 Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Yes, the opcode has to have an overload that takes an array type as argument.
Of course you may create a UDO that unpacks an array and passes its contents
as arguments to an opcode.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 2 Aug 2020, at 19:05, Alex Weiss <alexweiss86@GMAIL.COM> wrote:
>
> Thanks Victor. So does that mean the opcode itself needs to support this feature (or possibly be rewritten/extended to support it) rather than there being a generic opcode-agnostic way of doing this?
>
> On Sun, Aug 2, 2020 at 2:38 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
> yes, that's what ftgen with array input does, and the new version of schedule (and possibly others I forget)
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 2 Aug 2020, at 00:51, Alex Weiss <alexweiss86@gmail.com> wrote:
>>
>> 
>> WARNINGThis 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.
>> For opcodes with a variable number of arguments, is it possible to build the argument list dynamically at runtime? Say I have an array or a table containing all arguments (in order) for an opcode like 'expsega' -- is there a way to use the array/table as a list of arguments?
>> 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
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

Date2020-08-02 20:52
Fromjohn
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
Just to note that arrays must have only one type so the suggested apply 
mchansm Would not work for example with diskin

karr[] fillarray  "beats.wav", ktrans, 0, 1, 0, 32
a1 = apply(diskin, karr)

is not valid

==john ff

On Sun, 2 Aug 2020, Steven Yi wrote:

> This sounds to me like an apply operation that you would find in functional
> programming?  Something like:
> 
> asig = apply(oscil, [0.5, 440])
> 
> I think this is something that would be nice in CS7 as it would be a
> system-wide way to handle the situation rather than having to do it
> opcode-by-opcode.  
>

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

Date2020-08-02 21:00
FromSteven Yi
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
Good point; we could make it work if we had a list data type that allowed for heterogenous data. Would need to have type checking and casts inserted where necessary if the list was used elsewhere in code, but could be managed. So something like:

args:List = list("beats.wav", ktrans, 0, 1, 0, 32)
a1 = apply(diskin, karr)
asig = args[0] ;; <- Runtime error: type check would say something like "String" found but expected value of type "a".

On Sun, Aug 2, 2020 at 3:52 PM john <jpff@codemist.co.uk> wrote:
Just to note that arrays must have only one type so the suggested apply
mchansm Would not work for example with diskin

karr[] fillarray  "beats.wav", ktrans, 0, 1, 0, 32
a1 = apply(diskin, karr)

is not valid

==john ff

On Sun, 2 Aug 2020, Steven Yi wrote:

> This sounds to me like an apply operation that you would find in functional
> programming?  Something like:
>
> asig = apply(oscil, [0.5, 440])
>
> I think this is something that would be nice in CS7 as it would be a
> system-wide way to handle the situation rather than having to do it
> opcode-by-opcode.  
>

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

Date2020-08-02 21:09
FromAlex Weiss
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Building opcode arguments dynamically
Yes, something like this is pretty much exactly what I was hoping for. Very exciting.

On a related note, is there a cs7 roadmap somewhere? I'm curious about the plans and proposed new features.


On Sun, Aug 2, 2020, 13:00 Steven Yi <stevenyi@gmail.com> wrote:
Good point; we could make it work if we had a list data type that allowed for heterogenous data. Would need to have type checking and casts inserted where necessary if the list was used elsewhere in code, but could be managed. So something like:

args:List = list("beats.wav", ktrans, 0, 1, 0, 32)
a1 = apply(diskin, karr)
asig = args[0] ;; <- Runtime error: type check would say something like "String" found but expected value of type "a".

On Sun, Aug 2, 2020 at 3:52 PM john <jpff@codemist.co.uk> wrote:
Just to note that arrays must have only one type so the suggested apply
mchansm Would not work for example with diskin

karr[] fillarray  "beats.wav", ktrans, 0, 1, 0, 32
a1 = apply(diskin, karr)

is not valid

==john ff

On Sun, 2 Aug 2020, Steven Yi wrote:

> This sounds to me like an apply operation that you would find in functional
> programming?  Something like:
>
> asig = apply(oscil, [0.5, 440])
>
> I think this is something that would be nice in CS7 as it would be a
> system-wide way to handle the situation rather than having to do it
> opcode-by-opcode.  
>

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