Csound Csound-dev Csound-tekno Search About

[Csnd-dev] CPOF - omit outargs?

Date2024-07-06 08:45
FromPierre Clisson
Subject[Csnd-dev] CPOF - omit outargs?
Attachmentssmime.p7s  
Hi,

I have an opcode that expects an array as input:

csnd::plugin(csound, "myopcode", "k[]", "k[]", csnd::thread::k);

For performance reasons, I modify this array in place instead of 
instantiating a new object:

csnd::Vector &in = inargs.vector_data(0)
csnd::Vector &out = in;
// ...

So, it doesn't make sense to return anything from this opcode. But if I 
declare the opcode like this, the code builds but segfaults during 
execution:

struct MyOpcode : csnd::Plugin<0, 1> {
// ...
};
csnd::plugin(csound, "myopcode", "", "k[]", csnd::thread::k);

How can I omit outargs?

Thanks,

Pierre



Date2024-07-06 09:17
Fromvlz
SubjectRe: [Csnd-dev] CPOF - omit outargs?
You should use the InPlug base class instead of PlugIn. It has only one template argument.


Prof. Victor Lazzarini
Maynooth University
Ireland

> On 6 Jul 2024, at 08:45, Pierre Clisson  wrote:
> 
> Hi,
> 
> I have an opcode that expects an array as input:
> 
> csnd::plugin(csound, "myopcode", "k[]", "k[]", csnd::thread::k);
> 
> For performance reasons, I modify this array in place instead of instantiating a new object:
> 
> csnd::Vector &in = inargs.vector_data(0)
> csnd::Vector &out = in;
> // ...
> 
> So, it doesn't make sense to return anything from this opcode. But if I declare the opcode like this, the code builds but segfaults during execution:
> 
> struct MyOpcode : csnd::Plugin<0, 1> {
> // ...
> };
> csnd::plugin(csound, "myopcode", "", "k[]", csnd::thread::k);
> 
> How can I omit outargs?
> 
> Thanks,
> 
> Pierre
> 
> 

Date2024-07-07 10:57
FromPierre Clisson
SubjectRe: [Csnd-dev] CPOF - omit outargs?
Attachmentssmime.p7s  
Thanks, it works :)

vlz wrote on 06/07/2024 10:17:
> You should use the InPlug base class instead of PlugIn. It has only one template argument.
>
>
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 6 Jul 2024, at 08:45, Pierre Clisson  wrote:
>>
>> Hi,
>>
>> I have an opcode that expects an array as input:
>>
>> csnd::plugin(csound, "myopcode", "k[]", "k[]", csnd::thread::k);
>>
>> For performance reasons, I modify this array in place instead of instantiating a new object:
>>
>> csnd::Vector &in = inargs.vector_data(0)
>> csnd::Vector &out = in;
>> // ...
>>
>> So, it doesn't make sense to return anything from this opcode. But if I declare the opcode like this, the code builds but segfaults during execution:
>>
>> struct MyOpcode : csnd::Plugin<0, 1> {
>> // ...
>> };
>> csnd::plugin(csound, "myopcode", "", "k[]", csnd::thread::k);
>>
>> How can I omit outargs?
>>
>> Thanks,
>>
>> Pierre
>>
>>