Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Help with using api functions in opcodes

Date2005-09-11 03:55
From"Michael Gogins"
SubjectRe: [Cs-dev] Help with using api functions in opcodes
All API functions have function pointers in the CSOUND struct, which is what 
opcodes should call.

Instead of

( csoundTableLength( csound, 1 ) != -1 )

write

(csound->TableLength(csound, 1) != -1)

and so on.

Regards,
Mike
----- Original Message ----- 
From: "Iain Duncan" 
To: 
Sent: Saturday, September 10, 2005 10:10 PM
Subject: [Cs-dev] Help with using api functions in opcodes


> Perhaps I'm going about this all wrong. I'm trying to make a custom
> table reading opcode, so I'm under the impression that where possible I
> should just use api functions within my opcode. My dummy table reading
> wrapper compiles ok, but when I try to run a test, csound says:
>
> WARNING: could not open library 'libmytab.so'
>
> and then gives me a no legal opcode message.
>
> The above works fine if I take out the csoundTableGet() call.
> Attached is the C source.
>
> Thanks
> iain
>


--------------------------------------------------------------------------------


> // my table ramping opcode.
>
> // we'll start by just trying to make a wrapper of a table opcode
>
> #include "csdl.h"
> #include "csound.h"
>
> // structure definition for my opcode
> typedef struct _mytab {
> OPDS h;
> MYFLT *out;
> MYFLT *in1, *in2;
> } mytab;
>
> // init function for my opcode, initialize internal vars here
> int mytab_init ( CSOUND *csound, mytab *op )
> {
> // opcode initialization is expected to return OK
> return OK;
> }
>
> // a krate process needs to return just one sample
> int mytab_process_k ( CSOUND *csound, mytab *op )
> {
> // make our output variable
> //MYFLT result = *(op->in) * (MYFLT)2;
>
> MYFLT result;
>
> if ( csoundTableLength( csound, 1 ) != -1 )
> {
> result = csoundTableGet( csound, 1, 1 );
> }
> else
> result = 0;
>
> //MYFLT result = *(op->in2) * (MYFLT)8;
> *(op->out) = result;
>
> return OK;
> }
>
> // stub a-rate function, does nothing yet
> int mytab_process_a ( CSOUND *csound, mytab *op )
> {
> return OK;
> }
>
> // stuff to register opcode
> static OENTRY localops[] =
> { "mytab", sizeof(mytab), 7, "k", "ki", (SUBR)mytab_init, 
> (SUBR)mytab_process_k, (SUBR)mytab_process_a };
>
> // the macro I forgot
> LINKAGE
>
> 




-------------------------------------------------------
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-11 04:55
FromIain Duncan
SubjectRe: [Cs-dev] Help with using api functions in opcodes
Thanks, I knew it had to be some simple thing I wasn't getting! = )

Iain

Michael Gogins wrote:
> All API functions have function pointers in the CSOUND struct, which is 
> what opcodes should call.
> 
> Instead of
> 
> ( csoundTableLength( csound, 1 ) != -1 )
> 
> write
> 
> (csound->TableLength(csound, 1) != -1)
> 
> and so on.
> 
> Regards,
> Mike
> ----- Original Message ----- From: "Iain Duncan" 
> To: 
> Sent: Saturday, September 10, 2005 10:10 PM
> Subject: [Cs-dev] Help with using api functions in opcodes
> 
> 
>> Perhaps I'm going about this all wrong. I'm trying to make a custom
>> table reading opcode, so I'm under the impression that where possible I
>> should just use api functions within my opcode. My dummy table reading
>> wrapper compiles ok, but when I try to run a test, csound says:
>>
>> WARNING: could not open library 'libmytab.so'
>>
>> and then gives me a no legal opcode message.
>>
>> The above works fine if I take out the csoundTableGet() call.
>> Attached is the C source.
>>
>> Thanks
>> iain
>>
> 
> 
> -------------------------------------------------------------------------------- 
> 
> 
> 
>> // my table ramping opcode.
>>
>> // we'll start by just trying to make a wrapper of a table opcode
>>
>> #include "csdl.h"
>> #include "csound.h"
>>
>> // structure definition for my opcode
>> typedef struct _mytab {
>> OPDS h;
>> MYFLT *out;
>> MYFLT *in1, *in2;
>> } mytab;
>>
>> // init function for my opcode, initialize internal vars here
>> int mytab_init ( CSOUND *csound, mytab *op )
>> {
>> // opcode initialization is expected to return OK
>> return OK;
>> }
>>
>> // a krate process needs to return just one sample
>> int mytab_process_k ( CSOUND *csound, mytab *op )
>> {
>> // make our output variable
>> //MYFLT result = *(op->in) * (MYFLT)2;
>>
>> MYFLT result;
>>
>> if ( csoundTableLength( csound, 1 ) != -1 )
>> {
>> result = csoundTableGet( csound, 1, 1 );
>> }
>> else
>> result = 0;
>>
>> //MYFLT result = *(op->in2) * (MYFLT)8;
>> *(op->out) = result;
>>
>> return OK;
>> }
>>
>> // stub a-rate function, does nothing yet
>> int mytab_process_a ( CSOUND *csound, mytab *op )
>> {
>> return OK;
>> }
>>
>> // stuff to register opcode
>> static OENTRY localops[] =
>> { "mytab", sizeof(mytab), 7, "k", "ki", (SUBR)mytab_init, 
>> (SUBR)mytab_process_k, (SUBR)mytab_process_a };
>>
>> // the macro I forgot
>> LINKAGE
>>
>>
> 
> 
> 
> 
> -------------------------------------------------------
> 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