| 1 |
|
| 2 |
module Sound.Osc.Coding.Cast where |
| 3 |
|
| 4 |
import Data.Char {- base -} |
| 5 |
import Data.Word {- base -} |
| 6 |
|
| 7 |
import Sound.Osc.Coding.Byte {- hosc3 -} |
| 8 |
import Sound.Osc.Coding.Convert {- hosc -} |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
f32_w32 :: Float -> Word32 |
| 22 |
f32_w32 = decode_word32 . encode_f32 |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
w32_f32 :: Word32 -> Float |
| 33 |
w32_f32 = decode_f32 . encode_word32 |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
f64_w64 :: Double -> Word64 |
| 45 |
f64_w64 = decode_word64 . encode_f64 |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
w64_f64 :: Word64 -> Double |
| 56 |
w64_f64 = decode_f64 . encode_word64 |
| 57 |
|
| 58 |
|
| 59 |
str_cstr :: String -> [Word8] |
| 60 |
str_cstr s = map (int_to_word8 . ord) s ++ [0] |
| 61 |
|
| 62 |
|
| 63 |
cstr_str :: [Word8] -> String |
| 64 |
cstr_str = map (chr . word8_to_int) . takeWhile (/= 0) |
| 65 |
|
| 66 |
|
| 67 |
str_pstr :: String -> [Word8] |
| 68 |
str_pstr s = int_to_word8 (length s) : map (int_to_word8 . ord) s |
| 69 |
|
| 70 |
|
| 71 |
pstr_str :: [Word8] -> String |
| 72 |
pstr_str = map (chr . word8_to_int) . drop 1 |