# WAGS.Validation

- Package
- purescript-wags
- Repository
- mikesol/purescript-wags

Validation algorithms for audio graphs.

Validation includes making sure the graph is renderable by the web audio API and retrieving information about valid graphs, like their terminal node (ie a loudspeaker).

### #GraphIsRenderable Source

`class GraphIsRenderable (graph :: Graph) `

Asserts that an audio graph is renderable.

Every time that `makeScene`

is called, we assert that the graph is
renderable. This means that it can be played by the WebAudio API
without any runtime errors. Note that this assertion is a
*compile time* assertion and not a *runtime* assertion. This means that,
when your program is compiled, it is guaranteed to be renderable by
the WebAudio API *assuming that* it is within the memory constraints
of a given browser and computer. Usually, these memory limits are not
hit unless one has hundreds of active nodes.

#### Instances

`(NoNodesAreDuplicated graph, AllEdgesPointToNodes graph, NoParallelEdges graph, HasSourceNodes graph, UniqueTerminus graph name terminus, NodeIsOutputDevice terminus, AllNodesAreSaturated graph) => GraphIsRenderable graph`

### #TerminalNodeC Source

`class TerminalNodeC (g :: Graph) (ptr :: Symbol) | g -> ptr`

Retrieves the terminal node from an audio grpah. This is almost always a speaker or recording, but if the graph is at an intermediary stage of construction, this could be another top-level node, ie a gain node.

#### Instances

`(UniqueTerminus g sym t) => TerminalNodeC g sym`

### #NoNodesAreDuplicated Source

`class NoNodesAreDuplicated (graph :: Graph) `

#### Instances

`(Nub graph graph) => NoNodesAreDuplicated graph`

### #AllEdgesInGraph' Source

`class AllEdgesInGraph' (edgeProfile :: EdgeList) (graph :: Graph) `

Assert that all edges are present as nodes in a graph

#### Instances

`AllEdgesInGraph' Nil graph`

`(Cons sym node graph' graph, AllEdgesInGraph' rest graph) => AllEdgesInGraph' (Cons sym Unit rest) graph`

### #AllEdgesInGraph Source

`class AllEdgesInGraph (graphAsList :: NodeList) (graph :: Graph) `

Assert that all edges are present as nodes in a graph

#### Instances

`AllEdgesInGraph Nil graph`

`(RowToList edges edges', AllEdgesInGraph' edges' graph, AllEdgesInGraph rest graph) => AllEdgesInGraph (Cons sym (NodeC node (Record edges)) rest) graph`

### #AllEdgesPointToNodes Source

`class AllEdgesPointToNodes (graph :: Graph) `

Assertion that all edges in the graph point to a node in the graph.

#### Instances

`(RowToList graph nodeList, AllEdgesInGraph nodeList graph) => AllEdgesPointToNodes graph`

### #NoParallelEdgesNL Source

`class NoParallelEdgesNL (nodeList :: NodeList) `

Assertion that `nodeList`

contains no parallel edges. Parallel edges are two or more edges from `node1`

to `node2`

in a list of nodes.

#### Instances

`NoParallelEdgesNL Nil`

`(Nub r r) => NoParallelEdgesNL (Cons h (NodeC n (Record r)) tail)`

### #NoParallelEdges Source

`class NoParallelEdges (graph :: Graph) `

Assertion that `graph`

contains no parallel edges. Parallel edges are two or more edges from `node1`

to `node2`

in a list of nodes.

#### Instances

`(RowToList graph nodeList, NoParallelEdgesNL nodeList) => NoParallelEdges graph`

### #SourceNodes Source

`class SourceNodes (nodeList :: NodeList) (output :: NodeList) | nodeList -> output`

Tail-recursive lookup of all nodes in a graph without incoming edges.

`nodeList`

is the list of nodes that will be searched over.`output`

contains all nodes without incoming edges.

#### Instances

`SourceNodes Nil Nil`

`(RowToList edges edges', RowListEmpty edges' tf, SourceNodes rest out', Gate tf (Cons sym (NodeC node (Record edges)) out') out' out) => SourceNodes (Cons sym (NodeC node (Record edges)) rest) out`

### #HasSourceNodes Source

`class HasSourceNodes (graph :: Graph) `

Assertion that a graph has source nodes. Source nodes are nodes without incoming edges.

#### Instances

`(RowToList graph graph', SourceNodes graph' (Cons a b c)) => HasSourceNodes graph`

### #SymPresentInAtLeastOneEdge Source

`class SymPresentInAtLeastOneEdge (tf :: Type) (sym :: Symbol) (graphAsList :: RowList Type) (o :: Type) | tf sym graphAsList -> o`

#### Instances

`SymPresentInAtLeastOneEdge True sym graphAsList True`

`SymPresentInAtLeastOneEdge False sym Nil False`

`(RowToList edges edges', SymInRowList sym edges' tf, SymPresentInAtLeastOneEdge tf sym rest o) => SymPresentInAtLeastOneEdge False sym (Cons sym' (NodeC node (Record edges)) rest) o`

### #GetTerminii Source

`class GetTerminii (toVisit :: NodeList) (graphAsNodeList :: NodeList) (output :: NodeList) | toVisit graphAsNodeList -> output`

The algorithm that finds the terminal nodes of a graph.

#### Instances

`GetTerminii Nil graphAsNodeList Nil`

`(SymPresentInAtLeastOneEdge False sym graphAsList tf, GetTerminii rest graphAsList o, Gate tf o (Cons sym node o) oo) => GetTerminii (Cons sym node rest) graphAsList oo`

### #UniqueTerminus Source

`class UniqueTerminus (graph :: Graph) (sym :: Symbol) (node :: Type) | graph -> sym node`

Assertion that `graph`

has the unique terminus `node`

. Note that,
due to the fundep, the assertion also *finds* the unique terminus
if it exists.

#### Instances

`(RowToList graph graphAsList, GetTerminii graphAsList graphAsList (Cons sym node Nil)) => UniqueTerminus graph sym node`

### #HasUniqueTerminus Source

`class HasUniqueTerminus (graph :: Graph) `

Assertion that `graph`

has a unique terminus.

#### Instances

`(UniqueTerminus graph sym node) => HasUniqueTerminus graph`

### #AllNodesAreSaturatedNL Source

`class AllNodesAreSaturatedNL (graph :: NodeList) `

Asserts that all nodes in `graph`

are saturated.
"Saturation" for audio nodes is similar to the concept of saturation
in types, namely that they have all the information necessary to
render. In doing so, it also fails the assertion on degenerate nodes,
ie sine-wave oscillators with input (which wouldn't make sense).

#### Instances

`AllNodesAreSaturatedNL Nil`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TAllpass (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TBandpass (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TConstant (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC (TConvolver p0) (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TDelay (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TDynamicsCompressor (Record r)) tail)`

`(RowToList r (Cons aSym aVal next), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TGain (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC THighpass (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC THighshelf (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TLoopBuf (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TLowpass (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TLowshelf (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TMicrophone (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TNotch (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TPeaking (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TPeriodicOsc (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TPlayBuf (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC (TRecorder p0) (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TSawtoothOsc (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TSinOsc (Record r)) tail)`

`(RowToList r (Cons aSym aVal next), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TSpeaker (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TSquareOsc (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TStereoPanner (Record r)) tail)`

`(RowToList r Nil, AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC TTriangleOsc (Record r)) tail)`

`(RowToList r (Cons aSym aVal Nil), AllNodesAreSaturatedNL tail) => AllNodesAreSaturatedNL (Cons iSym (NodeC (TWaveShaper p0 p1) (Record r)) tail)`

### #AllNodesAreSaturated Source

`class AllNodesAreSaturated (graph :: Graph) `

Asserts that all nodes in `graph`

are saturated. This is
the same as the node-list algorithm, but for a graph.

#### Instances

`(RowToList graph nodeList, AllNodesAreSaturatedNL nodeList) => AllNodesAreSaturated graph`

### #NodeIsOutputDevice Source

`class NodeIsOutputDevice (node :: Type) `

Asserts the node is an output device. Currently, in the web-audio API, this is a loudspeaker or recorder.

#### Instances

`NodeIsOutputDevice (NodeC TSpeaker x)`

`NodeIsOutputDevice (NodeC (TRecorder name) x)`

- Modules
- FRP.
Event. MIDI - WAGS.
Change - WAGS.
Change. Optionals - WAGS.
Comonad - WAGS.
Connect - WAGS.
Control. Functions - WAGS.
Control. Functions. Validated - WAGS.
Control. Indexed - WAGS.
Control. Types - WAGS.
Create - WAGS.
Create. Optionals - WAGS.
CreateT - WAGS.
Debug - WAGS.
Destroy - WAGS.
Disconnect - WAGS.
Edgeable - WAGS.
Graph. AudioUnit - WAGS.
Graph. Edge - WAGS.
Graph. Graph - WAGS.
Graph. Node - WAGS.
Graph. Oversample - WAGS.
Graph. Paramable - WAGS.
Graph. Parameter - WAGS.
Interpret - WAGS.
Math - WAGS.
Patch - WAGS.
Rendered - WAGS.
Run - WAGS.
Util - WAGS.
Validation