{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.AudioContext
(newAudioContext, suspend, resume, close, createBuffer,
createBuffer_, createBufferFromArrayBuffer,
createBufferFromArrayBuffer_, decodeAudioData, createBufferSource,
createBufferSource_, createMediaElementSource,
createMediaElementSource_, createMediaStreamSource,
createMediaStreamSource_, createMediaStreamDestination,
createMediaStreamDestination_, createGain, createGain_,
createDelay, createDelay_, createBiquadFilter, createBiquadFilter_,
createWaveShaper, createWaveShaper_, createPanner, createPanner_,
createConvolver, createConvolver_, createDynamicsCompressor,
createDynamicsCompressor_, createAnalyser, createAnalyser_,
createScriptProcessor, createScriptProcessor_, createOscillator,
createOscillator_, createPeriodicWave, createPeriodicWave_,
createChannelSplitter, createChannelSplitter_, createChannelMerger,
createChannelMerger_, startRendering, getDestination,
getCurrentTime, getSampleRate, getListener, getState, statechange,
getActiveSourceCount, complete, AudioContext(..),
gTypeAudioContext, IsAudioContext, toAudioContext)
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
newAudioContext :: (MonadDOM m) => m AudioContext
newAudioContext
= liftDOM (AudioContext <$> new (jsg "AudioContext") ())
suspend :: (MonadDOM m, IsAudioContext self) => self -> m ()
suspend self
= liftDOM
(void
(((toAudioContext self) ^. jsf "suspend" ()) >>= readPromise))
resume :: (MonadDOM m, IsAudioContext self) => self -> m ()
resume self
= liftDOM
(void (((toAudioContext self) ^. jsf "resume" ()) >>= readPromise))
close :: (MonadDOM m, IsAudioContext self) => self -> m ()
close self
= liftDOM
(void (((toAudioContext self) ^. jsf "close" ()) >>= readPromise))
createBuffer ::
(MonadDOM m, IsAudioContext self) =>
self -> Word -> Word -> Float -> m AudioBuffer
createBuffer self numberOfChannels numberOfFrames sampleRate
= liftDOM
(((toAudioContext self) ^. jsf "createBuffer"
[toJSVal numberOfChannels, toJSVal numberOfFrames,
toJSVal sampleRate])
>>= fromJSValUnchecked)
createBuffer_ ::
(MonadDOM m, IsAudioContext self) =>
self -> Word -> Word -> Float -> m ()
createBuffer_ self numberOfChannels numberOfFrames sampleRate
= liftDOM
(void
((toAudioContext self) ^. jsf "createBuffer"
[toJSVal numberOfChannels, toJSVal numberOfFrames,
toJSVal sampleRate]))
createBufferFromArrayBuffer ::
(MonadDOM m, IsAudioContext self, IsArrayBuffer buffer) =>
self -> buffer -> Bool -> m AudioBuffer
createBufferFromArrayBuffer self buffer mixToMono
= liftDOM
(((toAudioContext self) ^. jsf "createBuffer"
[toJSVal buffer, toJSVal mixToMono])
>>= fromJSValUnchecked)
createBufferFromArrayBuffer_ ::
(MonadDOM m, IsAudioContext self, IsArrayBuffer buffer) =>
self -> buffer -> Bool -> m ()
createBufferFromArrayBuffer_ self buffer mixToMono
= liftDOM
(void
((toAudioContext self) ^. jsf "createBuffer"
[toJSVal buffer, toJSVal mixToMono]))
decodeAudioData ::
(MonadDOM m, IsAudioContext self, IsArrayBuffer audioData) =>
self ->
audioData ->
Maybe AudioBufferCallback -> Maybe AudioBufferCallback -> m ()
decodeAudioData self audioData successCallback errorCallback
= liftDOM
(void
((toAudioContext self) ^. jsf "decodeAudioData"
[toJSVal audioData, toJSVal successCallback,
toJSVal errorCallback]))
createBufferSource ::
(MonadDOM m, IsAudioContext self) =>
self -> m AudioBufferSourceNode
createBufferSource self
= liftDOM
(((toAudioContext self) ^. jsf "createBufferSource" ()) >>=
fromJSValUnchecked)
createBufferSource_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createBufferSource_ self
= liftDOM
(void ((toAudioContext self) ^. jsf "createBufferSource" ()))
createMediaElementSource ::
(MonadDOM m, IsAudioContext self,
IsHTMLMediaElement mediaElement) =>
self -> mediaElement -> m MediaElementAudioSourceNode
createMediaElementSource self mediaElement
= liftDOM
(((toAudioContext self) ^. jsf "createMediaElementSource"
[toJSVal mediaElement])
>>= fromJSValUnchecked)
createMediaElementSource_ ::
(MonadDOM m, IsAudioContext self,
IsHTMLMediaElement mediaElement) =>
self -> mediaElement -> m ()
createMediaElementSource_ self mediaElement
= liftDOM
(void
((toAudioContext self) ^. jsf "createMediaElementSource"
[toJSVal mediaElement]))
createMediaStreamSource ::
(MonadDOM m, IsAudioContext self) =>
self -> MediaStream -> m MediaStreamAudioSourceNode
createMediaStreamSource self mediaStream
= liftDOM
(((toAudioContext self) ^. jsf "createMediaStreamSource"
[toJSVal mediaStream])
>>= fromJSValUnchecked)
createMediaStreamSource_ ::
(MonadDOM m, IsAudioContext self) => self -> MediaStream -> m ()
createMediaStreamSource_ self mediaStream
= liftDOM
(void
((toAudioContext self) ^. jsf "createMediaStreamSource"
[toJSVal mediaStream]))
createMediaStreamDestination ::
(MonadDOM m, IsAudioContext self) =>
self -> m MediaStreamAudioDestinationNode
createMediaStreamDestination self
= liftDOM
(((toAudioContext self) ^. jsf "createMediaStreamDestination" ())
>>= fromJSValUnchecked)
createMediaStreamDestination_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createMediaStreamDestination_ self
= liftDOM
(void
((toAudioContext self) ^. jsf "createMediaStreamDestination" ()))
createGain ::
(MonadDOM m, IsAudioContext self) => self -> m GainNode
createGain self
= liftDOM
(((toAudioContext self) ^. jsf "createGain" ()) >>=
fromJSValUnchecked)
createGain_ :: (MonadDOM m, IsAudioContext self) => self -> m ()
createGain_ self
= liftDOM (void ((toAudioContext self) ^. jsf "createGain" ()))
createDelay ::
(MonadDOM m, IsAudioContext self) =>
self -> Maybe Double -> m DelayNode
createDelay self maxDelayTime
= liftDOM
(((toAudioContext self) ^. jsf "createDelay"
[toJSVal maxDelayTime])
>>= fromJSValUnchecked)
createDelay_ ::
(MonadDOM m, IsAudioContext self) => self -> Maybe Double -> m ()
createDelay_ self maxDelayTime
= liftDOM
(void
((toAudioContext self) ^. jsf "createDelay"
[toJSVal maxDelayTime]))
createBiquadFilter ::
(MonadDOM m, IsAudioContext self) => self -> m BiquadFilterNode
createBiquadFilter self
= liftDOM
(((toAudioContext self) ^. jsf "createBiquadFilter" ()) >>=
fromJSValUnchecked)
createBiquadFilter_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createBiquadFilter_ self
= liftDOM
(void ((toAudioContext self) ^. jsf "createBiquadFilter" ()))
createWaveShaper ::
(MonadDOM m, IsAudioContext self) => self -> m WaveShaperNode
createWaveShaper self
= liftDOM
(((toAudioContext self) ^. jsf "createWaveShaper" ()) >>=
fromJSValUnchecked)
createWaveShaper_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createWaveShaper_ self
= liftDOM
(void ((toAudioContext self) ^. jsf "createWaveShaper" ()))
createPanner ::
(MonadDOM m, IsAudioContext self) => self -> m PannerNode
createPanner self
= liftDOM
(((toAudioContext self) ^. jsf "createPanner" ()) >>=
fromJSValUnchecked)
createPanner_ :: (MonadDOM m, IsAudioContext self) => self -> m ()
createPanner_ self
= liftDOM (void ((toAudioContext self) ^. jsf "createPanner" ()))
createConvolver ::
(MonadDOM m, IsAudioContext self) => self -> m ConvolverNode
createConvolver self
= liftDOM
(((toAudioContext self) ^. jsf "createConvolver" ()) >>=
fromJSValUnchecked)
createConvolver_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createConvolver_ self
= liftDOM
(void ((toAudioContext self) ^. jsf "createConvolver" ()))
createDynamicsCompressor ::
(MonadDOM m, IsAudioContext self) =>
self -> m DynamicsCompressorNode
createDynamicsCompressor self
= liftDOM
(((toAudioContext self) ^. jsf "createDynamicsCompressor" ()) >>=
fromJSValUnchecked)
createDynamicsCompressor_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createDynamicsCompressor_ self
= liftDOM
(void ((toAudioContext self) ^. jsf "createDynamicsCompressor" ()))
createAnalyser ::
(MonadDOM m, IsAudioContext self) => self -> m AnalyserNode
createAnalyser self
= liftDOM
(((toAudioContext self) ^. jsf "createAnalyser" ()) >>=
fromJSValUnchecked)
createAnalyser_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createAnalyser_ self
= liftDOM (void ((toAudioContext self) ^. jsf "createAnalyser" ()))
createScriptProcessor ::
(MonadDOM m, IsAudioContext self) =>
self -> Word -> Maybe Word -> Maybe Word -> m ScriptProcessorNode
createScriptProcessor self bufferSize numberOfInputChannels
numberOfOutputChannels
= liftDOM
(((toAudioContext self) ^. jsf "createScriptProcessor"
[toJSVal bufferSize, toJSVal numberOfInputChannels,
toJSVal numberOfOutputChannels])
>>= fromJSValUnchecked)
createScriptProcessor_ ::
(MonadDOM m, IsAudioContext self) =>
self -> Word -> Maybe Word -> Maybe Word -> m ()
createScriptProcessor_ self bufferSize numberOfInputChannels
numberOfOutputChannels
= liftDOM
(void
((toAudioContext self) ^. jsf "createScriptProcessor"
[toJSVal bufferSize, toJSVal numberOfInputChannels,
toJSVal numberOfOutputChannels]))
createOscillator ::
(MonadDOM m, IsAudioContext self) => self -> m OscillatorNode
createOscillator self
= liftDOM
(((toAudioContext self) ^. jsf "createOscillator" ()) >>=
fromJSValUnchecked)
createOscillator_ ::
(MonadDOM m, IsAudioContext self) => self -> m ()
createOscillator_ self
= liftDOM
(void ((toAudioContext self) ^. jsf "createOscillator" ()))
createPeriodicWave ::
(MonadDOM m, IsAudioContext self, IsFloat32Array real,
IsFloat32Array imag) =>
self -> real -> imag -> m PeriodicWave
createPeriodicWave self real imag
= liftDOM
(((toAudioContext self) ^. jsf "createPeriodicWave"
[toJSVal real, toJSVal imag])
>>= fromJSValUnchecked)
createPeriodicWave_ ::
(MonadDOM m, IsAudioContext self, IsFloat32Array real,
IsFloat32Array imag) =>
self -> real -> imag -> m ()
createPeriodicWave_ self real imag
= liftDOM
(void
((toAudioContext self) ^. jsf "createPeriodicWave"
[toJSVal real, toJSVal imag]))
createChannelSplitter ::
(MonadDOM m, IsAudioContext self) =>
self -> Maybe Word -> m ChannelSplitterNode
createChannelSplitter self numberOfOutputs
= liftDOM
(((toAudioContext self) ^. jsf "createChannelSplitter"
[toJSVal numberOfOutputs])
>>= fromJSValUnchecked)
createChannelSplitter_ ::
(MonadDOM m, IsAudioContext self) => self -> Maybe Word -> m ()
createChannelSplitter_ self numberOfOutputs
= liftDOM
(void
((toAudioContext self) ^. jsf "createChannelSplitter"
[toJSVal numberOfOutputs]))
createChannelMerger ::
(MonadDOM m, IsAudioContext self) =>
self -> Maybe Word -> m ChannelMergerNode
createChannelMerger self numberOfInputs
= liftDOM
(((toAudioContext self) ^. jsf "createChannelMerger"
[toJSVal numberOfInputs])
>>= fromJSValUnchecked)
createChannelMerger_ ::
(MonadDOM m, IsAudioContext self) => self -> Maybe Word -> m ()
createChannelMerger_ self numberOfInputs
= liftDOM
(void
((toAudioContext self) ^. jsf "createChannelMerger"
[toJSVal numberOfInputs]))
startRendering :: (MonadDOM m, IsAudioContext self) => self -> m ()
startRendering self
= liftDOM (void ((toAudioContext self) ^. jsf "startRendering" ()))
getDestination ::
(MonadDOM m, IsAudioContext self) => self -> m AudioDestinationNode
getDestination self
= liftDOM
(((toAudioContext self) ^. js "destination") >>=
fromJSValUnchecked)
getCurrentTime ::
(MonadDOM m, IsAudioContext self) => self -> m Double
getCurrentTime self
= liftDOM
(((toAudioContext self) ^. js "currentTime") >>= valToNumber)
getSampleRate ::
(MonadDOM m, IsAudioContext self) => self -> m Float
getSampleRate self
= liftDOM
(realToFrac <$>
(((toAudioContext self) ^. js "sampleRate") >>= valToNumber))
getListener ::
(MonadDOM m, IsAudioContext self) => self -> m AudioListener
getListener self
= liftDOM
(((toAudioContext self) ^. js "listener") >>= fromJSValUnchecked)
getState ::
(MonadDOM m, IsAudioContext self) => self -> m AudioContextState
getState self
= liftDOM
(((toAudioContext self) ^. js "state") >>= fromJSValUnchecked)
statechange ::
(IsAudioContext self, IsEventTarget self) =>
EventName self onstatechange
statechange = unsafeEventName (toJSString "statechange")
getActiveSourceCount ::
(MonadDOM m, IsAudioContext self) => self -> m Word
getActiveSourceCount self
= liftDOM
(round <$>
(((toAudioContext self) ^. js "activeSourceCount") >>=
valToNumber))
complete ::
(IsAudioContext self, IsEventTarget self) =>
EventName self OfflineAudioCompletionEvent
complete = unsafeEventName (toJSString "complete")