(From Trac issue #51 by joreg)
my suggestion for the implementation of PadSize is:
{{{
private static int PadSize(int rawSize)
{
return rawSize + 4 - rawSize % 4;
}
}}}
it is then important to ''not'' include the ending \0 in rawSize for
0-terminated strings. this is
simple because for strings you can simply call PadSize(string.length()).
the current implementation somehow leads to problems when sending messages with
3, 7,
11,...parameters as padsize seems to be computed wrong when called with strings
of lengths of
multiples of 4 (in this case the typetag string e.g: ,iii or ,iiiffff)
also a similar change is necessary in InsertString. my suggestion:
{{{
private static int InsertString(string s, byte[] packet, int start, int length)
{
int index = start;
foreach (char c in s)
{
packet[index++] = (byte)c;
if (index == length)
return index;
}
int pad = 4 - (s.Length) % 4;
while (pad-- > 0)
packet[index++] = 0;
return index;
}
}}}
attached is a version of Osc.cs that works for me so far.
Original issue reported on code.google.com by lst...@gmail.com on 1 Jul 2009 at 5:01
Original issue reported on code.google.com by
lst...@gmail.com
on 1 Jul 2009 at 5:01Attachments: