Csound Csound-dev Csound-tekno Search About

[Cs-dev] adding plugin opcodes

Date2005-09-02 22:45
FromIain Duncan
Subject[Cs-dev] adding plugin opcodes
Attachmentsmyop.c  
I have been following Victor's excellently written tutorial on making 
opcodes. This does need to be updated on csounds.com as it uses ENVIRON 
instead of CSOUND in the example, dunno about other changes.

I seem to have compiled my opcode and made a shared library ok ( myop.so 
), but I get a no legal opcode error when I try to use it. Do I perhaps 
need to register it differently now? Or do something to make csound find 
it? I tried putting it in the root csound5 directory, the Plugins 
directory, and the Opcodes directory.

In the bottom of my C source file I have the registration copied from 
the tutorial:

// stuff to register opcode
static OENTRY localops[] =
{ "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init, 
(SUBR)myop_process_k, NULL };

Is this perhaps different now, or is this supposed to be somewhere else?
Attached is the C file.

Thanks
Iain

Date2005-09-02 23:00
FromSteven Yi
SubjectRe: [Cs-dev] adding plugin opcodes
AttachmentsNone  

Date2005-09-02 23:04
FromIain Duncan
SubjectRe: [Cs-dev] adding plugin opcodes
Can you point me to an example of this? or show me what it should look 
like?

I suggest that info be added to Victor's paper too. = )

Iain

Steven Yi wrote:
> Hi Iain, 
> 
> It doesn't look like you have the code to actually register with
> Csound your opcodes in the library.  The simple way to do that is to
> add the LINKAGE macro after the OENTRY localops[] line. (LINKAGE is
> defined in csdl.h)
> 
> steven
> 
> 
> On 9/2/05, Iain Duncan  wrote:
> 
>>I have been following Victor's excellently written tutorial on making
>>opcodes. This does need to be updated on csounds.com as it uses ENVIRON
>>instead of CSOUND in the example, dunno about other changes.
>>
>>I seem to have compiled my opcode and made a shared library ok ( myop.so
>>), but I get a no legal opcode error when I try to use it. Do I perhaps
>>need to register it differently now? Or do something to make csound find
>>it? I tried putting it in the root csound5 directory, the Plugins
>>directory, and the Opcodes directory.
>>
>>In the bottom of my C source file I have the registration copied from
>>the tutorial:
>>
>>// stuff to register opcode
>>static OENTRY localops[] =
>>{ "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init,
>>(SUBR)myop_process_k, NULL };
>>
>>Is this perhaps different now, or is this supposed to be somewhere else?
>>Attached is the C file.
>>
>>Thanks
>>Iain
>>
>>
>>// attempt at my first opcode
>>// doubles an input signal ( just to make it do something )
>>
>>#include "csdl.h"
>>
>>// structure definition for my opcode
>>typedef struct _myop {
>>        OPDS    h;
>>        MYFLT   *in;
>>        MYFLT   *out;
>>        MYFLT   var;
>>
>>} myop;
>>
>>// init function for my opcode, initialize internal vars here
>>int myop_init ( CSOUND *csound, myop *op )
>>{
>>        // initialize my internal variables here
>>        op->var = 2;
>>
>>        // opcode initialization is expected to return OK
>>        return OK;
>>}
>>
>>// a krate process needs to return just one sample
>>int myop_process_k ( CSOUND *csound, myop *op )
>>{
>>        // make our output variable
>>        MYFLT result = *(op->in) * op->var;
>>        *(op->out) = result;
>>
>>        return OK;
>>}
>>
>>
>>// stuff to register opcode
>>static OENTRY localops[] =
>>{ "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init, (SUBR)myop_process_k, NULL };
>>
>>
>>
>>
>>
>>
>>
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-09-02 23:12
FromIstvan Varga
SubjectRe: [Cs-dev] adding plugin opcodes
Just add LINKAGE at the end of the file:

// stuff to register opcode
static OENTRY localops[] =
{ "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init, (SUBR)myop_process_k, NULL };

LINKAGE

Of course, there are more advanced things that can be done, but that
should be enough to get started.

Iain Duncan wrote:

> Can you point me to an example of this? or show me what it should look 
> like?
> 
> I suggest that info be added to Victor's paper too. = )
> 
> Iain
> 
> Steven Yi wrote:
> 
>> Hi Iain,
>> It doesn't look like you have the code to actually register with
>> Csound your opcodes in the library.  The simple way to do that is to
>> add the LINKAGE macro after the OENTRY localops[] line. (LINKAGE is
>> defined in csdl.h)



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-09-02 23:18
FromIain Duncan
SubjectRe: [Cs-dev] adding plugin opcodes
Thanks guys, it worked! The tech support around here is second to none. ; )

So, I guess adding the entry to SConstruct replaces the need to compile 
the .so seperately as indicated in Victor's Paper? I guess the linkage 
macro should get mentioned in there too.

Iain

Istvan Varga wrote:
> Just add LINKAGE at the end of the file:
> 
> // stuff to register opcode
> static OENTRY localops[] =
> { "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init, 
> (SUBR)myop_process_k, NULL };
> 
> LINKAGE
> 
> Of course, there are more advanced things that can be done, but that
> should be enough to get started.
> 
> Iain Duncan wrote:
> 
>> Can you point me to an example of this? or show me what it should look 
>> like?
>>
>> I suggest that info be added to Victor's paper too. = )
>>
>> Iain
>>
>> Steven Yi wrote:
>>
>>> Hi Iain,
>>> It doesn't look like you have the code to actually register with
>>> Csound your opcodes in the library.  The simple way to do that is to
>>> add the LINKAGE macro after the OENTRY localops[] line. (LINKAGE is
>>> defined in csdl.h)
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-09-02 23:30
FromSteven Yi
SubjectRe: [Cs-dev] adding plugin opcodes
AttachmentsNone  

Date2005-09-04 08:06
FromIain Duncan
SubjectRe: [Cs-dev] adding plugin opcodes
> Thanks guys, it worked! The tech support around here is second to none. ; )
> 
> So, I guess adding the entry to SConstruct replaces the need to compile 
> the .so seperately as indicated in Victor's Paper? I guess the linkage 
> macro should get mentioned in there too.

I noticed the linkage macro is already mentioned in there. However it 
isn't included as a code example, so I got confused thinking there had 
to be more to it than just typing LINKAGE. Suppose it might be worth 
adding it that way too.

By the way Victor, for some reason when I unzip the example files from 
your DevelopingOpcodes.zip the use a character in place of carriage 
return in gvim. Dunno how to fix it either, which is why I hadn't looked 
thoroughly at the examples and only at the pdf.

Thanks
Iain


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-09-04 09:37
FromAndres Cabrera
SubjectRe: [Cs-dev] adding plugin opcodes
Hi,
Most plugins are already set to be linked using the LINKAGE macro. Take
a look for instance at:
Opcodes/babo.c
#define S       sizeof

static OENTRY localops[] = {
{ "babo",   S(BABO), 5, "aa", "akkkiiijj",(SUBR)baboset, NULL,
(SUBR)babo   }
};

LINKAGE

Cheers,
Andres

On Fri, 2005-09-02 at 17:04, Iain Duncan wrote:
> Can you point me to an example of this? or show me what it should look 
> like?
> 
> I suggest that info be added to Victor's paper too. = )
> 
> Iain
> 
> Steven Yi wrote:
> > Hi Iain, 
> > 
> > It doesn't look like you have the code to actually register with
> > Csound your opcodes in the library.  The simple way to do that is to
> > add the LINKAGE macro after the OENTRY localops[] line. (LINKAGE is
> > defined in csdl.h)
> > 
> > steven
> > 
> > 
> > On 9/2/05, Iain Duncan  wrote:
> > 
> >>I have been following Victor's excellently written tutorial on making
> >>opcodes. This does need to be updated on csounds.com as it uses ENVIRON
> >>instead of CSOUND in the example, dunno about other changes.
> >>
> >>I seem to have compiled my opcode and made a shared library ok ( myop.so
> >>), but I get a no legal opcode error when I try to use it. Do I perhaps
> >>need to register it differently now? Or do something to make csound find
> >>it? I tried putting it in the root csound5 directory, the Plugins
> >>directory, and the Opcodes directory.
> >>
> >>In the bottom of my C source file I have the registration copied from
> >>the tutorial:
> >>
> >>// stuff to register opcode
> >>static OENTRY localops[] =
> >>{ "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init,
> >>(SUBR)myop_process_k, NULL };
> >>
> >>Is this perhaps different now, or is this supposed to be somewhere else?
> >>Attached is the C file.
> >>
> >>Thanks
> >>Iain
> >>
> >>
> >>// attempt at my first opcode
> >>// doubles an input signal ( just to make it do something )
> >>
> >>#include "csdl.h"
> >>
> >>// structure definition for my opcode
> >>typedef struct _myop {
> >>        OPDS    h;
> >>        MYFLT   *in;
> >>        MYFLT   *out;
> >>        MYFLT   var;
> >>
> >>} myop;
> >>
> >>// init function for my opcode, initialize internal vars here
> >>int myop_init ( CSOUND *csound, myop *op )
> >>{
> >>        // initialize my internal variables here
> >>        op->var = 2;
> >>
> >>        // opcode initialization is expected to return OK
> >>        return OK;
> >>}
> >>
> >>// a krate process needs to return just one sample
> >>int myop_process_k ( CSOUND *csound, myop *op )
> >>{
> >>        // make our output variable
> >>        MYFLT result = *(op->in) * op->var;
> >>        *(op->out) = result;
> >>
> >>        return OK;
> >>}
> >>
> >>
> >>// stuff to register opcode
> >>static OENTRY localops[] =
> >>{ "myop", sizeof(myop), 3, "k", "k", (SUBR)myop_init, (SUBR)myop_process_k, NULL };
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> > 
> > 
> > 
> > -------------------------------------------------------
> > SF.Net email is Sponsored by the Better Software Conference & EXPO
> > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net