{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.AudioBufferSourceNode
(start, stop, pattern UNSCHEDULED_STATE, pattern SCHEDULED_STATE,
pattern PLAYING_STATE, pattern FINISHED_STATE, setBuffer,
getBuffer, getBufferUnsafe, getBufferUnchecked, getPlaybackState,
getGain, getPlaybackRate, setLoop, getLoop, setLoopStart,
getLoopStart, setLoopEnd, getLoopEnd, ended,
AudioBufferSourceNode(..), gTypeAudioBufferSourceNode)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
start ::
(MonadDOM m) =>
AudioBufferSourceNode ->
Maybe Double -> Maybe Double -> Maybe Double -> m ()
start self when grainOffset grainDuration
= liftDOM
(void
(self ^. jsf "start"
[toJSVal when, toJSVal grainOffset, toJSVal grainDuration]))
stop ::
(MonadDOM m) => AudioBufferSourceNode -> Maybe Double -> m ()
stop self when = liftDOM (void (self ^. jsf "stop" [toJSVal when]))
pattern UNSCHEDULED_STATE = 0
pattern SCHEDULED_STATE = 1
pattern PLAYING_STATE = 2
pattern FINISHED_STATE = 3
setBuffer ::
(MonadDOM m) => AudioBufferSourceNode -> Maybe AudioBuffer -> m ()
setBuffer self val = liftDOM (self ^. jss "buffer" (toJSVal val))
getBuffer ::
(MonadDOM m) => AudioBufferSourceNode -> m (Maybe AudioBuffer)
getBuffer self = liftDOM ((self ^. js "buffer") >>= fromJSVal)
getBufferUnsafe ::
(MonadDOM m, HasCallStack) =>
AudioBufferSourceNode -> m AudioBuffer
getBufferUnsafe self
= liftDOM
(((self ^. js "buffer") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getBufferUnchecked ::
(MonadDOM m) => AudioBufferSourceNode -> m AudioBuffer
getBufferUnchecked self
= liftDOM ((self ^. js "buffer") >>= fromJSValUnchecked)
getPlaybackState :: (MonadDOM m) => AudioBufferSourceNode -> m Word
getPlaybackState self
= liftDOM
(round <$> ((self ^. js "playbackState") >>= valToNumber))
getGain :: (MonadDOM m) => AudioBufferSourceNode -> m AudioParam
getGain self = liftDOM ((self ^. js "gain") >>= fromJSValUnchecked)
getPlaybackRate ::
(MonadDOM m) => AudioBufferSourceNode -> m AudioParam
getPlaybackRate self
= liftDOM ((self ^. js "playbackRate") >>= fromJSValUnchecked)
setLoop :: (MonadDOM m) => AudioBufferSourceNode -> Bool -> m ()
setLoop self val = liftDOM (self ^. jss "loop" (toJSVal val))
getLoop :: (MonadDOM m) => AudioBufferSourceNode -> m Bool
getLoop self = liftDOM ((self ^. js "loop") >>= valToBool)
setLoopStart ::
(MonadDOM m) => AudioBufferSourceNode -> Double -> m ()
setLoopStart self val
= liftDOM (self ^. jss "loopStart" (toJSVal val))
getLoopStart :: (MonadDOM m) => AudioBufferSourceNode -> m Double
getLoopStart self
= liftDOM ((self ^. js "loopStart") >>= valToNumber)
setLoopEnd ::
(MonadDOM m) => AudioBufferSourceNode -> Double -> m ()
setLoopEnd self val = liftDOM (self ^. jss "loopEnd" (toJSVal val))
getLoopEnd :: (MonadDOM m) => AudioBufferSourceNode -> m Double
getLoopEnd self = liftDOM ((self ^. js "loopEnd") >>= valToNumber)
ended :: EventName AudioBufferSourceNode Event
ended = unsafeEventName (toJSString "ended")