[PD] packOSC integer marshalling

Jamie Bullock jamie at jamiebullock.com
Fri Sep 7 13:11:01 CEST 2012

Hi list,

It looks like the mrpeach [packOSC] external converts Pd floats to OSC integers if the float value is equal to the float value cast to an int. From the source code:

   /* It might be an int, a float, or a string */
   switch (a->a_type)
       case A_FLOAT:
           f = atom_getfloat(a);
           i = atom_getint(a);
           if (f == (t_float)i)
           { /* assume that if the int and float are the same, it's an int */
               returnVal.type = INT_osc;

Implicitly converting floats to integers based on an arbitrary rule seems a bad idea to me. Why bother making the conversion? Why not send floats as floats?

It's certainly going to cause problems for some clients. For example, if the client is expecting floats on a given OSC address, it may get:

0.5 -> float
1.0 -> int ???
1.5 -> float

Which may result in dropped values or other anomalies.

I am happy to send a code patch if people agree that this is a bug or at least bad design...



More information about the Pd-list mailing list