Csound Csound-dev Csound-tekno Search About

[Cs-dev] OSC and Csound

Date2005-05-02 09:53
Fromjpff@codemist.co.uk
Subject[Cs-dev] OSC and Csound
I have a working OSCsend opcode -- a little restrictive until I work
some problems out.  However there is a licence problem as I understand
it.  I am using liblo which is GPL so cannot be linked with LGPL
code.  I have mailed the author, Steve Harris, to ask for his
assistance.  We need also to see if it will work on OSX and Windows.

I reinstalled liblo this morning and it all magically worked.  Notes
below are preliminary.  Could extend to use the N format, but I still
need to know whether a value is integer or float.

Have only given a little thought to OSCreceive.  
==John ffitch


Opcode
        OSCsend   kwhen, sHost, iPort, sDest, itype, sArg1, sArg2

Sends OSC message(s) to host described in the string sHost, to port
iPort.  A host of "" is treated as the local machine.  The message is
send to the OSC destination given in the string sDest.  One or two
data items can be sent.  The code itype says what they are:
       0)  int
       1)  float
       2)  string
       3)  int int
       4)  int float
       5)  int string
       6)  float int
       7)  float string
       8)  float float
       9)  string int
       10) string float
       11) string string

A message is sent on first call, and then whenever the kwhen variable
changes.  

Example

    OSCsend     kk, "", 7770, "/foo/bar", 4, 42, "FOO"




-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-02 12:42
FromIstvan Varga
SubjectRe: [Cs-dev] OSC and Csound
jpff@codemist.co.uk wrote:

> I reinstalled liblo this morning and it all magically worked.  Notes
> below are preliminary.  Could extend to use the N format, but I still
> need to know whether a value is integer or float.

>         OSCsend   kwhen, sHost, iPort, sDest, itype, sArg1, sArg2

You mean something like this ?

     OSCsend kwhen, sHost, iPort, sDest, xArg1[, xArg2[, ... xArg27]]

with an opcode entry of:

     "kSiSN"

Then, the opcode should check the following at init time:

   /* with too many args, XINCODE/XSTRCODE may not work correctly */
   if (p->INOCOUNT > 31) csound->InitError(...);
   /* a-rate arguments are not allowed */
   if (p->XINCODE) csound->InitError(...);

Argument types can be determined as follows:

   xArg1 is string if p->XSTRCODE & 16 is non-zero
   xArg2 is string if p->XSTRCODE & 32 is non-zero
   xArg3 is string if p->XSTRCODE & 64 is non-zero
   etc.

Arguments that are known to be MYFLT can be further checked for being integer
or float with code like ((double) ((long) x) == (double) x), assuming that you
do not want to treat values that are very close to integers (e.g. 0.99999) as
integers, in which case a more complex test is needed (such as done in oload.c
for consistency of sr/kr/ksmps).


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-02 13:27
Fromjpff@codemist.co.uk
SubjectRe: [Cs-dev] OSC and Csound
No, OSC transmits three type, integer, float and string.  The N
specification allows float or string, but not the integer v string as
that is a user decision.  Clearly what you suggest is possible, but is
not the answer.  One would need some way of indicating which.
==John ffitch


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-07 15:12
FromAndres Cabrera
SubjectRe: [Cs-dev] OSC and Csound
AttachmentsOSC.c  
Hi John,
Thanks very much for the OSCsend opcodes, they are extremely useful for
me! (and are working fine on my preliminary tests communicating with pd
locally)
I notice that the itype order is wrong in the sources with respect to
your message, I think they should be:
       0)  int
       1)  float
       2)  string
       3)  int int
       4)  int float
       5)  int string
       6)  float int
       7)  float float
       8)  float string
       9)  string int
       10) string float
       11) string string
I'm attaching a corrected version for someone to commit, since I don't
have karma in that directory.

Thanks,
Andres

Date2005-05-07 18:59
Fromjpff@codemist.co.uk
SubjectRe: [Cs-dev] OSC and Csound
The order should be int, float, string and I have ensured that is
what the comments and code does.

As Istvan has liberalised the number of strings again I could 'easily'
extend this a little.  At present there is no checking which worries
me a little.
==John ffitch


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-07 21:37
FromIstvan Varga
SubjectRe: [Cs-dev] OSC and Csound
It may be possible to use a string type argument instead of an integer,
in a format like "isf" (for integer, string, and float), in combination
with the 'N' type. The type string would be parsed at i-rate (and checked
for consistency with the actual argument list), and if it is too short,
any remaining number arguments would be assumed float.

jpff@codemist.co.uk wrote:

> The order should be int, float, string and I have ensured that is
> what the comments and code does.
> 
> As Istvan has liberalised the number of strings again I could 'easily'
> extend this a little.  At present there is no checking which worries
> me a little.
> ==John ffitch


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-09 01:45
FromAndres Cabrera
SubjectRe: [Cs-dev] OSC and Csound
John,
Thanks, there's still this little one:

       0)  int
       1)  float
       2)  string


while the code says:

	case 0:
        lo_send(p->addr, (char*) p->dest, "i", (int)(FL(0.5)+*p->d1));
        return OK;
      case 1:
        lo_send(p->addr, (char*) p->dest, "s", (char*) p->d1);
        return OK;
      case 2:
        lo_send(p->addr, (char*) p->dest, "f", (float) *p->d1);
        return OK;

Thanks,
Andres

On Sat, 2005-05-07 at 12:59, jpff@codemist.co.uk wrote:
> The order should be int, float, string and I have ensured that is
> what the comments and code does.
> 
> As Istvan has liberalised the number of strings again I could 'easily'
> extend this a little.  At present there is no checking which worries
> me a little.
> ==John ffitch
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.
> Get your fingers limbered up and give it your best shot. 4 great events, 4
> opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
> win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-09 08:36
Fromjpff@codemist.co.uk
SubjectRe: [Cs-dev] OSC and Csound
Hum; perhaps I need new glasses.  Fixed now

==John ffitch

>>>>> "Andres" == Andres Cabrera  writes:

 Andres> John,
 Andres> Thanks, there's still this little one:

 Andres>        0)  int
 Andres>        1)  float
 Andres>        2)  string



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-05-09 12:41
FromIstvan Varga
SubjectRe: [Cs-dev] OSC and Csound
jpff@codemist.co.uk wrote:

> Hum; perhaps I need new glasses.  Fixed now

Still looks wrong:

          return OK;
        case 1:
-        lo_send(p->addr, (char*) p->dest, "s", (char*) p->d1);
+        lo_send(p->addr, (char*) p->dest, "s", (float*) p->d1);
          return OK;
        case 2:
-        lo_send(p->addr, (char*) p->dest, "f", (float) *p->d1);
+        lo_send(p->addr, (char*) p->dest, "f", (char) *p->d1);
          return OK;
        case 3:

case 1 should be (assuming that it is intended to send a float)
          lo_send(p->addr, (char*) p->dest, "f", (float) *p->d1);
case 2 should be (for sending a string)
          lo_send(p->addr, (char*) p->dest, "s", (char*) p->d1);


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net