module Util.Audio.AudioT where
import qualified Util.Serialize as Serialize
import Global
newtype Frames = Frames Int
deriving (Int -> Frames -> ShowS
[Frames] -> ShowS
Frames -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Frames] -> ShowS
$cshowList :: [Frames] -> ShowS
show :: Frames -> String
$cshow :: Frames -> String
showsPrec :: Int -> Frames -> ShowS
$cshowsPrec :: Int -> Frames -> ShowS
Show, Frames -> Frames -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Frames -> Frames -> Bool
$c/= :: Frames -> Frames -> Bool
== :: Frames -> Frames -> Bool
$c== :: Frames -> Frames -> Bool
Eq, Eq Frames
Frames -> Frames -> Bool
Frames -> Frames -> Ordering
Frames -> Frames -> Frames
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Frames -> Frames -> Frames
$cmin :: Frames -> Frames -> Frames
max :: Frames -> Frames -> Frames
$cmax :: Frames -> Frames -> Frames
>= :: Frames -> Frames -> Bool
$c>= :: Frames -> Frames -> Bool
> :: Frames -> Frames -> Bool
$c> :: Frames -> Frames -> Bool
<= :: Frames -> Frames -> Bool
$c<= :: Frames -> Frames -> Bool
< :: Frames -> Frames -> Bool
$c< :: Frames -> Frames -> Bool
compare :: Frames -> Frames -> Ordering
$ccompare :: Frames -> Frames -> Ordering
Ord, Integer -> Frames
Frames -> Frames
Frames -> Frames -> Frames
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Frames
$cfromInteger :: Integer -> Frames
signum :: Frames -> Frames
$csignum :: Frames -> Frames
abs :: Frames -> Frames
$cabs :: Frames -> Frames
negate :: Frames -> Frames
$cnegate :: Frames -> Frames
* :: Frames -> Frames -> Frames
$c* :: Frames -> Frames -> Frames
- :: Frames -> Frames -> Frames
$c- :: Frames -> Frames -> Frames
+ :: Frames -> Frames -> Frames
$c+ :: Frames -> Frames -> Frames
Num, Num Frames
Ord Frames
Frames -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: Frames -> Rational
$ctoRational :: Frames -> Rational
Real, Int -> Frames
Frames -> Int
Frames -> [Frames]
Frames -> Frames
Frames -> Frames -> [Frames]
Frames -> Frames -> Frames -> [Frames]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Frames -> Frames -> Frames -> [Frames]
$cenumFromThenTo :: Frames -> Frames -> Frames -> [Frames]
enumFromTo :: Frames -> Frames -> [Frames]
$cenumFromTo :: Frames -> Frames -> [Frames]
enumFromThen :: Frames -> Frames -> [Frames]
$cenumFromThen :: Frames -> Frames -> [Frames]
enumFrom :: Frames -> [Frames]
$cenumFrom :: Frames -> [Frames]
fromEnum :: Frames -> Int
$cfromEnum :: Frames -> Int
toEnum :: Int -> Frames
$ctoEnum :: Int -> Frames
pred :: Frames -> Frames
$cpred :: Frames -> Frames
succ :: Frames -> Frames
$csucc :: Frames -> Frames
Enum, Enum Frames
Real Frames
Frames -> Integer
Frames -> Frames -> (Frames, Frames)
Frames -> Frames -> Frames
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Frames -> Integer
$ctoInteger :: Frames -> Integer
divMod :: Frames -> Frames -> (Frames, Frames)
$cdivMod :: Frames -> Frames -> (Frames, Frames)
quotRem :: Frames -> Frames -> (Frames, Frames)
$cquotRem :: Frames -> Frames -> (Frames, Frames)
mod :: Frames -> Frames -> Frames
$cmod :: Frames -> Frames -> Frames
div :: Frames -> Frames -> Frames
$cdiv :: Frames -> Frames -> Frames
rem :: Frames -> Frames -> Frames
$crem :: Frames -> Frames -> Frames
quot :: Frames -> Frames -> Frames
$cquot :: Frames -> Frames -> Frames
Integral, Get Frames
Putter Frames
forall a. Putter a -> Get a -> Serialize a
get :: Get Frames
$cget :: Get Frames
put :: Putter Frames
$cput :: Putter Frames
Serialize.Serialize)
instance Pretty Frames where
pretty :: Frames -> Text
pretty (Frames Int
n) = forall a. Pretty a => a -> Text
pretty Int
n forall a. Semigroup a => a -> a -> a
<> Text
"f"
type Rate = Int
type Seconds = Double
framesToSeconds :: Rate -> Frames -> Seconds
framesToSeconds :: Int -> Frames -> Seconds
framesToSeconds Int
rate (Frames Int
frames) = forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
frames forall a. Fractional a => a -> a -> a
/ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
rate