packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/AudioTimestamp.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webaudio-1.1 (webref). Do not edit.
module JSDOM.Generated.AudioTimestamp
       (newAudioTimestamp, setContextTime, getContextTime, getContextTimeUnsafe, getContextTimeUnchecked, setPerformanceTime, getPerformanceTime, getPerformanceTimeUnsafe, getPerformanceTimeUnchecked, AudioTimestamp(..), gTypeAudioTimestamp)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://webaudio.github.io/web-audio-api/#AudioTimestamp AudioTimestamp specification>
newAudioTimestamp :: (MonadDOM m) => m AudioTimestamp
newAudioTimestamp = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-contexttime AudioTimestamp.contextTime specification>
setContextTime :: (MonadDOM m) => AudioTimestamp -> Double -> m ()
setContextTime self val = liftDOM (void (self ^. jss "contextTime" (toJSVal val)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-contexttime AudioTimestamp.contextTime specification>
getContextTime :: (MonadDOM m) => AudioTimestamp -> m (Maybe Double)
getContextTime self = liftDOM (((self ^. js "contextTime") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-contexttime AudioTimestamp.contextTime specification>
getContextTimeUnsafe :: (MonadDOM m, HasCallStack) => AudioTimestamp -> m Double
getContextTimeUnsafe self = liftDOM ((((self ^. js "contextTime") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-contexttime AudioTimestamp.contextTime specification>
getContextTimeUnchecked :: (MonadDOM m) => AudioTimestamp -> m Double
getContextTimeUnchecked self = liftDOM (((self ^. js "contextTime") >>= valToNumber))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-performancetime AudioTimestamp.performanceTime specification>
setPerformanceTime :: (MonadDOM m) => AudioTimestamp -> Double -> m ()
setPerformanceTime self val = liftDOM (void (self ^. jss "performanceTime" (toJSVal val)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-performancetime AudioTimestamp.performanceTime specification>
getPerformanceTime :: (MonadDOM m) => AudioTimestamp -> m (Maybe Double)
getPerformanceTime self = liftDOM (((self ^. js "performanceTime") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-performancetime AudioTimestamp.performanceTime specification>
getPerformanceTimeUnsafe :: (MonadDOM m, HasCallStack) => AudioTimestamp -> m Double
getPerformanceTimeUnsafe self = liftDOM ((((self ^. js "performanceTime") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiotimestamp-performancetime AudioTimestamp.performanceTime specification>
getPerformanceTimeUnchecked :: (MonadDOM m) => AudioTimestamp -> m Double
getPerformanceTimeUnchecked self = liftDOM (((self ^. js "performanceTime") >>= valToNumber))