Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Plugin return types

Date2023-06-05 03:27
Fromandy fillebrown
Subject[Csnd-dev] Plugin return types
I'm making a custom plugin for improved Websocket communication and
I'm wondering if it's possible to use the same opcode name to return a
string or a k-array. Right now I have two opcodes in the plugin named
"WSget_s" that returns a string and "WSget_k" that returns a k-array,
but I'd really like to drop the _s and _k suffixes so I can just use
"WSget". Is this possible with arrays?

Date2023-06-05 09:30
FromRory Walsh
SubjectRe: [Csnd-dev] Plugin return types
Can't you overload the opcode functions? I do this with a lot of Cabbage opcodes:

    csnd::plugin<GetCabbageValue>((csnd::Csound*) getCsound(), "cabbageGetValue", "k", "S", csnd::thread::k);
    csnd::plugin<GetCabbageValueArray>((csnd::Csound*) getCsound(), "cabbageGetValue", "k[]", "S[]", csnd::thread::k);
    csnd::plugin<GetCabbageValue>((csnd::Csound*) getCsound(), "cabbageGetValue", "i", "S", csnd::thread::i);
    csnd::plugin<GetCabbageValueWithTrigger>((csnd::Csound*) getCsound(), "cabbageGetValue", "kk", "S", csnd::thread::k);
    csnd::plugin<GetCabbageValueArrayWithTrigger>((csnd::Csound*) getCsound(), "cabbageGetValue", "k[]k[]", "S[]", csnd::thread::k);

On Mon, 5 Jun 2023 at 03:27, andy fillebrown <andy.fillebrown@gmail.com> wrote:
I'm making a custom plugin for improved Websocket communication and
I'm wondering if it's possible to use the same opcode name to return a
string or a k-array. Right now I have two opcodes in the plugin named
"WSget_s" that returns a string and "WSget_k" that returns a k-array,
but I'd really like to drop the _s and _k suffixes so I can just use
"WSget". Is this possible with arrays?

Date2023-06-05 10:53
FromJohn ff
SubjectRe: [Csnd-dev] Plugin return types
Should work 

⁣​

On 5 Jun 2023, 09:31, at 09:31, Rory Walsh  wrote:
>Can't you overload the opcode functions? I do this with a lot of
>Cabbage
>opcodes:
>
>    csnd::plugin((csnd::Csound*) getCsound(),
>"cabbageGetValue", "k", "S", csnd::thread::k);
>    csnd::plugin((csnd::Csound*) getCsound(),
>"cabbageGetValue", "k[]", "S[]", csnd::thread::k);
>    csnd::plugin((csnd::Csound*) getCsound(),
>"cabbageGetValue", "i", "S", csnd::thread::i);
>  csnd::plugin((csnd::Csound*) getCsound(),
>"cabbageGetValue", "kk", "S", csnd::thread::k);
>    csnd::plugin((csnd::Csound*)
>getCsound(), "cabbageGetValue", "k[]k[]", "S[]", csnd::thread::k);
>
>On Mon, 5 Jun 2023 at 03:27, andy fillebrown
>
>wrote:
>
>> I'm making a custom plugin for improved Websocket communication and
>> I'm wondering if it's possible to use the same opcode name to return
>a
>> string or a k-array. Right now I have two opcodes in the plugin named
>> "WSget_s" that returns a string and "WSget_k" that returns a k-array,
>> but I'd really like to drop the _s and _k suffixes so I can just use
>> "WSget". Is this possible with arrays?
>>