Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/mono
mono is a low level language for audio expressions that compiles to wasm
https://github.com/stagas/mono
audio compiler expression language sound wasm webassembly
Last synced: 7 days ago
JSON representation
mono is a low level language for audio expressions that compiles to wasm
- Host: GitHub
- URL: https://github.com/stagas/mono
- Owner: stagas
- License: mit
- Created: 2021-12-10T17:03:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T06:31:08.000Z (over 1 year ago)
- Last Synced: 2024-10-03T06:47:49.064Z (about 1 month ago)
- Topics: audio, compiler, expression, language, sound, wasm, webassembly
- Language: TypeScript
- Homepage:
- Size: 387 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
monolangmono is a low level language for audio expressions that compiles to wasm
npm i monolang -g
pnpm add monolang -g
yarn global add monolang
## API
#
CompilerErrorCauses
src/causes.ts#L1
# CompilerErrorCause
src/causes.ts#L3
# constructor
(token, short)
col
number
index
number
input
string
line
number
message
string
name
= 'CompilerUnknownError'
src/causes.ts#L4 string
short
string
token
InvalidErrorCause
src/causes.ts#L15 # constructor
(token, short)
col
number
index
number
input
string
line
number
message
string
name
= 'CompilerInvalidError'
src/causes.ts#L16 string
short
string
token
ReferenceErrorCause
src/causes.ts#L6 # constructor
(token, short)
col
number
index
number
input
string
line
number
message
string
name
= 'CompilerReferenceError'
src/causes.ts#L7 string
short
string
token
SyntaxErrorCause
src/causes.ts#L12 # constructor
(token, short)
col
number
index
number
input
string
line
number
message
string
name
= 'CompilerSyntaxError'
src/causes.ts#L13 string
short
string
token
TypeErrorCause
src/causes.ts#L9 # constructor
(token, short)
col
number
index
number
input
string
line
number
message
string
name
= 'CompilerTypeError'
src/causes.ts#L10 string
short
string
token
CompStep
src/compiler.ts#L184 "lib"
User
src/compiler.ts#L186 "user"
Type
src/typed.ts#L4 # any
src/typed.ts#L5
"any"
bool
src/typed.ts#L6 "bool"
f32
src/typed.ts#L8 "f32"
i32
src/typed.ts#L7 "i32"
multi
src/typed.ts#L9 "multi"
none
src/typed.ts#L10 "none"
Arg
src/compiler.ts#L165 # constructor
(id, type) src/compiler.ts#L172
default
src/compiler.ts#L167 # export
src/compiler.ts#L166 boolean
id
src/compiler.ts#L173 Token & string
originalDefault
src/compiler.ts#L168 # range
src/compiler.ts#L169 # slope
src/compiler.ts#L170 # type
src/compiler.ts#L174
Buffer
src/compiler.ts#L61 # constructor
(context, sym) src/compiler.ts#L41
context
src/compiler.ts#L41 # sym
src/compiler.ts#L41 # Buffer
= ...
src/compiler.ts#L32 {
# Contents
= 5
src/compiler.ts#L38
5
Current
= 1
src/compiler.ts#L34 1
Length
= 4
src/compiler.ts#L37 4
Needle
= 0
src/compiler.ts#L33 0
Size
= 2
src/compiler.ts#L35 2
Size_m1
= 3
src/compiler.ts#L36 3
current
src/compiler.ts#L80 elements
src/compiler.ts#L101 elements_const
src/compiler.ts#L104 length
src/compiler.ts#L109 needle
src/compiler.ts#L73 pointer
src/compiler.ts#L66 scope
src/compiler.ts#L62 size
src/compiler.ts#L87 size_m1
src/compiler.ts#L94 get_pos
(offset, useNeedle) src/compiler.ts#L119 # read
(type, index) src/compiler.ts#L43 # read_at
(pos, elementOffset) src/compiler.ts#L160 # read_at_pos
(pos, elementOffset) src/compiler.ts#L152 # set_current
(value) src/compiler.ts#L83 # set_length
(value) src/compiler.ts#L112 # set_needle
(value) src/compiler.ts#L76 # set_pointer
(value) src/compiler.ts#L69 # set_size
(value) src/compiler.ts#L90 # set_size_m1
(value) src/compiler.ts#L97 # write
(type, index, value) src/compiler.ts#L51 # write_at
(i, val) src/compiler.ts#L116 # write_at_pos
(pos, elementOffset, value) src/compiler.ts#L143 # CompilerError
src/compiler.ts#L16 # constructor
(cause) src/compiler.ts#L26
cause
src/compiler.ts#L17 # name
= 'CompilerError'
src/compiler.ts#L25 string
prepareStackTrace
stackTraceLimit
number
captureStackTrace
(targetObject, constructorOpt) # targetObject
object
constructorOpt
Function
captureStackTrace(targetObject, constructorOpt) =>
- void
Context
src/compiler.ts#L349 # constructor
(module) src/compiler.ts#L355
elements
= {}
src/compiler.ts#L353 Record<string, Token>
module
src/compiler.ts#L355 # offsets
= {}
src/compiler.ts#L352 Record<string, number>
params
= []
src/compiler.ts#L350 Arg []
refs
= []
src/compiler.ts#L354 string []
scope
= ...
src/compiler.ts#L351 # build
(node, ops) src/compiler.ts#L372 funcDef
(id, params, body) src/compiler.ts#L404 # get_buffer
(id) src/compiler.ts#L363 # get_elements
(sym) src/compiler.ts#L357 # map
(nodes, ops) src/compiler.ts#L397 # Func
src/compiler.ts#L333 # constructor
(context, id) src/compiler.ts#L337
body
src/compiler.ts#L334 # context
src/compiler.ts#L337 # id
src/compiler.ts#L337 # source
src/compiler.ts#L335 # params
src/compiler.ts#L339 result
src/compiler.ts#L343 Module
src/compiler.ts#L411 # constructor
(root, types) src/compiler.ts#L425
OpTables
= ...
src/compiler.ts#L581 {
OpTable
OpParams
src/optables.ts#L968 OpTable
W
= Typed.W
src/typed.ts#L57 # bodies
= ...
src/compiler.ts#L413 # body
= []
src/compiler.ts#L412 # exported
= ...
src/compiler.ts#L417 Map<SExpr, number>
exported_id
= 0
src/compiler.ts#L416 number
exported_params
= ...
src/compiler.ts#L418 Map<Arg, Set<string>>
exported_params_map
= ...
src/compiler.ts#L419 Map<string, SExpr>
fill_body
= []
src/compiler.ts#L423 # funcs
= {}
src/compiler.ts#L414 Record<string, Func>
global
= ...
src/compiler.ts#L579 # init_body
src/compiler.ts#L421 # max
= Typed.max
src/typed.ts#L58 # ops
= ...
src/compiler.ts#L580 # eq
src/optables.ts#L83 # f32
src/optables.ts#L83 {
# add
= ...
src/optables.ts#L72
Op
const
= ...
src/optables.ts#L71 eq
= ...
src/optables.ts#L77 Op
mul
= ...
src/optables.ts#L74 Op
ne
= ...
src/optables.ts#L76 Op
shl
= ...
src/optables.ts#L75 Op
sub
= ...
src/optables.ts#L73 Op
i32
src/optables.ts#L83 {
# add
= ...
src/optables.ts#L72
Op
const
= ...
src/optables.ts#L71 eq
= ...
src/optables.ts#L77 Op
mul
= ...
src/optables.ts#L74 Op
ne
= ...
src/optables.ts#L76 Op
shl
= ...
src/optables.ts#L75 Op
sub
= ...
src/optables.ts#L73 Op
todo
src/optables.ts#L83 null
typebin
src/optables.ts#L83 } # root
src/compiler.ts#L426 # types
= ...
src/compiler.ts#L427 Map<string | object, Type>
OpTypeCast
= OpTypeCast
src/typed.ts#L50 # Type
= Type
src/typed.ts#L48 typeof Type
Types
= Types
src/typed.ts#L49 Type []
W
= W
src/typed.ts#L51 # f_params
src/compiler.ts#L436 f_type
src/compiler.ts#L432 cast
(targetType, x) src/typed.ts#L73 # castAll
(type, values) src/typed.ts#L85 # denan
(body) src/compiler.ts#L553 # forId
(id) src/compiler.ts#L573 # funcCall
(id, args) src/compiler.ts#L440 # hi
(values) src/typed.ts#L88 # infer
(x) src/compiler.ts#L559 # scoped
(scope, op) src/compiler.ts#L549 # top
(type, ops) src/typed.ts#L94 # typeAs
(type, x) src/typed.ts#L66 # typeOf
(x) src/typed.ts#L63 # valueOf
() src/compiler.ts#L583
valueOf() =>
max
(type, types) src/typed.ts#L53 # MonoParam
src/linker-service.ts#L38 # constructor
(data) src/linker-service.ts#L57
code
src/linker-service.ts#L49 string
defaultValue
src/linker-service.ts#L53 number
fnId
src/linker-service.ts#L40 Token & string
id
src/linker-service.ts#L39 Token & string
maxValue
src/linker-service.ts#L52 number
minValue
src/linker-service.ts#L51 number
name
src/linker-service.ts#L50 string
normalValue
src/linker-service.ts#L54 number
paramId
src/linker-service.ts#L41 Token & string
scaleValue
src/linker-service.ts#L55 number
source
src/linker-service.ts#L43 {
# arg
src/linker-service.ts#L44
string
default
src/linker-service.ts#L47 string
id
src/linker-service.ts#L45 string
range
src/linker-service.ts#L46 string
sourceIndex
src/linker-service.ts#L42 number
normalize
(value) src/linker-service.ts#L63 # value
number
normalize(value) =>
- number
scale
(normal) src/linker-service.ts#L67 # normal
number
scale(normal) =>
- number
Scope
src/compiler.ts#L248 # constructor
(context) src/compiler.ts#L251
context
src/compiler.ts#L251 # symbols
= ...
src/compiler.ts#L249 Map<string, Sym>
add
(type, id) src/compiler.ts#L253 ensure_sym
(id) src/compiler.ts#L286 # id
string | Token
ensure_sym(id) =>
- {
# scope
src/compiler.ts#L300
sym
src/compiler.ts#L300 }get
(id) src/compiler.ts#L303 # has
(id) src/compiler.ts#L277 # lookup
(id) src/compiler.ts#L281 # set
(id, value) src/compiler.ts#L308 # tee
(id, value) src/compiler.ts#L320 # Struct
src/compiler.ts#L31 # constructor
(context, sym) src/compiler.ts#L41
context
src/compiler.ts#L41 # sym
src/compiler.ts#L41 # Buffer
= ...
src/compiler.ts#L32 {
# Contents
= 5
src/compiler.ts#L38
5
Current
= 1
src/compiler.ts#L34 1
Length
= 4
src/compiler.ts#L37 4
Needle
= 0
src/compiler.ts#L33 0
Size
= 2
src/compiler.ts#L35 2
Size_m1
= 3
src/compiler.ts#L36 3
read
(type, index) src/compiler.ts#L43 # write
(type, index, value) src/compiler.ts#L51 # Sym
src/compiler.ts#L189 # constructor
(type, id, scope, token) src/compiler.ts#L190
id
src/compiler.ts#L192 string
scope
src/compiler.ts#L193 # token
= ...
src/compiler.ts#L194 # type
src/compiler.ts#L191 # $id
src/compiler.ts#L197 declare_mut
(value) src/compiler.ts#L214 export_id
() src/compiler.ts#L201
export_id() =>
- string []
export_mut
(value) src/compiler.ts#L205 # get
() src/compiler.ts#L219
get() =>
set
(value) src/compiler.ts#L224 # tee
(value) src/compiler.ts#L233 # Token
# constructor
(value)
group
string
source
RegExpMatchArrayLike
index
value
as
(value, group) is
(group, value) # toJSON
()
toJSON() =>
create
(value, group, source) # VM
src/linker-service.ts#L82 # constructor
({ blockSize, inputChannels, outputChannels, sampleRate }) src/linker-service.ts#L107
# new VM
()
# config
= ...
{
# blockSize
= 128
src/config.ts#L4
number
inputChannels
= 0
src/config.ts#L2 number
outputChannels
= 1
src/config.ts#L3 number
sampleRate
= 44100
src/config.ts#L5 number
code
src/linker-service.ts#L387 string
config
= ...
src/linker-service.ts#L107 {
# blockSize
= 128
src/config.ts#L4
number
inputChannels
= 0
src/config.ts#L2 number
outputChannels
= 1
src/config.ts#L3 number
sampleRate
= 44100
src/config.ts#L5 number
exportEntries
= {}
src/linker-service.ts#L288 Record<string, number>
floats
src/linker-service.ts#L90 Float32Array
id
= ...
src/linker-service.ts#L83 string
inputChannels
= 0
src/linker-service.ts#L87 number
inputs
src/linker-service.ts#L92 Float32Array []
instance
src/linker-service.ts#L85 Instance
ints
src/linker-service.ts#L91 Int32Array
isReady
= false
src/linker-service.ts#L386 boolean
memory
src/linker-service.ts#L84 Memory
monoBuffers
= ...
src/linker-service.ts#L96 Map<string, MonoBuffer>
outputChannels
= 1
src/linker-service.ts#L88 number
outputs
src/linker-service.ts#L93 Float32Array []
params
= []
src/linker-service.ts#L86 MonoParam []
port
src/linker-service.ts#L98 MessagePort
sampleBufferRanges
= []
src/linker-service.ts#L277 [ number, number ] []
sampleBuffers
= []
src/linker-service.ts#L245 Float32Array [] []
samples
src/linker-service.ts#L94 MonoBuffer [] []
exports
src/linker-service.ts#L284 createMonoBuffer
(id, pos, size) src/linker-service.ts#L175 # link
(code) src/linker-service.ts#L389 # code
string
link(code) =>
Promise<ModuleResponse>
makeFloats
() src/linker-service.ts#L227
makeFloats() =>
- void
makeSampleBuffers
() src/linker-service.ts#L201
makeSampleBuffers() =>
- void
setCode
(code) src/linker-service.ts#L290 # code
string
setCode(code) =>
Promise<{
# inputChannels
src/linker-service.ts#L381
number
outputChannels
src/linker-service.ts#L382 number
setPort
(port) src/linker-service.ts#L113 # port
MessagePort
setPort(port) =>
- void
setSampleBuffer
(index, buffer, range) src/linker-service.ts#L247 # index
number
buffer
Float32Array []
range
[ number, number ]
setSampleBuffer(index, buffer, range) =>
- void
setSampleBufferRange
(index, range) src/linker-service.ts#L279 # Includes
src/compiler.ts#L178 MonoBuffer
src/linker-service.ts#L74 # bufferSize
src/linker-service.ts#L79
number
id
src/linker-service.ts#L75 string
pos
src/linker-service.ts#L76 number
size
src/linker-service.ts#L77 number
structData
src/linker-service.ts#L78 Int32Array
SExpr
src/sexpr.ts#L3 TokenJson
# value
string
InstanceExports
src/linker-service.ts#L28 {} & libvm.VM & {
# __start__
() src/linker-service.ts#L34
__start__() =>
- void
f
(args) src/linker-service.ts#L35 # args
number []
f(args) =>
- number
Node
} # BYTES_CHANNELS
= ...
src/const.ts#L22 number
BYTES_EVENTS
= ...
src/const.ts#L7 number
BYTES_PADDING
= ...
src/const.ts#L4 number
BYTES_PAGE
= ...
src/const.ts#L3 number
BYTES_SAMPLES
= SAMPLE_SIZES.bytes
src/const.ts#L32 number
BYTES_USER
= ...
src/const.ts#L5 number
EVENTS_SIZE
= 128
src/const.ts#L6 128
MAX_CHANNELS
= 2
src/const.ts#L11 2
MAX_SIZE_BLOCK
= 128
src/const.ts#L12 128
SAMPLE_CHANNELS
= 2
src/const.ts#L16 2
SAMPLE_MAX_COUNT
= 1
src/const.ts#L17 1
SAMPLE_SAMPLE_RATE
= 44100
src/const.ts#L14 44100
SAMPLE_SECONDS
= 4
src/const.ts#L15 4
SAMPLE_SIZES
= ...
src/const.ts#L24 {
# bytes
src/const.ts#L29
number
channel
src/const.ts#L29 number
one
src/const.ts#L29 number
pages
src/const.ts#L29 number
SIZE_CHANNEL_IO
= ...
src/const.ts#L21 number
SIZE_CHANNEL_ONE
= ...
src/const.ts#L20 number
channelsPtr
= ...
src/const.ts#L34 number
eventsPtr
= BYTES_PADDING
src/const.ts#L9 number
memory
= ...
src/const.ts#L46 {
# initial
= MEM_PAGES
src/const.ts#L47
number
maximum
= MEM_PAGES
src/const.ts#L48 number
setupPtr
= ...
src/const.ts#L39 number
syntax
= ...
src/syntax.ts#L10 {
# comment
= ...
src/syntax.ts#L43
RegExp
declare
= ...
src/syntax.ts#L45 RegExp
normal
= ids
src/syntax.ts#L47 RegExp
number
= num
src/syntax.ts#L49 RegExp
operator
= ops
src/syntax.ts#L50 RegExp
property
= ...
src/syntax.ts#L44 RegExp
punctuation
= ...
src/syntax.ts#L48 RegExp
regexp
= ...
src/syntax.ts#L46 RegExp
userPtr
= ...
src/const.ts#L40 number
Parse
(input) src/parser.ts#L11 # compile
(root, scope_record, includes, init_body, fill_body, types, step) src/compiler.ts#L588 # root
scope_record
= {}
Record<string, Type>
includes
= {}
# init_body
= []
undefined | SExpr
fill_body
= []
# types
= ...
TypesMap
step
= CompStep.User
compile(root, scope_record, includes, init_body, fill_body, types, step) =>
getSharedWorkerPort
() src/get-shared-worker-port.ts#L1
getSharedWorkerPort() =>
- MessagePort
parse
(input) src/parser.ts#L9
## Credits
- [decarg](https://npmjs.org/package/decarg) by [stagas](https://github.com/stagas) – decorator based cli arguments parser
- [everyday-utils](https://npmjs.org/package/everyday-utils) by [stagas](https://github.com/stagas) – Everyday utilities
- [json-objectify](https://npmjs.org/package/json-objectify) by [stagas](https://github.com/stagas) – Like JSON.stringify but without the stringify part.
- [lexer-next](https://npmjs.org/package/lexer-next) by [stagas](https://github.com/stagas) – lexer for recursive descent parsers
- [rfdc](https://npmjs.org/package/rfdc) by [David Mark Clements](https://github.com/davidmarkclements) – Really Fast Deep Clone
- [serialize-whatever](https://npmjs.org/package/serialize-whatever) by [stagas](https://github.com/stagas) – Serialize and deserialize whatever.
- [tinypratt](https://npmjs.org/package/tinypratt) by [stagas](https://github.com/stagas) – a tiny pratt parser implementation
- [wat-compiler](https://npmjs.org/package/wat-compiler) by [stagas](https://github.com/stagas) – webassembly wat text format to binary compiler
## Contributing
[Fork](https://github.com/stagas/mono/fork) or [edit](https://github.dev/stagas/mono) and submit a PR.
All contributions are welcome!
## License
MIT © 2023 [stagas](https://github.com/stagas)