Csound Csound-dev Csound-tekno Search About

[Csnd] Opcodes with no outargs in c++ plugin framework

Date2019-09-17 20:53
FromRichard Knight
Subject[Csnd] Opcodes with no outargs in c++ plugin framework

The code below returns the following when it would be expected to show 1: 1.000 , 2: 2.00 etc. With outargs set it works ok, and also the inverse (outargs but no inargs) works OK. Is there a problem with my code or is it possibly a bug?

 

struct testopcode : csnd::Plugin<0, 4> {
    static constexpr char const *otypes = "";
    static constexpr char const *itypes = "iiii";
    
    int init() {
        for (int i = 0; i < 4 ; i++) {
            std::string info = std::to_string(i+1) + ": " + std::to_string(inargs[i]);
            csound->message(info);
        }
        return OK;
    }
};

 

 

...
testopcode 1, 2, 3, 4
...

1: 2.000000
2: 3.000000
3: 4.000000

csound command: Segmentation fault


Date2019-09-17 21:39
FromVictor Lazzarini
SubjectRe: [Csnd] Opcodes with no outargs in c++ plugin framework
yep, using 0 for outargs is problematic. A solution, which might sound confusing, but should work is to set outargs to 1 and use outargs[0] as your first input. You'll
also reduce the number of inargs by 1 as well. 

Or, set zero input args and use the outargs array as your inputs.

I might make a separate class template for zero outputs to make it less confusing, but
for now, one of the above should work.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 17 Sep 2019, at 20:53, Richard Knight <richard@1bpm.net> wrote:

The code below returns the following when it would be expected to show 1: 1.000 , 2: 2.00 etc. With outargs set it works ok, and also the inverse (outargs but no inargs) works OK. Is there a problem with my code or is it possibly a bug?

 

struct testopcode : csnd::Plugin<0, 4> {
    static constexpr char const *otypes = "";
    static constexpr char const *itypes = "iiii";
    
    int init() {
        for (int i = 0; i < 4 ; i++) {
            std::string info = std::to_string(i+1) + ": " + std::to_string(inargs[i]);
            csound->message(info);
        }
        return OK;
    }
};

 

 

...
testopcode 1, 2, 3, 4
...

1: 2.000000
2: 3.000000
3: 4.000000

csound command: Segmentation fault

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

Date2019-09-17 23:13
FromRichard Knight
SubjectRe: [Csnd] Opcodes with no outargs in c++ plugin framework

Ah ok, thanks! I will go with your second suggestion and basically switch round in/out.

On Tue, 17 Sep 2019 20:39:27 +0000, Victor Lazzarini wrote:

yep, using 0 for outargs is problematic. A solution, which might sound confusing, but should work is to set outargs to 1 and use outargs[0] as your first input. You'll
also reduce the number of inargs by 1 as well. 
Or, set zero input args and use the outargs array as your inputs.
I might make a separate class template for zero outputs to make it less confusing, but
for now, one of the above should work.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 17 Sep 2019, at 20:53, Richard Knight <richard@1bpm.net> wrote:

The code below returns the following when it would be expected to show 1: 1.000 , 2: 2.00 etc. With outargs set it works ok, and also the inverse (outargs but no inargs) works OK. Is there a problem with my code or is it possibly a bug?

 

struct testopcode : csnd::Plugin<0, 4> {
    static constexpr char const *otypes = "";
    static constexpr char const *itypes = "iiii";
    
    int init() {
        for (int i = 0; i < 4 ; i++) {
            std::string info = std::to_string(i+1) + ": " + std::to_string(inargs[i]);
            csound->message(info);
        }
        return OK;
    }
};

 

 

...
testopcode 1, 2, 3, 4
...

1: 2.000000
2: 3.000000
3: 4.000000

csound command: Segmentation fault

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

-- 


http://rk.1bpm.net/

Date2019-09-18 15:56
FromVictor Lazzarini
SubjectRe: [Csnd] Opcodes with no outargs in c++ plugin framework
I’ve added the class InPlug for the case where there are no outputs. It’s in GIT, not sure if you can try it.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 17 Sep 2019, at 23:13, Richard Knight  wrote:
> 
> Ah ok, thanks! I will go with your second suggestion and basically switch round in/out.
> 
> On Tue, 17 Sep 2019 20:39:27 +0000, Victor Lazzarini wrote:
> 
>> yep, using 0 for outargs is problematic. A solution, which might sound confusing, but should work is to set outargs to 1 and use outargs[0] as your first input. You'll
>> also reduce the number of inargs by 1 as well. 
>> Or, set zero input args and use the outargs array as your inputs.
>> I might make a separate class template for zero outputs to make it less confusing, but
>> for now, one of the above should work.
>> 
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>> 
>> On 17 Sep 2019, at 20:53, Richard Knight  wrote:
>> 
>>> The code below returns the following when it would be expected to show 1: 1.000 , 2: 2.00 etc. With outargs set it works ok, and also the inverse (outargs but no inargs) works OK. Is there a problem with my code or is it possibly a bug?
>>> 
>>>  
>>> struct testopcode : csnd::Plugin<0, 4> {
>>>     static constexpr char const *otypes = "";
>>>     static constexpr char const *itypes = "iiii";
>>>     
>>>     int init() {
>>>         for (int i = 0; i < 4 ; i++) {
>>>             std::string info = std::to_string(i+1) + ": " + std::to_string(inargs[i]);
>>>             csound->message(info);
>>>         }
>>>         return OK;
>>>     }
>>> };
>>> 
>>>  
>>>  
>>> ...
>>> testopcode 1, 2, 3, 4
>>> ...
>>> 
>>> 
>>> 1: 2.000000
>>> 2: 3.000000
>>> 3: 4.000000
>>> 
>>> csound command: Segmentation fault
>>> 
>>> 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
>> 
> -- 
> 
> 
> http://rk.1bpm.net/
> 
> 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

Date2019-09-20 00:25
FromRichard Knight
SubjectRe: [Csnd] Opcodes with no outargs in c++ plugin framework

Great, thank you. I have tried it, and it works :)

On Wed, 18 Sep 2019 14:56:35 +0000, Victor Lazzarini wrote:

I’ve added the class InPlug for the case where there are no outputs. It’s in GIT, not sure if you can try it.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

On 17 Sep 2019, at 23:13, Richard Knight <richard@1BPM.NET> wrote: Ah ok, thanks! I will go with your second suggestion and basically switch round in/out. On Tue, 17 Sep 2019 20:39:27 +0000, Victor Lazzarini wrote:
yep, using 0 for outargs is problematic. A solution, which might sound confusing, but should work is to set outargs to 1 and use outargs[0] as your first input. You'll also reduce the number of inargs by 1 as well. Or, set zero input args and use the outargs array as your inputs. I might make a separate class template for zero outputs to make it less confusing, but for now, one of the above should work. Prof. Victor Lazzarini Maynooth University Ireland On 17 Sep 2019, at 20:53, Richard Knight <richard@1bpm.net> wrote:
The code below returns the following when it would be expected to show 1: 1.000 , 2: 2.00 etc. With outargs set it works ok, and also the inverse (outargs but no inargs) works OK. Is there a problem with my code or is it possibly a bug? struct testopcode : csnd::Plugin<0, 4> { static constexpr char const *otypes = ""; static constexpr char const *itypes = "iiii"; int init() { for (int i = 0; i < 4 ; i++) { std::string info = std::to_string(i+1) + ": " + std::to_string(inargs[i]); csound->message(info); } return OK; } }; ... testopcode 1, 2, 3, 4 ... 1: 2.000000 2: 3.000000 3: 4.000000 csound command: Segmentation fault 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
-- http://rk.1bpm.net/ 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
-- 


http://rk.1bpm.net/

Date2019-09-27 13:22
FromVictor Lazzarini
SubjectRe: [Csnd] Opcodes with no outargs in c++ plugin framework
Good. I made a small change of var name 
inargs to just args, since this can also be used
with unlimited outputs, which does not work
with the original template.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 27 Sep 2019, at 13:01, Richard Knight <richard@1bpm.net> wrote:

Great, thank you. I have tried it, and it works :)

On Wed, 18 Sep 2019 14:56:35 +0000, Victor Lazzarini wrote:

I’ve added the class InPlug for the case where there are no outputs. It’s in GIT, not sure if you can try it.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

On 17 Sep 2019, at 23:13, Richard Knight <richard@1BPM.NET> wrote: Ah ok, thanks! I will go with your second suggestion and basically switch round in/out. On Tue, 17 Sep 2019 20:39:27 +0000, Victor Lazzarini wrote:
yep, using 0 for outargs is problematic. A solution, which might sound confusing, but should work is to set outargs to 1 and use outargs[0] as your first input. You'll also reduce the number of inargs by 1 as well. Or, set zero input args and use the outargs array as your inputs. I might make a separate class template for zero outputs to make it less confusing, but for now, one of the above should work. Prof. Victor Lazzarini Maynooth University Ireland On 17 Sep 2019, at 20:53, Richard Knight <richard@1bpm.net> wrote:
The code below returns the following when it would be expected to show 1: 1.000 , 2: 2.00 etc. With outargs set it works ok, and also the inverse (outargs but no inargs) works OK. Is there a problem with my code or is it possibly a bug? struct testopcode : csnd::Plugin<0, 4> { static constexpr char const *otypes = ""; static constexpr char const *itypes = "iiii"; int init() { for (int i = 0; i < 4 ; i++) { std::string info = std::to_string(i+1) + ": " + std::to_string(inargs[i]); csound->message(info); } return OK; } }; ... testopcode 1, 2, 3, 4 ... 1: 2.000000 2: 3.000000 3: 4.000000 csound command: Segmentation fault 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
-- http://rk.1bpm.net/ 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