Module

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

#TerminalNode Source

class TerminalNode (g :: Graph) (ptr :: Ptr) | 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

#TerminalIdentityEdge Source

class TerminalIdentityEdge (u :: Graph) (prof :: EdgeProfile) | u -> prof

Retrieves the terminal node from an audio grpah as an edge profile - in this case, a single edge into the terminal node.

Instances

#LookupNL Source

class LookupNL (accumulator :: NodeList) (ptr :: Ptr) (graph :: NodeList) (node :: NodeList) | accumulator ptr graph -> node

Tail recursive lookup of a node in a node list.

  • accumulator: the accumulator for tail recursion that should start at NodeListNil.
  • ptr: the pointer of the node we are trying retrieve.
  • graph: the list of nodes to iterate over.
  • node: a list of nodes that have this pointer.

Instances

#NodeNotInNodeList Source

class NodeNotInNodeList (node :: Node) (nodeList :: NodeList) 

Assertion that node is not present in nodeList.

Instances

#NoNodesAreDuplicatedInNodeList Source

class NoNodesAreDuplicatedInNodeList (nodeList :: NodeList) 

Assertion that there are no duplicate nodes in nodeList.

Instances

#NoNodesAreDuplicated Source

class NoNodesAreDuplicated (graph :: Graph) 

Assertion that there are no duplicate nodes in graph.

Instances

#PtrInPtrList Source

class PtrInPtrList (foundPtr :: Type) (ptr :: Ptr) (ptrList :: PtrList) (output :: Type) | foundPtr ptr ptrList -> output

Tail-recursive check that a pointer is in a pointer list.

  • foundPtr: an accumulator indicating whether we've found the ptr or not. Starts as False.
  • ptr: is this ptr in the pointer list?
  • ptrList: a list of pointers
  • output: True if the pointer is in the list, False otherwise.

Instances

#AudioUnitInAudioUnitList Source

class AudioUnitInAudioUnitList (foundAU :: Type) (audioUnit :: AudioUnit) (audioUnitList :: AudioUnitList) (output :: Type) | foundAU audioUnit audioUnitList -> output

Tail-recursive check that an audio unit is in an audio unit list.

  • foundPtr: an accumulator indicating whether we've found the audio unit or not. Starts as False.
  • audioUnit: is this audioUnit in the audio unit list?
  • audioUnitList: a list of audio units
  • output: True if the audio unit is in the list, False otherwise.

Instances

#AllPtrsInNodeList Source

class AllPtrsInNodeList (pointers :: PtrList) (nodeList :: NodeList) 

Assertion that all pointers are present in a nodeList.

Instances

#GetEdgesAsPtrList Source

class GetEdgesAsPtrList (node :: Node) (ptrList :: PtrList) | node -> ptrList

For a given node, get all of its incoming edges as a ptrList.

Instances

#AllEdgesInNodeList Source

class AllEdgesInNodeList (needles :: NodeList) (haystack :: NodeList) 

For a given set of nodes called needles, assert that all of them are present in at least one incoming edge of the nodes called haystack.

Instances

#AllEdgesPointToNodes Source

class AllEdgesPointToNodes (graph :: Graph) 

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

Instances

#PtrNotInPtrList Source

class PtrNotInPtrList (ptr :: Ptr) (ptrList :: PtrList) 

Assertion that ptr is not in ptrList.

Instances

#NoPtrsAreDuplicatedInPtrList Source

class NoPtrsAreDuplicatedInPtrList (ptrList :: PtrList) 

Assertion that not pointers are duplicated in ptrList.

Instances

#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

#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

#SourceNodesNL Source

class SourceNodesNL (accumulator :: NodeList) (nodeList :: NodeList) (output :: NodeList) | accumulator nodeList -> output

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

  • accumulator is the accumulator that will be returned.
  • nodeList is the list of nodes that will be searched over.
  • output contains all nodes without incoming edges.

Instances

#SourceNodes Source

class SourceNodes (graph :: Graph) (nodeList :: NodeList) | graph -> nodeList

Lookup of all nodes in graph without incoming edges and return them as nodeList.

Instances

#HasSourceNodes Source

class HasSourceNodes (graph :: Graph) 

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

Instances

#AudioUnitInNodeList Source

class AudioUnitInNodeList (foundNode :: Type) (audioUnit :: AudioUnit) (nodeList :: NodeList) (output :: Type) | foundNode audioUnit nodeList -> output

Tail-recursive lookup of audio unit in node list.

  • foundNode: an accumulator indicating whether we've found the node or not. Starts as False.
  • audioUnit: is this audioUnit in the node list?
  • nodeList: a list of nodes
  • output: True if the audio unit is in the list, False otherwise.

Instances

#RemoveDuplicates Source

class RemoveDuplicates (accumulator :: NodeList) (maybeWithDuplicates :: NodeList) (output :: NodeList) | accumulator maybeWithDuplicates -> output

Tail-recursive removal of duplicate nodes from a node list.

  • accumulator: the accumulating deduped list. Starts at NodeListNil.
  • maybeWithDuplicates: a node list that potentially has duplicates.
  • output: the final deduped list

Instances

#NodeInNodeList Source

class NodeInNodeList (foundNode :: Type) (node :: Node) (nodeList :: NodeList) (output :: Type) | foundNode node nodeList -> output

Tail-recursive lookup of node in a node list.

  • foundNode: an accumulator indicating whether we've found the node or not. Starts as False.
  • node: is this node in the node list?
  • nodeList: a list of nodes
  • output: True if the node is in the list, False otherwise.

Instances

#UnvisitedNodes Source

class UnvisitedNodes (visited :: NodeList) (accumulator :: NodeList) (candidates :: NodeList) (unvisited :: NodeList) | visited accumulator candidates -> unvisited

Tail-recursive algorithm to find nodes we have not visited yet.

  • visited nodes that we have visited
  • accumulator accumulates unvisited nodes
  • candidates are nodes that have potentially not been visited yet and will be cross-referenced against visited.
  • unvisited is a list of unvisited nodes.

Instances

#ToVisitSingle Source

class ToVisitSingle (accumulator :: NodeList) (graph :: NodeList) (findMeInAnEdge :: Node) (candidates :: NodeList) | accumulator graph findMeInAnEdge -> candidates

In the node-visiting algorithm, this is a single step where we look for a node in a given list of edges. This step is repeated until all of the nodes have been visited.

  • accumulator - the running accumulator of nodes we are visiting
  • graph - the entire graph. if we were using an env comonad, this would be the environment
  • findMeInAnEdge - this is the node we want to find in edges
  • candidates - these are all of the nodes that have findMeInAnEdge as an incoming connection

Instances

#NodeListAppend Source

class NodeListAppend (l :: NodeList) (r :: NodeList) (o :: NodeList) | l r -> o

This appends node list l and r to produce the result o.

Instances

#PtrListAppend Source

class PtrListAppend (l :: PtrList) (r :: PtrList) (o :: PtrList) | l r -> o

This appends pointer list l and r to produce the result o.

Instances

#AltEdgeProfile Source

class AltEdgeProfile (a :: EdgeProfile) (b :: EdgeProfile) (c :: EdgeProfile) | a b -> c

This is the equivalent of Alt for edge profiles. NoEdge always loses.

Instances

#IsNodeListEmpty Source

class IsNodeListEmpty (nodeList :: NodeList) (tf :: Type) | nodeList -> tf

Asks is nodeList empty and replies with True or False as tf.

Instances

#ToVisit Source

class ToVisit (candidatesAccumulator :: NodeList) (parentlessAccumulator :: NodeList) (graph :: NodeList) (findMeInAnEdge :: NodeList) (candidates :: NodeList) (parentless :: NodeList) | candidatesAccumulator parentlessAccumulator graph findMeInAnEdge -> candidates parentless

In the visiting algorithm, obtains a list of nodes to visit as well as parentless or "sink" nodes.

  • candidatesAccumulator an accumulator of candidates to visit
  • parentlessAccumulator an accumulator of parentless or "sink" nodes
  • graph - the entire graph. if we were using an env comonad, this would be the environment
  • findMeInAnEdge - a list of nodes remaining to find in edges. This starts as the whole graph and whittles down to no nodes as the algorithm runs.
  • candidates return value of candidates for the next step
  • parentless return value of parentless nodes in the graph

Instances

#TerminusLoop Source

class TerminusLoop (graph :: NodeList) (visited :: NodeList) (visiting :: NodeList) (accumulator :: NodeList) (output :: NodeList) | graph visited visiting accumulator -> output

The algorithm that finds the terminal nodes of a graph.

  • graph - the entire graph. if we were using an env comonad, this would be the environment
  • visited - nodes we have visited so far in the aglorithm
  • visiting - nodes we are currently visiting in the aglorithm
  • accumulator - accumulator for tail-recursion that builds output
  • output - terminal nodes of the graph

Instances

#UniqueTerminus Source

class UniqueTerminus (graph :: Graph) (node :: Node) | graph -> 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

#HasUniqueTerminus Source

class HasUniqueTerminus (graph :: Graph) 

Assertion that graph has a unique terminus.

Instances

#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

#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

#NodeIsOutputDevice Source

class NodeIsOutputDevice (node :: Node) 

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

Instances