Csound Csound-dev Csound-tekno Search About

[Cs-dev] Getting information about inputs in opcodes

Date2014-09-01 01:54
FromEdward Costello
Subject[Cs-dev] Getting information about inputs in opcodes
Hi,

I was thinking about extending an opcode for writing hdf5 files to support arbitrary types of inputs. Is it possible and if so what is the best way to query as to what kind of input was supplied to an opcode?
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-09-01 03:12
FromSteven Yi
SubjectRe: [Cs-dev] Getting information about inputs in opcodes
Hi Ed,

If you're using the latest from develop branch, you can use
csound->GetTypeForArg(p->argPtr) function.  You should look at
Opcodes/OSC.c for an example. It should have the following code:

strcmp("a", csound->GetTypeForArg(p->arg[i])->varTypeName)

(Be sure to pull the latest). Note that opcodes that are internal to
Csound directly compare the type to constants such as &CS_VAR_TYPE_A.
However, that code does not work for external opcode libraries, so
you'll have to compare against the csType->varTypeName.

Let me know if you have any questions.

Cheers!
steven


On Sun, Aug 31, 2014 at 8:54 PM, Edward Costello
 wrote:
> Hi,
>
> I was thinking about extending an opcode for writing hdf5 files to support arbitrary types of inputs. Is it possible and if so what is the best way to query as to what kind of input was supplied to an opcode?
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-09-01 13:34
FromEdward Costello
SubjectRe: [Cs-dev] Getting information about inputs in opcodes
Thanks for that, I was just doing some testing there and I was wondering how I can find out the type of array that a variable is, when I print out the varTypeName and varTypeDescription for a k rate array I get varTypeName = “[" , and varTypeDescription = “array”. I am printing varTypeName out as a string.

> On 1 Sep 2014, at 03:12, Steven Yi  wrote:
> 
> Hi Ed,
> 
> If you're using the latest from develop branch, you can use
> csound->GetTypeForArg(p->argPtr) function.  You should look at
> Opcodes/OSC.c for an example. It should have the following code:
> 
> strcmp("a", csound->GetTypeForArg(p->arg[i])->varTypeName)
> 
> (Be sure to pull the latest). Note that opcodes that are internal to
> Csound directly compare the type to constants such as &CS_VAR_TYPE_A.
> However, that code does not work for external opcode libraries, so
> you'll have to compare against the csType->varTypeName.
> 
> Let me know if you have any questions.
> 
> Cheers!
> steven
> 
> 
> On Sun, Aug 31, 2014 at 8:54 PM, Edward Costello
>  wrote:
>> Hi,
>> 
>> I was thinking about extending an opcode for writing hdf5 files to support arbitrary types of inputs. Is it possible and if so what is the best way to query as to what kind of input was supplied to an opcode?
>> ------------------------------------------------------------------------------
>> Slashdot TV.
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Slashdot TV.  
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourc

Date2014-09-01 13:51
FromSteven Yi
SubjectRe: [Cs-dev] Getting information about inputs in opcodes
Yeah, the array type stuff isn't ideal at this point.  We need to add
a type constructor I think for having unique array type descriptions.
Until then, you can use the varTypeName to first check if it's an
array.  After that, you can cast the arg to an ARRAYDAT and read the
information from there (dimensions, arrayType).  The arrayType should
be something like "k" or "a".

On Mon, Sep 1, 2014 at 8:34 AM, Edward Costello  wrote:
> Thanks for that, I was just doing some testing there and I was wondering how I can find out the type of array that a variable is, when I print out the varTypeName and varTypeDescription for a k rate array I get varTypeName = “[" , and varTypeDescription = “array”. I am printing varTypeName out as a string.
>
>> On 1 Sep 2014, at 03:12, Steven Yi  wrote:
>>
>> Hi Ed,
>>
>> If you're using the latest from develop branch, you can use
>> csound->GetTypeForArg(p->argPtr) function.  You should look at
>> Opcodes/OSC.c for an example. It should have the following code:
>>
>> strcmp("a", csound->GetTypeForArg(p->arg[i])->varTypeName)
>>
>> (Be sure to pull the latest). Note that opcodes that are internal to
>> Csound directly compare the type to constants such as &CS_VAR_TYPE_A.
>> However, that code does not work for external opcode libraries, so
>> you'll have to compare against the csType->varTypeName.
>>
>> Let me know if you have any questions.
>>
>> Cheers!
>> steven
>>
>>
>> On Sun, Aug 31, 2014 at 8:54 PM, Edward Costello
>>  wrote:
>>> Hi,
>>>
>>> I was thinking about extending an opcode for writing hdf5 files to support arbitrary types of inputs. Is it possible and if so what is the best way to query as to what kind of input was supplied to an opcode?
>>> ------------------------------------------------------------------------------
>>> Slashdot TV.
>>> Video for Nerds.  Stuff that matters.
>>> http://tv.slashdot.org/
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Slashdot TV.
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinf

Date2014-09-01 13:52
FromSteven Yi
SubjectRe: [Cs-dev] Getting information about inputs in opcodes
Sorry, I should have said that the arrayType is a CS_TYPE but you
could read the varTypeName's from those to check for "k", "a", etc.

On Mon, Sep 1, 2014 at 8:51 AM, Steven Yi  wrote:
> Yeah, the array type stuff isn't ideal at this point.  We need to add
> a type constructor I think for having unique array type descriptions.
> Until then, you can use the varTypeName to first check if it's an
> array.  After that, you can cast the arg to an ARRAYDAT and read the
> information from there (dimensions, arrayType).  The arrayType should
> be something like "k" or "a".
>
> On Mon, Sep 1, 2014 at 8:34 AM, Edward Costello  wrote:
>> Thanks for that, I was just doing some testing there and I was wondering how I can find out the type of array that a variable is, when I print out the varTypeName and varTypeDescription for a k rate array I get varTypeName = “[" , and varTypeDescription = “array”. I am printing varTypeName out as a string.
>>
>>> On 1 Sep 2014, at 03:12, Steven Yi  wrote:
>>>
>>> Hi Ed,
>>>
>>> If you're using the latest from develop branch, you can use
>>> csound->GetTypeForArg(p->argPtr) function.  You should look at
>>> Opcodes/OSC.c for an example. It should have the following code:
>>>
>>> strcmp("a", csound->GetTypeForArg(p->arg[i])->varTypeName)
>>>
>>> (Be sure to pull the latest). Note that opcodes that are internal to
>>> Csound directly compare the type to constants such as &CS_VAR_TYPE_A.
>>> However, that code does not work for external opcode libraries, so
>>> you'll have to compare against the csType->varTypeName.
>>>
>>> Let me know if you have any questions.
>>>
>>> Cheers!
>>> steven
>>>
>>>
>>> On Sun, Aug 31, 2014 at 8:54 PM, Edward Costello
>>>  wrote:
>>>> Hi,
>>>>
>>>> I was thinking about extending an opcode for writing hdf5 files to support arbitrary types of inputs. Is it possible and if so what is the best way to query as to what kind of input was supplied to an opcode?
>>>> ------------------------------------------------------------------------------
>>>> Slashdot TV.
>>>> Video for Nerds.  Stuff that matters.
>>>> http://tv.slashdot.org/
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Slashdot TV.
>>> Video for Nerds.  Stuff that matters.
>>> http://tv.slashdot.org/
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> Slashdot TV.
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-d