Using Janet In Monolith

Using Janet In Monolith

This is a general overview for using Janet in Monolith.

Janet was introduced as an alternative language interface to Scheme. It's still in the early stages, but has proven itself to be a very promising language with a flexible C API.

Here is just enough code to be able to evaluate runt code to produce an audio file:

<<janet_simple.janet>>=
(monolith/runt-loader)

(def rvl monolith/runt-eval)

(rvl "patchwerk nodes")
(rvl "440 0.5 sine")
(rvl "\"sine.wav\" wavout bdrop ps")

(monolith/compute (* 44100 10))

TODO Patchwerk Plugins with Janet

Janet can be used to build dynamically loadable patchwerk plugins. This makes it easier to develop experimental DSP algorithms.

The code below shows how to make a simple sine wave generator in patchwerk, wrapped inside of a Janet function.

INSERT CODE HERE.

This can be built using the internal JPM utility included with monolith monolith jpm.

From here, the node can be managed using some of the janet-patchwerk bindings, included in monolith. Monolith also supplies some glue functions that allow the node to interact with Runt code:

INSERT CODE HERE.

TODO Drawing With Janet

Most drawing operations are implemented as Janet functions, rather than scheme ones. This was done in order to practice using Janet.

Calling Janet from Scheme

Yes, Janet can be controlled from inside of Scheme. Isn't that just terrible? This combo is used when creating audio-visual things. Scheme handles most of the audio side and pages, while Janet is used to produce the graphics, using channels to talk to one another.

First, Janet needs to be initialized using monolith:janet-init.

(monolith:janet-init)

From there, janet code can be evaluated using monolith:janet-eval.

TODO Using Jex

JEX, or Janet EXecute, is a runt word that allows a Janet function to be triggered from Patchwerk. Multi-threaded support in Janet is tricky, so this only works in offline mode.