Module

WAGS.Control.Types

Package
purescript-wags
Repository
mikesol/purescript-wags

#Frame Source

type Frame (env :: Type) (audio :: Type) (engine :: Type) (proof :: Type) (res :: Type) (graph :: Type) (a :: Type) = env -> WAG audio engine proof res graph a

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.
  • 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.
  • graph: The Graph, meaning the current audio graph of the frame.
  • a: The term within the frame. This is often some form of accumulator that represents an evolving state over time.

#EFrame Source

type EFrame (env :: Type) (audio :: Type) (engine :: Type) (proof :: Type) (res :: Type) (graph :: Type) (a :: Type) = env -> Either (Scene env audio engine proof res) (WAG audio engine proof res graph a)

#WAG Source

newtype WAG (audio :: Type) (engine :: Type) (proof :: Type) (res :: Type) (graph :: Type) (a :: Type)

Instances

#AudioState' Source

type AudioState' audio (engine :: Type) res = { instructions :: Array (audio -> engine), res :: res }

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

#InitialGraph Source

type InitialGraph = Record ()

The Graph at which any scene starts.

#InitialFrame Source

type InitialFrame env audio engine res a = Frame env audio engine Frame0 res InitialGraph a

The FrameT at which any scene starts.

#InitialWAG Source

type InitialWAG audio engine res a = WAG audio engine Frame0 res InitialGraph a

#Frame0 Source

data Frame0

A proof term for the initial frame.

#Scene Source

newtype Scene env audio engine proofA res

Constructors

  • Scene (env -> (forall (proofB :: k). Scene' env audio engine proofB res))

#Scene' Source

type Scene' env audio engine proof res = { instructions :: Array (audio -> engine), next :: Scene env audio engine proof res, res :: res }

#oneFrame Source

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

#oneFrame' Source

oneFrame' :: forall env audio engine proofA res. Scene env audio engine proofA res -> env -> ((Array (audio -> engine)) /\ res /\ (Scene env audio engine proofA res))

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

#unsafeUnWAG Source

unsafeUnWAG :: forall audio engine proof res graph a. WAG audio engine proof res graph a -> { context :: AudioState' audio engine res, value :: a }

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

#unsafeWAG Source

unsafeWAG :: forall audio engine proof res graph a. { context :: AudioState' audio engine res, value :: a } -> WAG audio engine proof res graph a

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