mono
mono is a low level language for audio expressions that compiles to wasm
Install
$ npm i @stagas/mono
-- work in progress --
API
Table of Contents
- todo
- bin
- typebin
- eq
- funcDef
- Op
- OpArgs
- build
- map
- typeOf
- typeAs
- cast
- castAll
- hi
- max
- top
- infer
- flatten
- mush
todo
todo is a "not implemented" marker for ops
bin
constructs a binary op of least type type
Parameters
-
type
Type -
op
string
Returns Op
typebin
constructs a binary op of exact type type
Parameters
-
type
Type -
op
string
Returns Op
eq
constructs an equality op
Parameters
-
op
string
Returns Op
funcDef
defines a function
Parameters
Op
primary optable
Type: OpTable
OpArgs
arguments optable
Type: OpTable
build
builds a node
under context ctx
and optable ops
Parameters
-
node
Node -
ctx
Context -
ops
OpTable
Returns SExpr
map
builds an array of nodes
under context ctx
and optable ops
Parameters
Returns Array<SExpr>
typeOf
looks up and returns the type of x
, if found, otherwise returns type any
Parameters
Returns Type
typeAs
marks sexpr x
to be of type type
Parameters
-
type
Type -
x
SExpr
cast
creates a cast operation if the given value x
doesn't satisfy type
Parameters
-
type
Type -
x
SExpr
castAll
casts all values
to be of type type
Parameters
-
type
Type -
values
...SExpr
Returns SExpr
hi
returns the highest precision type of the given values
Parameters
-
values
...SExpr
Returns Type
max
returns at least the precision of the given type among the given types
Parameters
-
type
Type -
types
...Array<Type>
Returns Type
top
types an operation with the correct prefix (f32 or i32) and type casts the values to satisfy the op
Parameters
-
type
Type -
ops
SExpr
Returns SExpr
infer
infers the type of a token literal string: bool for 0 or 1, i32 for integers and f32 for floats
Parameters
-
x
Token
Returns Type
flatten
flattens a node that is left hand side recursing on symbol sym
Parameters
mush
Merges or pUSHes obj
to array arr
Parameters
-
arr
Array<any> -
obj
any
Contribute
All contributions are welcome!
License
MIT © 2022 stagas