{-# 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 :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode
-> Maybe Double -> Maybe Double -> Maybe Double -> m ()
start AudioBufferSourceNode
self Maybe Double
when Maybe Double
grainOffset Maybe Double
grainDuration
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"start"
[Maybe Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe Double
when, Maybe Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe Double
grainOffset, Maybe Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe Double
grainDuration]))
stop ::
(MonadDOM m) => AudioBufferSourceNode -> Maybe Double -> m ()
stop :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> Maybe Double -> m ()
stop AudioBufferSourceNode
self Maybe Double
when = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"stop" [Maybe Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe Double
when]))
pattern $mUNSCHEDULED_STATE :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bUNSCHEDULED_STATE :: forall {a}. (Eq a, Num a) => a
UNSCHEDULED_STATE = 0
pattern $mSCHEDULED_STATE :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bSCHEDULED_STATE :: forall {a}. (Eq a, Num a) => a
SCHEDULED_STATE = 1
pattern $mPLAYING_STATE :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bPLAYING_STATE :: forall {a}. (Eq a, Num a) => a
PLAYING_STATE = 2
pattern $mFINISHED_STATE :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bFINISHED_STATE :: forall {a}. (Eq a, Num a) => a
FINISHED_STATE = 3
setBuffer ::
(MonadDOM m) => AudioBufferSourceNode -> Maybe AudioBuffer -> m ()
setBuffer :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> Maybe AudioBuffer -> m ()
setBuffer AudioBufferSourceNode
self Maybe AudioBuffer
val = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (DOM ()) AudioBufferSourceNode (DOM ()) -> DOM ()
forall s a. s -> Getting a s a -> a
^. String
-> JSM JSVal
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
forall name val.
(ToJSString name, ToJSVal val) =>
name
-> val
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
jss String
"buffer" (Maybe AudioBuffer -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe AudioBuffer
val))
getBuffer ::
(MonadDOM m) => AudioBufferSourceNode -> m (Maybe AudioBuffer)
getBuffer :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> m (Maybe AudioBuffer)
getBuffer AudioBufferSourceNode
self = DOM (Maybe AudioBuffer) -> m (Maybe AudioBuffer)
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"buffer") JSM JSVal
-> (JSVal -> DOM (Maybe AudioBuffer)) -> DOM (Maybe AudioBuffer)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe AudioBuffer)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal)
getBufferUnsafe ::
(MonadDOM m, HasCallStack) =>
AudioBufferSourceNode -> m AudioBuffer
getBufferUnsafe :: forall (m :: * -> *).
(MonadDOM m, HasCallStack) =>
AudioBufferSourceNode -> m AudioBuffer
getBufferUnsafe AudioBufferSourceNode
self
= DOM AudioBuffer -> m AudioBuffer
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"buffer") JSM JSVal
-> (JSVal -> DOM (Maybe AudioBuffer)) -> DOM (Maybe AudioBuffer)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe AudioBuffer)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal) DOM (Maybe AudioBuffer)
-> (Maybe AudioBuffer -> DOM AudioBuffer) -> DOM AudioBuffer
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
DOM AudioBuffer
-> (AudioBuffer -> DOM AudioBuffer)
-> Maybe AudioBuffer
-> DOM AudioBuffer
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> DOM AudioBuffer
forall a. HasCallStack => String -> a
Prelude.error String
"Nothing to return") AudioBuffer -> DOM AudioBuffer
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return)
getBufferUnchecked ::
(MonadDOM m) => AudioBufferSourceNode -> m AudioBuffer
getBufferUnchecked :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> m AudioBuffer
getBufferUnchecked AudioBufferSourceNode
self
= DOM AudioBuffer -> m AudioBuffer
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"buffer") JSM JSVal -> (JSVal -> DOM AudioBuffer) -> DOM AudioBuffer
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM AudioBuffer
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
getPlaybackState :: (MonadDOM m) => AudioBufferSourceNode -> m Word
getPlaybackState :: forall (m :: * -> *). MonadDOM m => AudioBufferSourceNode -> m Word
getPlaybackState AudioBufferSourceNode
self
= DOM Word -> m Word
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(Double -> Word
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Word) -> JSM Double -> DOM Word
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"playbackState") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))
getGain :: (MonadDOM m) => AudioBufferSourceNode -> m AudioParam
getGain :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> m AudioParam
getGain AudioBufferSourceNode
self = DOM AudioParam -> m AudioParam
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"gain") JSM JSVal -> (JSVal -> DOM AudioParam) -> DOM AudioParam
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM AudioParam
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
getPlaybackRate ::
(MonadDOM m) => AudioBufferSourceNode -> m AudioParam
getPlaybackRate :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> m AudioParam
getPlaybackRate AudioBufferSourceNode
self
= DOM AudioParam -> m AudioParam
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"playbackRate") JSM JSVal -> (JSVal -> DOM AudioParam) -> DOM AudioParam
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM AudioParam
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
setLoop :: (MonadDOM m) => AudioBufferSourceNode -> Bool -> m ()
setLoop :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> Bool -> m ()
setLoop AudioBufferSourceNode
self Bool
val = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (DOM ()) AudioBufferSourceNode (DOM ()) -> DOM ()
forall s a. s -> Getting a s a -> a
^. String
-> JSM JSVal
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
forall name val.
(ToJSString name, ToJSVal val) =>
name
-> val
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
jss String
"loop" (Bool -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Bool
val))
getLoop :: (MonadDOM m) => AudioBufferSourceNode -> m Bool
getLoop :: forall (m :: * -> *). MonadDOM m => AudioBufferSourceNode -> m Bool
getLoop AudioBufferSourceNode
self = DOM Bool -> m Bool
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"loop") JSM JSVal -> (JSVal -> DOM Bool) -> DOM Bool
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM Bool
forall value. ToJSVal value => value -> DOM Bool
valToBool)
setLoopStart ::
(MonadDOM m) => AudioBufferSourceNode -> Double -> m ()
setLoopStart :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> Double -> m ()
setLoopStart AudioBufferSourceNode
self Double
val
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (DOM ()) AudioBufferSourceNode (DOM ()) -> DOM ()
forall s a. s -> Getting a s a -> a
^. String
-> JSM JSVal
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
forall name val.
(ToJSString name, ToJSVal val) =>
name
-> val
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
jss String
"loopStart" (Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Double
val))
getLoopStart :: (MonadDOM m) => AudioBufferSourceNode -> m Double
getLoopStart :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> m Double
getLoopStart AudioBufferSourceNode
self
= JSM Double -> m Double
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"loopStart") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber)
setLoopEnd ::
(MonadDOM m) => AudioBufferSourceNode -> Double -> m ()
setLoopEnd :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> Double -> m ()
setLoopEnd AudioBufferSourceNode
self Double
val = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (DOM ()) AudioBufferSourceNode (DOM ()) -> DOM ()
forall s a. s -> Getting a s a -> a
^. String
-> JSM JSVal
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
forall name val.
(ToJSString name, ToJSVal val) =>
name
-> val
-> forall o. MakeObject o => IndexPreservingGetter o (DOM ())
jss String
"loopEnd" (Double -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Double
val))
getLoopEnd :: (MonadDOM m) => AudioBufferSourceNode -> m Double
getLoopEnd :: forall (m :: * -> *).
MonadDOM m =>
AudioBufferSourceNode -> m Double
getLoopEnd AudioBufferSourceNode
self = JSM Double -> m Double
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((AudioBufferSourceNode
self AudioBufferSourceNode
-> Getting (JSM JSVal) AudioBufferSourceNode (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter AudioBufferSourceNode (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"loopEnd") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber)
ended :: EventName AudioBufferSourceNode Event
ended :: EventName AudioBufferSourceNode Event
ended = DOMString -> EventName AudioBufferSourceNode Event
forall t e. DOMString -> EventName t e
unsafeEventName (String -> DOMString
forall a. ToJSString a => a -> DOMString
toJSString String
"ended")