Csound Csound-dev Csound-tekno Search About

[Cs-dev] typed variables

Date2013-01-08 06:37
FromAndres Cabrera
Subject[Cs-dev] typed variables
Hi,

I'm trying to wrap my head around how the API would use CS_VARIABLES
internally. I'm thinking specifically of the I/O callbacks for the
software buses/channels.

If I want the invalue opcode to accept a generic CS_VARIABLE, how
would that be done? If I want it to accept just MYFLT, how would that
be? And if I want to wrap a MYFLT into the more generic CS_VARIABLEto
pass to the callback, how can that be done?

Cheers,
Andrés

------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cs

Date2013-01-11 14:11
FromSteven Yi
SubjectRe: [Cs-dev] typed variables
Hi Andres,

Regarding CS_VAR's and the bus, that's a good question. :)  I'm not
sure what's a good solution.  Right now, CS_VAR's essentially have the
name of the var, a reference to a CS_TYPE, a memBlock size, and a
memBlockIndex.  With that information, you should be able to find the
address of a defined csound variable by name within an instrument
instance's memory block.  I think at this point, the host would have
to then know that a CS_VAR maps to a type that then maps to an
underlying struct or MYFLT.  So you could probably do something like:

CS_VAR* csvar = csGetVariable(instr, "variableName");
void* var = csGetVariableAddress(instr, csvar);
if(csvar->type == CS_TYPE_K) {
  MYFLT* myVar = (MYFLT*) var;
}

CS_VAR* csvar2 = csGetVariable(csound, "myArray");  // GLOBAL
void* var2 = csGetVariableAddress(csound, csvar2);
if(csvar2->type == CS_TYPE_ARRAY) {
  ARRAY_DAT* myVar = (ARRAY_DAT*) var2;
}

Thoughts?

steven


On Tue, Jan 8, 2013 at 6:37 AM, Andres Cabrera  wrote:
> Hi,
>
> I'm trying to wrap my head around how the API would use CS_VARIABLES
> internally. I'm thinking specifically of the I/O callbacks for the
> software buses/channels.
>
> If I want the invalue opcode to accept a generic CS_VARIABLE, how
> would that be done? If I want it to accept just MYFLT, how would that
> be? And if I want to wrap a MYFLT into the more generic CS_VARIABLEto
> pass to the callback, how can that be done?
>
> Cheers,
> Andrés
>
> ------------------------------------------------------------------------------
> Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
> and more. Get SQL Server skills now (including 2012) with LearnDevNow -
> 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only - learn more at:
> http://p.sf.net/sfu/learnmore_122512
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-02-01 04:59
FromAndres Cabrera
SubjectRe: [Cs-dev] typed variables
Hi Steven,

Thanks for your thoughts and apologies for the late reply.

On Fri, Jan 11, 2013 at 6:11 AM, Steven Yi  wrote:
> CS_VAR* csvar = csGetVariable(instr, "variableName");
> void* var = csGetVariableAddress(instr, csvar);
> if(csvar->type == CS_TYPE_K) {
>   MYFLT* myVar = (MYFLT*) var;
> }

How would this mechanism differentiate between different instances of
an instrument?
And why would you need to pass the instrument again to get the
address? Wouldn't that be redundant?

But I think this works well for buses, as they would return a CS_VAR *
which you can then "cast" to whatever you need.
I'm wondering, have you had a look at how other systems like python do
this? I think we should look for existing examples.

Cheers,
Andrés


> steven
>
>
> On Tue, Jan 8, 2013 at 6:37 AM, Andres Cabrera  wrote:
>> Hi,
>>
>> I'm trying to wrap my head around how the API would use CS_VARIABLES
>> internally. I'm thinking specifically of the I/O callbacks for the
>> software buses/channels.
>>
>> If I want the invalue opcode to accept a generic CS_VARIABLE, how
>> would that be done? If I want it to accept just MYFLT, how would that
>> be? And if I want to wrap a MYFLT into the more generic CS_VARIABLEto
>> pass to the callback, how can that be done?
>>
>> Cheers,
>> Andrés
>>
>> ------------------------------------------------------------------------------
>> Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
>> and more. Get SQL Server skills now (including 2012) with LearnDevNow -
>> 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
>> SALE $99.99 this month only - learn more at:
>> http://p.sf.net/sfu/learnmore_122512
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
> much more. Get web development skills now with LearnDevNow -
> 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122812
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listin