Module

WAGS.Control.Types

Package
purescript-wags
Repository
mikesol/purescript-wags

#FrameT Source

newtype FrameT (env :: Type) (audio :: Type) (engine :: Type) (proof :: Type) (m :: Type -> Type) (res :: Type) (iu :: Universe) (ou :: Universe) (a :: Type)

Represents a single frame of an audio scene. Conceptually, this is a snapshot in time of audio.

  • env: The outside environment influencing audio. Contains things like mouse clicks, the current time, and MIDI events.
  • audio: The audio context. This is Unit when testing and FFIAudio when rendering actual audio.
  • engine: The type output by the audio rendering engine. This is Instruction when testing and Effect Unit when rendering actual audio.
  • proof: A proof term representing the current moment in time. proof is a type-safe way to make sure that a frame at time n is not composed (ie via bind) with a frame at time n + 1.
  • m: The underlying monad in which the information of the frame lies. Usually this is Thunkable but can also be Identity or Aff depending on your use case.
  • res: A monoid containing a residual from the audio computation. Use this if you need to pass computations from an audio graph to downstream consumers. In general, it is best if computations happen before audio graph rendering, so it's best to use res only in cases where a computation is dependent on values that can only be calculated in the audio-graph, ie scheduling based on the audio clock.
  • iu: The input Universe, meaning the state of the frame before a computation.
  • ou: The output Universe, meaning the state of the frame after a computation.
  • a: The term within the frame. This is often some form of accumulator that represents an evolving state over time.

NB: FrameT does not implement IxApplicative because we never want to be able to pull a proof term out of thin air. It does, however, have a bind operation in WAGS.Control.Qualified that can is used for rebindable do notation in all of the tests and examples.

Instances

#Frame Source

type Frame (env :: Type) (audio :: Type) (engine :: Type) (proof :: Type) (iu :: Universe) (ou :: Universe) (a :: Type) = FrameT env audio engine proof Thunkable Unit iu ou a

A FrameT specialized to the Thunkable monad.

#AudioState Source

type AudioState env audio engine proof m res a = (MemoizedStateT proof (AudioState' env audio engine res) m) a

Type used for the internal representation of the current audio state.

#AudioState' Source

type AudioState' env audio (engine :: Type) res = { currentIdx :: Int, env :: env, instructions :: Array (audio -> engine), internalEdges :: Map Int (Set Int), internalNodes :: Map Int (AnAudioUnit), res :: res }

Type used for the internal representation of the current audio state.

#InitialUniverse Source

type InitialUniverse = UniverseC D0 InitialGraph Z SkolemListNil

The Universe at which any scene starts.

#InitialFrameT Source

type InitialFrameT env audio engine m res a = FrameT env audio engine Frame0 m res InitialUniverse InitialUniverse a

The FrameT at which any scene starts.

#InitialFrame Source

type InitialFrame env audio engine a = Frame env audio engine Frame0 InitialUniverse InitialUniverse a

The Frame at which any scene starts.

#Frame0 Source

data Frame0

A proof term for the initial frame.

#SceneT Source

data SceneT env audio engine proof m res

Constructors

#SceneT' Source

type SceneT' env audio engine proof m res = { edges :: Map Int (Set Int), instructions :: Array (audio -> engine), next :: SceneT env audio engine proof m res, nodes :: Map Int AnAudioUnit, res :: res }

#Scene Source

type Scene env audio engine proof = SceneT env audio engine proof Thunkable Unit

#Scene' Source

type Scene' env audio engine proof = SceneT' env audio engine proof Thunkable Unit

#Universe' Source

type Universe' currentIndex graph cb = UniverseC currentIndex graph cb SkolemListNil

A type constructor for a graph with no changes and no skolems

#oneFrame Source

oneFrame :: forall env audio engine proofA. Scene env audio engine proofA -> env -> (forall proofB. Scene' env audio engine proofB)

oneFrame is oneFrameT specialized for the Thunkable monad.

#oneFrame' Source

oneFrame' :: forall env audio engine proofA. Scene env audio engine proofA -> env -> (forall proofB. ((Map Int AnAudioUnit) /\ (Map Int (Set Int)) /\ (Array (audio -> engine)) /\ Unit /\ (Scene env audio engine proofB)))

This represents the output of oneFrame as a tuple instead of a record.

#oneFrameT Source

oneFrameT :: forall env audio engine proofA m res. Monad m => SceneT env audio engine proofA m res -> env -> (forall proofB. m (SceneT' env audio engine proofB m res))

Given an env, gets the next SceneT' from a SceneT.

#oneFrameT' Source

oneFrameT' :: forall env audio engine proofA m res. Monad m => SceneT env audio engine proofA m res -> env -> (forall proofB. m ((Map Int AnAudioUnit) /\ (Map Int (Set Int)) /\ (Array (audio -> engine)) /\ res /\ (SceneT env audio engine proofB m res)))

This represents the output of oneFrameT as a tuple instead of a record.

#unsafeUnframe Source

unsafeUnframe :: forall env audio engine proof m res iu ou a. FrameT env audio engine proof m res iu ou a -> AudioState env audio engine proof m res a

"For office use only" way to access the innards of a frame. Obliterates type safety. Use at your own risk.

#unsafeFrame Source

unsafeFrame :: forall env audio engine proof m res iu ou a. AudioState env audio engine proof m res a -> FrameT env audio engine proof m res iu ou a

"For office use only" way to construct a frame. Obliterates type safety. Use at your own risk.