module Sound.OpenSoundControl.Coding.Coerce where
import Sound.OpenSoundControl.Type
message_coerce :: (Datum -> Datum) -> Message -> Message
message_coerce f (Message s xs) = Message s (map f xs)
bundle_coerce :: (Datum -> Datum) -> Bundle -> Bundle
bundle_coerce f (Bundle t xs) = Bundle t (map (message_coerce f) xs)
f_to_d :: Datum -> Datum
f_to_d d =
case d of
Float n -> Double n
_ -> d
if_to_d :: Datum -> Datum
if_to_d d =
case d of
Int n -> Double (fromIntegral n)
Float n -> Double n
_ -> d
fd_to_i :: Datum -> Datum
fd_to_i d =
case d of
Float n -> Int (round n)
Double n -> Int (round n)
_ -> d