I'm trying to fix a bug in Audio::OSC, where values are packed/unpacked incorrectly on some platforms and I've run into a problem I can't really solve:
According to the OSC Spec examples, a float value of 440.0 should be encoded as 43 dc 00 00. Using pack('f', 440.0'), I get these results:
- Mac: 43 dc 00 00 - correct according to spec.
- PC: 00 00 43 dc - incorrect.
A user suggested the somewhat unsightly combination pack("N", unpack("l", pack("f", 440.0))), but that yielded
- Mac: 43 dc 00 00 - still correct
- PC: dc 43 00 00 - still incorrect, but differently
Can somebody help me to come up with a good and fast solution for this? Even if it only works on PCs, it's okay -- I can check the endian-ness on startup and make aliases for the correct function to use. The main point is that it should be correct and fast.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.