packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/AudioContextOptions.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.AudioContextOptions
       (newAudioContextOptions, setLatencyHint, getLatencyHint, getLatencyHintUnsafe, getLatencyHintUnchecked, setSampleRate, getSampleRate, getSampleRateUnsafe, getSampleRateUnchecked, setSinkId, getSinkId, getSinkIdUnsafe, getSinkIdUnchecked, setRenderSizeHint, getRenderSizeHint, getRenderSizeHintUnsafe, getRenderSizeHintUnchecked, AudioContextOptions(..), gTypeAudioContextOptions)
       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/#AudioContextOptions AudioContextOptions specification>
newAudioContextOptions :: (MonadDOM m) => m AudioContextOptions
newAudioContextOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-latencyhint AudioContextOptions.latencyHint specification>
setLatencyHint :: (MonadDOM m, IsAudioContextLatencyCategoryOrDouble val) => AudioContextOptions -> val -> m ()
setLatencyHint self val = liftDOM (void (self ^. jss "latencyHint" (toJSVal val)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-latencyhint AudioContextOptions.latencyHint specification>
getLatencyHint :: (MonadDOM m) => AudioContextOptions -> m (Maybe AudioContextLatencyCategoryOrDouble)
getLatencyHint self = liftDOM (((self ^. js "latencyHint") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-latencyhint AudioContextOptions.latencyHint specification>
getLatencyHintUnsafe :: (MonadDOM m, HasCallStack) => AudioContextOptions -> m AudioContextLatencyCategoryOrDouble
getLatencyHintUnsafe self = liftDOM ((((self ^. js "latencyHint") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-latencyhint AudioContextOptions.latencyHint specification>
getLatencyHintUnchecked :: (MonadDOM m) => AudioContextOptions -> m AudioContextLatencyCategoryOrDouble
getLatencyHintUnchecked self = liftDOM (((self ^. js "latencyHint") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-samplerate AudioContextOptions.sampleRate specification>
setSampleRate :: (MonadDOM m) => AudioContextOptions -> Float -> m ()
setSampleRate self val = liftDOM (void (self ^. jss "sampleRate" (toJSVal val)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-samplerate AudioContextOptions.sampleRate specification>
getSampleRate :: (MonadDOM m) => AudioContextOptions -> m (Maybe Float)
getSampleRate self = liftDOM (((self ^. js "sampleRate") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-samplerate AudioContextOptions.sampleRate specification>
getSampleRateUnsafe :: (MonadDOM m, HasCallStack) => AudioContextOptions -> m Float
getSampleRateUnsafe self = liftDOM ((((self ^. js "sampleRate") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-samplerate AudioContextOptions.sampleRate specification>
getSampleRateUnchecked :: (MonadDOM m) => AudioContextOptions -> m Float
getSampleRateUnchecked self = liftDOM ((P.realToFrac <$> ((self ^. js "sampleRate") >>= valToNumber)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-sinkid AudioContextOptions.sinkId specification>
setSinkId :: (MonadDOM m, IsStringOrAudioSinkOptions val) => AudioContextOptions -> val -> m ()
setSinkId self val = liftDOM (void (self ^. jss "sinkId" (toJSVal val)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-sinkid AudioContextOptions.sinkId specification>
getSinkId :: (MonadDOM m) => AudioContextOptions -> m (Maybe StringOrAudioSinkOptions)
getSinkId self = liftDOM (((self ^. js "sinkId") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-sinkid AudioContextOptions.sinkId specification>
getSinkIdUnsafe :: (MonadDOM m, HasCallStack) => AudioContextOptions -> m StringOrAudioSinkOptions
getSinkIdUnsafe self = liftDOM ((((self ^. js "sinkId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-sinkid AudioContextOptions.sinkId specification>
getSinkIdUnchecked :: (MonadDOM m) => AudioContextOptions -> m StringOrAudioSinkOptions
getSinkIdUnchecked self = liftDOM (((self ^. js "sinkId") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-rendersizehint AudioContextOptions.renderSizeHint specification>
setRenderSizeHint :: (MonadDOM m, IsAudioContextRenderSizeCategoryOrWord val) => AudioContextOptions -> val -> m ()
setRenderSizeHint self val = liftDOM (void (self ^. jss "renderSizeHint" (toJSVal val)))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-rendersizehint AudioContextOptions.renderSizeHint specification>
getRenderSizeHint :: (MonadDOM m) => AudioContextOptions -> m (Maybe AudioContextRenderSizeCategoryOrWord)
getRenderSizeHint self = liftDOM (((self ^. js "renderSizeHint") >>= fromJSValUnchecked))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-rendersizehint AudioContextOptions.renderSizeHint specification>
getRenderSizeHintUnsafe :: (MonadDOM m, HasCallStack) => AudioContextOptions -> m AudioContextRenderSizeCategoryOrWord
getRenderSizeHintUnsafe self = liftDOM ((((self ^. js "renderSizeHint") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-rendersizehint AudioContextOptions.renderSizeHint specification>
getRenderSizeHintUnchecked :: (MonadDOM m) => AudioContextOptions -> m AudioContextRenderSizeCategoryOrWord
getRenderSizeHintUnchecked self = liftDOM (((self ^. js "renderSizeHint") >>= fromJSValUnchecked))