-- Copyright 2017 Evan Laforge
-- This program is distributed under the terms of the GNU General Public
-- License 3.0, see COPYING or http://www.gnu.org/licenses/gpl-3.0.txt

module Ness.Global where
import qualified Data.Text as Text

import Global


type SamplingRate = Int

class Render a where
    render :: a -> Text

instance Render Double where
    render :: Double -> Text
render Double
n = forall a. a -> Maybe a -> a
fromMaybe Text
t forall a b. (a -> b) -> a -> b
$ Text -> Text -> Maybe Text
Text.stripSuffix Text
".0" Text
t
        where t :: Text
t = forall a. Show a => a -> Text
showt Double
n
instance Render Int where render :: Int -> Text
render = forall a. Show a => a -> Text
showt
instance Render Bool where render :: Bool -> Text
render Bool
b = if Bool
b then Text
"1" else Text
"0"

type Meters = Double
type Seconds = Double
type Newtons = Double
type Kg = Double
type Velocity = Double -- m/s
-- | From -1 to 1.
type Pan = Double
-- | Normalized linear position, from 0 to 1.
type Location = Double
type Frequency = Double -- hz