Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        


monolang

mono 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

# CompStep src/compiler.ts#L184 # Type src/typed.ts#L4 # Arg src/compiler.ts#L165 # Buffer src/compiler.ts#L61 # 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

    # offset

    # useNeedle

      boolean


    get_pos(offset, useNeedle)  =>



# read(type, index) src/compiler.ts#L43

    # type

    # index

      number


    read(type, index)  =>


# read_at(pos, elementOffset) src/compiler.ts#L160

    # pos

    # elementOffset  =  0

      number


    read_at(pos, elementOffset)  =>


# read_at_pos(pos, elementOffset) src/compiler.ts#L152

    # pos

    # elementOffset  =  0

      number


    read_at_pos(pos, elementOffset)  =>


# 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

    # pos

    # elementOffset

      number

    # value


    write_at_pos(pos, elementOffset, value)  =>


# CompilerError src/compiler.ts#L16 # stackTraceLimit

    number

# captureStackTrace(targetObject, constructorOpt)

    # targetObject


      object

    # constructorOpt

      Function


    captureStackTrace(targetObject, constructorOpt)  =>


      void
# Context src/compiler.ts#L349 # funcDef(id, params, body) src/compiler.ts#L404

    # id

    # params # body


    funcDef(id, params, body)  =>


      void
# get_buffer(id) src/compiler.ts#L363 # get_elements(sym) src/compiler.ts#L357 # map(nodes, ops) src/compiler.ts#L397

    # nodes

    # ops

      OpTable


    map(nodes, ops)  =>


# Func src/compiler.ts#L333 # Module src/compiler.ts#L411 # W  =  Typed.W src/typed.ts#L57

    # (x)

      # x


      (x)  =>


        number

# bodies  =  ... src/compiler.ts#L413 # body  =  [] src/compiler.ts#L412 # exported  =  ... src/compiler.ts#L417 # 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 # 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

    # (op)

      # op


        string


      (op)  =>


        Op

# f32 src/optables.ts#L83 # 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 # 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

    # (type, op)

      # type

      # op

        string


      (type, op)  =>


        Op

} # root src/compiler.ts#L426 # types  =  ... src/compiler.ts#L427

    Map<string | object, Type>

# OpTypeCast  =  OpTypeCast src/typed.ts#L50

    Record<Type, Partial<Record<Type, string>>>

# Type  =  Type src/typed.ts#L48 # Types  =  Types src/typed.ts#L49 # W  =  W src/typed.ts#L51

    # (x)

      # x


      (x)  =>


        number

# 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

    # scope

    # op

      string


    scoped(scope, op)  =>


      string
# 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 # max(type, types) src/typed.ts#L53 # MonoParam src/linker-service.ts#L38 # 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 # ensure_sym(id) src/compiler.ts#L286 # get(id) src/compiler.ts#L303 # has(id) src/compiler.ts#L277

    # id


    has(id)  =>


      boolean
# 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 # read(type, index) src/compiler.ts#L43

    # type

    # index

      number


    read(type, index)  =>


# write(type, index, value) src/compiler.ts#L51 # Sym src/compiler.ts#L189 # export_id() src/compiler.ts#L201


    export_id()  =>


      string []
# export_mut(value) src/compiler.ts#L205

    # value


      string | number


    export_mut(value)  =>


# get() src/compiler.ts#L219 # set(value) src/compiler.ts#L224 # tee(value) src/compiler.ts#L233 # Token

    # constructor(value)

    # group

      string

    # source

      RegExpMatchArrayLike

    # index
    # value
    # as(value, group)

      # value


        string

      # group

        string


      as(value, group)  =>



# is(group, value)

    # group


      string

    # value

      string


    is(group, value)  =>


      boolean
# toJSON() # create(value, group, source)

    # value


      string

    # group

      string

    # source

      RegExpMatchArrayLike


    create(value, group, source)  =>


# VM src/linker-service.ts#L82 # code src/linker-service.ts#L387

    string

# config  =  ... src/linker-service.ts#L107 # 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 # outputChannels  =  1 src/linker-service.ts#L88

    number

# outputs src/linker-service.ts#L93

    Float32Array []

# params  =  [] src/linker-service.ts#L86 # 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 # exports src/linker-service.ts#L284
# createMonoBuffer(id, pos, size) src/linker-service.ts#L175

    # id


      string

    # pos

      number

    # size

      number


    createMonoBuffer(id, pos, size)  =>


# 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 # 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

    # index


      number

    # range

      [ number, number ]


    setSampleBufferRange(index, range)  =>


      void
# Includes src/compiler.ts#L178
# MonoBuffer src/linker-service.ts#L74 # SExpr src/sexpr.ts#L3
# TokenJson

    # group


      string

    # source

      {


      # index


        number

      # input

        string

      # match

        string []

      }

# value

    string

# InstanceExports src/linker-service.ts#L28 # f(args) src/linker-service.ts#L35

    # args


      number []


    f(args)  =>


      number
} # Node

    NodeArray | Token & {


    # lexer


      Lexer

    # toString()


      toString()  =>


        string

} # 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 # 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 # setupPtr  =  ... src/const.ts#L39

    number

# syntax  =  ... src/syntax.ts#L10 # userPtr  =  ... src/const.ts#L40

    number

# Parse(input) src/parser.ts#L11

    # input


      string


    Parse(input)  =>


# compile(root, scope_record, includes, init_body, fill_body, types, step) src/compiler.ts#L588

    # root

    # scope_record  =  {}

      Record<string, Type>

    # includes  =  {} # init_body  =  [] # 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

    # input


      string


    parse(input)  =>


## 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)