module Sound.Osc.Coding.Cast where
import Data.Char
import Data.Word
import qualified Data.Binary.IEEE754 as Ieee
import Sound.Osc.Coding.Convert
f32_w32 :: Float -> Word32
f32_w32 :: Float -> Word32
f32_w32 = Float -> Word32
Ieee.floatToWord
w32_f32 :: Word32 -> Float
w32_f32 :: Word32 -> Float
w32_f32 = Word32 -> Float
Ieee.wordToFloat
f64_w64 :: Double -> Word64
f64_w64 :: Double -> Word64
f64_w64 = Double -> Word64
Ieee.doubleToWord
w64_f64 :: Word64 -> Double
w64_f64 :: Word64 -> Double
w64_f64 = Word64 -> Double
Ieee.wordToDouble
str_cstr :: String -> [Word8]
str_cstr :: String -> [Word8]
str_cstr String
s = forall a b. (a -> b) -> [a] -> [b]
map (Int -> Word8
int_to_word8 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) String
s forall a. [a] -> [a] -> [a]
++ [Word8
0]
cstr_str :: [Word8] -> String
cstr_str :: [Word8] -> String
cstr_str = forall a b. (a -> b) -> [a] -> [b]
map (Int -> Char
chr forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Int
word8_to_int) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
takeWhile (forall a. Eq a => a -> a -> Bool
/= Word8
0)
str_pstr :: String -> [Word8]
str_pstr :: String -> [Word8]
str_pstr String
s = Int -> Word8
int_to_word8 (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s) forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map (Int -> Word8
int_to_word8 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) String
s
pstr_str :: [Word8] -> String
pstr_str :: [Word8] -> String
pstr_str = forall a b. (a -> b) -> [a] -> [b]
map (Int -> Char
chr forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> Int
word8_to_int) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> [a] -> [a]
drop Int
1