Csound Csound-dev Csound-tekno Search About

[Csnd] opcode request: better OSC support

Date2012-07-07 23:12
Fromjoachim heintz
Subject[Csnd] opcode request: better OSC support
(sorry, again:)

hi -

i am working on some csound examples for the INScore project of
dominique fober (GRAME, Lyon, France). if anyone wants to have an
impression:
http://inscore.sourceforge.net/

i am very restricted in my work because the csound opcodes for Open
Sound Control are rather restricted. i can't see how i can send
type-flexible messages like
/ITL defaultShow 0
/ITL/scene/* del
/ITL/scene color 255 255 255 255
/ITL/scene width 1.33
/ITL/scene/title set file rsrc/title.html
/ITL/scene/title x -0.12
/ITL/scene/title y -0.66
/ITL/scene/title scale 3.3
/ITL/scene/title show 1
in another way than translating them by hand. it is even not possible to
use the score or an external file for this. and because the python
opcodes do not accept strings as input and output, i can't see no way at
all.

the similar problem is in receiving OSC messages, because csound wants
to know the exact formal of the message. if you don't know the exact
format, you receive nothing.

can there be opcodes like the PD objects sendOSC and dumpOSC? perhaps
like this:

OSCsend2 kWhen, SHost, iPort, Sdest, SMsg
like: OSCsend2 1, "localhost", 7000, "/ITL", "defaultShow 0"

OSClisten2 could in a similar way just receive a data string:
kans OSClisten2 giPort, SAddress, Sdata

thanks -

	joachim

Date2012-07-07 23:24
FromVictor Lazzarini
SubjectRe: [Csnd] opcode request: better OSC support
In other words, you would like to send and receive typeless strings. Is that it?

Victor
On 7 Jul 2012, at 23:12, joachim heintz wrote:

> (sorry, again:)
> 
> hi -
> 
> i am working on some csound examples for the INScore project of
> dominique fober (GRAME, Lyon, France). if anyone wants to have an
> impression:
> http://inscore.sourceforge.net/
> 
> i am very restricted in my work because the csound opcodes for Open
> Sound Control are rather restricted. i can't see how i can send
> type-flexible messages like
> /ITL defaultShow 0
> /ITL/scene/* del
> /ITL/scene color 255 255 255 255
> /ITL/scene width 1.33
> /ITL/scene/title set file rsrc/title.html
> /ITL/scene/title x -0.12
> /ITL/scene/title y -0.66
> /ITL/scene/title scale 3.3
> /ITL/scene/title show 1
> in another way than translating them by hand. it is even not possible to
> use the score or an external file for this. and because the python
> opcodes do not accept strings as input and output, i can't see no way at
> all.
> 
> the similar problem is in receiving OSC messages, because csound wants
> to know the exact formal of the message. if you don't know the exact
> format, you receive nothing.
> 
> can there be opcodes like the PD objects sendOSC and dumpOSC? perhaps
> like this:
> 
> OSCsend2 kWhen, SHost, iPort, Sdest, SMsg
> like: OSCsend2 1, "localhost", 7000, "/ITL", "defaultShow 0"
> 
> OSClisten2 could in a similar way just receive a data string:
> kans OSClisten2 giPort, SAddress, Sdata
> 
> thanks -
> 
> 	joachim
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-07-07 23:26
FromVictor Lazzarini
SubjectRe: [Csnd] opcode request: better OSC support
The only question is this:

when sending the data, what type should we ascribe to it? OSC asks for types. Just a single "s" ?
I see that on receiving, we would match everything, so ignoring the types, that should be possible.

Victor

On 7 Jul 2012, at 23:12, joachim heintz wrote:

> (sorry, again:)
> 
> hi -
> 
> i am working on some csound examples for the INScore project of
> dominique fober (GRAME, Lyon, France). if anyone wants to have an
> impression:
> http://inscore.sourceforge.net/
> 
> i am very restricted in my work because the csound opcodes for Open
> Sound Control are rather restricted. i can't see how i can send
> type-flexible messages like
> /ITL defaultShow 0
> /ITL/scene/* del
> /ITL/scene color 255 255 255 255
> /ITL/scene width 1.33
> /ITL/scene/title set file rsrc/title.html
> /ITL/scene/title x -0.12
> /ITL/scene/title y -0.66
> /ITL/scene/title scale 3.3
> /ITL/scene/title show 1
> in another way than translating them by hand. it is even not possible to
> use the score or an external file for this. and because the python
> opcodes do not accept strings as input and output, i can't see no way at
> all.
> 
> the similar problem is in receiving OSC messages, because csound wants
> to know the exact formal of the message. if you don't know the exact
> format, you receive nothing.
> 
> can there be opcodes like the PD objects sendOSC and dumpOSC? perhaps
> like this:
> 
> OSCsend2 kWhen, SHost, iPort, Sdest, SMsg
> like: OSCsend2 1, "localhost", 7000, "/ITL", "defaultShow 0"
> 
> OSClisten2 could in a similar way just receive a data string:
> kans OSClisten2 giPort, SAddress, Sdata
> 
> thanks -
> 
> 	joachim
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-07-07 23:39
Fromjoachim heintz
SubjectRe: [Csnd] opcode request: better OSC support
AttachmentsOSC.py  
thanks, victor. i don't know about the details of the implementation,
but in PD you can send a list like [/ITL defaultShow 0]. i suppose the
implementation looks for the types.

i have also used the simple python implementation in OSC.py
(http://pypi.python.org/pypi/pyOSC). here i can send with the
combination of an address string and a list, like:
client.send( OSCMessage("/ITL", ['rootPath', '/this/path' ] ) )

i do attach the OSC.py, which is in pure python. maybe it shows how it
could be done.

best -

	joachim


Am 08.07.2012 00:26, schrieb Victor Lazzarini:
> The only question is this:
> 
> when sending the data, what type should we ascribe to it? OSC asks for types. Just a single "s" ?
> I see that on receiving, we would match everything, so ignoring the types, that should be possible.
> 
> Victor
> 
> On 7 Jul 2012, at 23:12, joachim heintz wrote:
> 
>> (sorry, again:)
>>
>> hi -
>>
>> i am working on some csound examples for the INScore project of
>> dominique fober (GRAME, Lyon, France). if anyone wants to have an
>> impression:
>> http://inscore.sourceforge.net/
>>
>> i am very restricted in my work because the csound opcodes for Open
>> Sound Control are rather restricted. i can't see how i can send
>> type-flexible messages like
>> /ITL defaultShow 0
>> /ITL/scene/* del
>> /ITL/scene color 255 255 255 255
>> /ITL/scene width 1.33
>> /ITL/scene/title set file rsrc/title.html
>> /ITL/scene/title x -0.12
>> /ITL/scene/title y -0.66
>> /ITL/scene/title scale 3.3
>> /ITL/scene/title show 1
>> in another way than translating them by hand. it is even not possible to
>> use the score or an external file for this. and because the python
>> opcodes do not accept strings as input and output, i can't see no way at
>> all.
>>
>> the similar problem is in receiving OSC messages, because csound wants
>> to know the exact formal of the message. if you don't know the exact
>> format, you receive nothing.
>>
>> can there be opcodes like the PD objects sendOSC and dumpOSC? perhaps
>> like this:
>>
>> OSCsend2 kWhen, SHost, iPort, Sdest, SMsg
>> like: OSCsend2 1, "localhost", 7000, "/ITL", "defaultShow 0"
>>
>> OSClisten2 could in a similar way just receive a data string:
>> kans OSClisten2 giPort, SAddress, Sdata
>>
>> thanks -
>>
>> 	joachim
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
> 
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
> 
> 
> 
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 


Date2012-07-08 00:11
FromVictor Lazzarini
SubjectRe: [Csnd] opcode request: better OSC support
I think in PD the list yields the types and that is probably the case with python. Not sure how to do that in Csound right now.
I'll have to think a bit.

Victor
On 7 Jul 2012, at 23:39, joachim heintz wrote:

> thanks, victor. i don't know about the details of the implementation,
> but in PD you can send a list like [/ITL defaultShow 0]. i suppose the
> implementation looks for the types.
> 
> i have also used the simple python implementation in OSC.py
> (http://pypi.python.org/pypi/pyOSC). here i can send with the
> combination of an address string and a list, like:
> client.send( OSCMessage("/ITL", ['rootPath', '/this/path' ] ) )
> 
> i do attach the OSC.py, which is in pure python. maybe it shows how it
> could be done.
> 
> best -
> 
> 	joachim
> 
> 
> Am 08.07.2012 00:26, schrieb Victor Lazzarini:
>> The only question is this:
>> 
>> when sending the data, what type should we ascribe to it? OSC asks for types. Just a single "s" ?
>> I see that on receiving, we would match everything, so ignoring the types, that should be possible.
>> 
>> Victor
>> 
>> On 7 Jul 2012, at 23:12, joachim heintz wrote:
>> 
>>> (sorry, again:)
>>> 
>>> hi -
>>> 
>>> i am working on some csound examples for the INScore project of
>>> dominique fober (GRAME, Lyon, France). if anyone wants to have an
>>> impression:
>>> http://inscore.sourceforge.net/
>>> 
>>> i am very restricted in my work because the csound opcodes for Open
>>> Sound Control are rather restricted. i can't see how i can send
>>> type-flexible messages like
>>> /ITL defaultShow 0
>>> /ITL/scene/* del
>>> /ITL/scene color 255 255 255 255
>>> /ITL/scene width 1.33
>>> /ITL/scene/title set file rsrc/title.html
>>> /ITL/scene/title x -0.12
>>> /ITL/scene/title y -0.66
>>> /ITL/scene/title scale 3.3
>>> /ITL/scene/title show 1
>>> in another way than translating them by hand. it is even not possible to
>>> use the score or an external file for this. and because the python
>>> opcodes do not accept strings as input and output, i can't see no way at
>>> all.
>>> 
>>> the similar problem is in receiving OSC messages, because csound wants
>>> to know the exact formal of the message. if you don't know the exact
>>> format, you receive nothing.
>>> 
>>> can there be opcodes like the PD objects sendOSC and dumpOSC? perhaps
>>> like this:
>>> 
>>> OSCsend2 kWhen, SHost, iPort, Sdest, SMsg
>>> like: OSCsend2 1, "localhost", 7000, "/ITL", "defaultShow 0"
>>> 
>>> OSClisten2 could in a similar way just receive a data string:
>>> kans OSClisten2 giPort, SAddress, Sdata
>>> 
>>> thanks -
>>> 
>>> 	joachim
>>> 
>>> 
>>> Send bugs reports to the Sourceforge bug tracker
>>>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>> 
>> 
>> Dr Victor Lazzarini
>> Senior Lecturer
>> Dept. of Music
>> NUI Maynooth Ireland
>> tel.: +353 1 708 3545
>> Victor dot Lazzarini AT nuim dot ie
>> 
>> 
>> 
>> 
>> 
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>> 
>> 
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-07-08 16:16
FromTarmo Johannes
SubjectRe: [Csnd] opcode request: better OSC support
Hello,


On Sunday 08 July 2012 00:12:38 joachim heintz wrote:
> how i can send
> type-flexible messages like
> /ITL defaultShow 0

so far one possible workaround could be to use system opcode to run utilites 
oscsend or  dumposc of the liblo pacakge like


ires system_i 1, "oscsend localhost 7000 /ITL defaultShow 0"


I have used it with sending messages without any parameters (that fail wis 
csounds OSCsend (like for example 

ires system_i 1, "oscsend localhost 3819 /ardour/transport_start"	

)

But probably your python module does the work at least as good.

not sure if it helps...

tarmo


Date2012-07-08 17:29
Fromjoachim heintz
SubjectRe: [Csnd] opcode request: better OSC support
hi tarmo -

thanks for the tip. it's not so much about my personal use, but i want
to make examples for INScore, and for all platforms. so i can't depend
on the system opcode and having liblo installed.

the syntax you decribed for liblo is exactly what i would love to see in
csound, to support the flexibility of osc messages.

best -

	joachim



Am 08.07.2012 17:16, schrieb Tarmo Johannes:
> Hello,
> 
> 
> On Sunday 08 July 2012 00:12:38 joachim heintz wrote:
>> how i can send
>> type-flexible messages like
>> /ITL defaultShow 0
> 
> so far one possible workaround could be to use system opcode to run utilites 
> oscsend or  dumposc of the liblo pacakge like
> 
> 
> ires system_i 1, "oscsend localhost 7000 /ITL defaultShow 0"
> 
> 
> I have used it with sending messages without any parameters (that fail wis 
> csounds OSCsend (like for example 
> 
> ires system_i 1, "oscsend localhost 3819 /ardour/transport_start"	
> 
> )
> 
> But probably your python module does the work at least as good.
> 
> not sure if it helps...
> 
> tarmo
> 
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 


Date2012-07-08 17:43
FromVictor Lazzarini
SubjectRe: [Csnd] opcode request: better OSC support
I guess the solution is to parse the string. Spaces separate arguments; anything starting with a number is either int, float or double. Numbers with decimal points are either floats or doubles, the ones finishing with 'f' are floats. Anything non-numeric is a string.

Should be possible.

Victor
On 8 Jul 2012, at 17:29, joachim heintz wrote:

> hi tarmo -
> 
> thanks for the tip. it's not so much about my personal use, but i want
> to make examples for INScore, and for all platforms. so i can't depend
> on the system opcode and having liblo installed.
> 
> the syntax you decribed for liblo is exactly what i would love to see in
> csound, to support the flexibility of osc messages.
> 
> best -
> 
> 	joachim
> 
> 
> 
> Am 08.07.2012 17:16, schrieb Tarmo Johannes:
>> Hello,
>> 
>> 
>> On Sunday 08 July 2012 00:12:38 joachim heintz wrote:
>>> how i can send
>>> type-flexible messages like
>>> /ITL defaultShow 0
>> 
>> so far one possible workaround could be to use system opcode to run utilites 
>> oscsend or  dumposc of the liblo pacakge like
>> 
>> 
>> ires system_i 1, "oscsend localhost 7000 /ITL defaultShow 0"
>> 
>> 
>> I have used it with sending messages without any parameters (that fail wis 
>> csounds OSCsend (like for example 
>> 
>> ires system_i 1, "oscsend localhost 3819 /ardour/transport_start"	
>> 
>> )
>> 
>> But probably your python module does the work at least as good.
>> 
>> not sure if it helps...
>> 
>> tarmo
>> 
>> 
>> 
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>> 
>> 
> 
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie





Date2012-07-09 08:39
Fromjoachim heintz
SubjectRe: [Csnd] opcode request: better OSC support
yes i think so. in python the core might be somthing like:

def strToNum(str):
    """converts str to a float or int if possible"""
    try:
        float(str)
    except ValueError:
        res = str
    else:
        try:
            int(str)
        except ValueError:
            res = float(str)
        else:
            res = int(str)
    return res

in csound:

  opcode StrNumP, i, S
;tests whether String is numerical string (simple, no scientific
notation) which can be converted via strtod ito a float (1 = yes, 0 = no)
Str       xin	
ip        =         1; start at yes and falsify
ilen      strlen    Str
 if ilen == 0 then
ip        =         0
          igoto     end
 endif
ifirst    strchar   Str, 0
 if ifirst == 45 then; a "-" is just allowed as first character
Str       strsub    Str, 1, -1
ilen      =         ilen-1
 endif
indx      =         0
inpnts    =         0; how many points have there been
loop:
iascii    strchar   Str, indx; 48-57
 if iascii < 48 || iascii > 57 then; if not 0-9
  if iascii == 46 && inpnts == 0 then; if not the first point
inpnts    =         1
  else
ip        =         0
  endif
 endif	
          loop_lt   indx, 1, ilen, loop
end:	     xout      ip
  endop

i just don't know how to write it in C ...

thanks -
	joachim



Am 08.07.2012 18:43, schrieb Victor Lazzarini:
> I guess the solution is to parse the string. Spaces separate arguments; anything starting with a number is either int, float or double. Numbers with decimal points are either floats or doubles, the ones finishing with 'f' are floats. Anything non-numeric is a string.
> 
> Should be possible.
> 
> Victor
> On 8 Jul 2012, at 17:29, joachim heintz wrote:
> 
>> hi tarmo -
>>
>> thanks for the tip. it's not so much about my personal use, but i want
>> to make examples for INScore, and for all platforms. so i can't depend
>> on the system opcode and having liblo installed.
>>
>> the syntax you decribed for liblo is exactly what i would love to see in
>> csound, to support the flexibility of osc messages.
>>
>> best -
>>
>> 	joachim
>>
>>
>>
>> Am 08.07.2012 17:16, schrieb Tarmo Johannes:
>>> Hello,
>>>
>>>
>>> On Sunday 08 July 2012 00:12:38 joachim heintz wrote:
>>>> how i can send
>>>> type-flexible messages like
>>>> /ITL defaultShow 0
>>>
>>> so far one possible workaround could be to use system opcode to run utilites 
>>> oscsend or  dumposc of the liblo pacakge like
>>>
>>>
>>> ires system_i 1, "oscsend localhost 7000 /ITL defaultShow 0"
>>>
>>>
>>> I have used it with sending messages without any parameters (that fail wis 
>>> csounds OSCsend (like for example 
>>>
>>> ires system_i 1, "oscsend localhost 3819 /ardour/transport_start"	
>>>
>>> )
>>>
>>> But probably your python module does the work at least as good.
>>>
>>> not sure if it helps...
>>>
>>> tarmo
>>>
>>>
>>>
>>> Send bugs reports to the Sourceforge bug tracker
>>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>>
>>>
>>
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
> 
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
> 
> 
> 
> 
> 
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
>