| 1 |
|
| 2 |
module Sound.Osc.Coding.Convert where |
| 3 |
|
| 4 |
import Data.Int {- base -} |
| 5 |
import Data.Word {- base -} |
| 6 |
|
| 7 |
-- * Int -> N |
| 8 |
|
| 9 |
|
| 10 |
int_to_word8 :: Int -> Word8 |
| 11 |
int_to_word8 = fromIntegral |
| 12 |
|
| 13 |
|
| 14 |
int_to_word32 :: Int -> Word32 |
| 15 |
int_to_word32 = fromIntegral |
| 16 |
|
| 17 |
|
| 18 |
int_to_word16 :: Int -> Word16 |
| 19 |
int_to_word16 = fromIntegral |
| 20 |
|
| 21 |
|
| 22 |
int_to_int8 :: Int -> Int8 |
| 23 |
int_to_int8 = fromIntegral |
| 24 |
|
| 25 |
|
| 26 |
int_to_int16 :: Int -> Int16 |
| 27 |
int_to_int16 = fromIntegral |
| 28 |
|
| 29 |
|
| 30 |
int_to_int32 :: Int -> Int32 |
| 31 |
int_to_int32 = fromIntegral |
| 32 |
|
| 33 |
|
| 34 |
int_to_int64 :: Int -> Int64 |
| 35 |
int_to_int64 = fromIntegral |
| 36 |
|
| 37 |
-- * N -> Int |
| 38 |
|
| 39 |
|
| 40 |
int8_to_int :: Int8 -> Int |
| 41 |
int8_to_int = fromIntegral |
| 42 |
|
| 43 |
|
| 44 |
int16_to_int :: Int16 -> Int |
| 45 |
int16_to_int = fromIntegral |
| 46 |
|
| 47 |
|
| 48 |
int32_to_int :: Int32 -> Int |
| 49 |
int32_to_int = fromIntegral |
| 50 |
|
| 51 |
|
| 52 |
int64_to_int :: Int64 -> Int |
| 53 |
int64_to_int = fromIntegral |
| 54 |
|
| 55 |
|
| 56 |
word8_to_int :: Word8 -> Int |
| 57 |
word8_to_int = fromIntegral |
| 58 |
|
| 59 |
|
| 60 |
word16_to_int :: Word16 -> Int |
| 61 |
word16_to_int = fromIntegral |
| 62 |
|
| 63 |
|
| 64 |
word32_to_int :: Word32 -> Int |
| 65 |
word32_to_int = fromIntegral |
| 66 |
|
| 67 |
-- * N -> N |
| 68 |
|
| 69 |
|
| 70 |
word16_to_word32 :: Word16 -> Word32 |
| 71 |
word16_to_word32 = fromIntegral |
| 72 |
|
| 73 |
|
| 74 |
word32_to_word16 :: Word32 -> Word16 |
| 75 |
word32_to_word16 = fromIntegral |
| 76 |
|
| 77 |
|
| 78 |
word32_to_int32 :: Word32 -> Int32 |
| 79 |
word32_to_int32 = fromIntegral |
| 80 |
|
| 81 |
|
| 82 |
word32_to_int64 :: Word32 -> Int64 |
| 83 |
word32_to_int64 = fromIntegral |
| 84 |
|
| 85 |
|
| 86 |
word64_to_int64 :: Word64 -> Int64 |
| 87 |
word64_to_int64 = fromIntegral |
| 88 |
|
| 89 |
|
| 90 |
int64_to_int32 :: Int64 -> Int32 |
| 91 |
int64_to_int32 = fromIntegral |
| 92 |
|
| 93 |
|
| 94 |
int64_to_word32 :: Int64 -> Word32 |
| 95 |
int64_to_word32 = fromIntegral |
| 96 |
|
| 97 |
-- * N -> Real |
| 98 |
|
| 99 |
|
| 100 |
word64_to_double :: Word64 -> Double |
| 101 |
word64_to_double = fromIntegral |
| 102 |
|
| 103 |
-- * Enum |
| 104 |
|
| 105 |
|
| 106 |
word8_to_enum :: Enum e => Word8 -> e |
| 107 |
word8_to_enum = toEnum . fromIntegral |
| 108 |
|
| 109 |
|
| 110 |
word16_to_enum :: Enum e => Word16 -> e |
| 111 |
word16_to_enum = toEnum . fromIntegral |
| 112 |
|
| 113 |
|
| 114 |
enum_to_word8 :: Enum e => e -> Word8 |
| 115 |
enum_to_word8 = fromIntegral . fromEnum |
| 116 |
|
| 117 |
|
| 118 |
enum_to_word16 :: Enum e => e -> Word16 |
| 119 |
enum_to_word16 = fromIntegral . fromEnum |
| 120 |
|
| 121 |
-- * Enum/Char |
| 122 |
|
| 123 |
|
| 124 |
word8_to_char :: Word8 -> Char |
| 125 |
word8_to_char = word8_to_enum |
| 126 |
|
| 127 |
|
| 128 |
char_to_word8 :: Char -> Word8 |
| 129 |
char_to_word8 = enum_to_word8 |