jsaddle-dom-0.10.0.0: src/JSDOM/Generated/OscillatorOptions.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.OscillatorOptions
(newOscillatorOptions, setType, getType, getTypeUnsafe, getTypeUnchecked, setFrequency, getFrequency, getFrequencyUnsafe, getFrequencyUnchecked, setDetune, getDetune, getDetuneUnsafe, getDetuneUnchecked, setPeriodicWave, getPeriodicWave, getPeriodicWaveUnsafe, getPeriodicWaveUnchecked, OscillatorOptions(..), gTypeOscillatorOptions)
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/#OscillatorOptions OscillatorOptions specification>
newOscillatorOptions :: (MonadDOM m) => m OscillatorOptions
newOscillatorOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-type OscillatorOptions.type specification>
setType :: (MonadDOM m) => OscillatorOptions -> OscillatorType -> m ()
setType self val = liftDOM (void (self ^. jss "type" (toJSVal val)))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-type OscillatorOptions.type specification>
getType :: (MonadDOM m) => OscillatorOptions -> m (Maybe OscillatorType)
getType self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-type OscillatorOptions.type specification>
getTypeUnsafe :: (MonadDOM m, HasCallStack) => OscillatorOptions -> m OscillatorType
getTypeUnsafe self = liftDOM ((((self ^. js "type") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-type OscillatorOptions.type specification>
getTypeUnchecked :: (MonadDOM m) => OscillatorOptions -> m OscillatorType
getTypeUnchecked self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-frequency OscillatorOptions.frequency specification>
setFrequency :: (MonadDOM m) => OscillatorOptions -> Float -> m ()
setFrequency self val = liftDOM (void (self ^. jss "frequency" (toJSVal val)))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-frequency OscillatorOptions.frequency specification>
getFrequency :: (MonadDOM m) => OscillatorOptions -> m (Maybe Float)
getFrequency self = liftDOM (((self ^. js "frequency") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-frequency OscillatorOptions.frequency specification>
getFrequencyUnsafe :: (MonadDOM m, HasCallStack) => OscillatorOptions -> m Float
getFrequencyUnsafe self = liftDOM ((((self ^. js "frequency") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-frequency OscillatorOptions.frequency specification>
getFrequencyUnchecked :: (MonadDOM m) => OscillatorOptions -> m Float
getFrequencyUnchecked self = liftDOM ((P.realToFrac <$> ((self ^. js "frequency") >>= valToNumber)))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-detune OscillatorOptions.detune specification>
setDetune :: (MonadDOM m) => OscillatorOptions -> Float -> m ()
setDetune self val = liftDOM (void (self ^. jss "detune" (toJSVal val)))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-detune OscillatorOptions.detune specification>
getDetune :: (MonadDOM m) => OscillatorOptions -> m (Maybe Float)
getDetune self = liftDOM (((self ^. js "detune") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-detune OscillatorOptions.detune specification>
getDetuneUnsafe :: (MonadDOM m, HasCallStack) => OscillatorOptions -> m Float
getDetuneUnsafe self = liftDOM ((((self ^. js "detune") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-detune OscillatorOptions.detune specification>
getDetuneUnchecked :: (MonadDOM m) => OscillatorOptions -> m Float
getDetuneUnchecked self = liftDOM ((P.realToFrac <$> ((self ^. js "detune") >>= valToNumber)))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-periodicwave OscillatorOptions.periodicWave specification>
setPeriodicWave :: (MonadDOM m) => OscillatorOptions -> PeriodicWave -> m ()
setPeriodicWave self val = liftDOM (void (self ^. jss "periodicWave" (toJSVal val)))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-periodicwave OscillatorOptions.periodicWave specification>
getPeriodicWave :: (MonadDOM m) => OscillatorOptions -> m (Maybe PeriodicWave)
getPeriodicWave self = liftDOM (((self ^. js "periodicWave") >>= fromJSValUnchecked))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-periodicwave OscillatorOptions.periodicWave specification>
getPeriodicWaveUnsafe :: (MonadDOM m, HasCallStack) => OscillatorOptions -> m PeriodicWave
getPeriodicWaveUnsafe self = liftDOM ((((self ^. js "periodicWave") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://webaudio.github.io/web-audio-api/#dom-oscillatoroptions-periodicwave OscillatorOptions.periodicWave specification>
getPeriodicWaveUnchecked :: (MonadDOM m) => OscillatorOptions -> m PeriodicWave
getPeriodicWaveUnchecked self = liftDOM (((self ^. js "periodicWave") >>= fromJSValUnchecked))