demonstrate matron custom events from an external module
git clone
the repository some place outside of the dust/
tree such as /home/we
. cd
into the repository and run:
git submodule update --init
compiling the code requires add the matron
src tree to the search path for header files and the submodule pulls in the norns code base as needed. alternatively you can skip submodule and create symlink to the location of an existing source tree, for example:
mkdir -pv dep/
ln -s ~/norns dep/norns
once the norns source tree is setup building the module can be done by running:
mkdir -pv build && cd build
cmake ..
make
the build directory should now contain norns-event-demo/
- a directory which is
organized as a "mod" for matron.
make install-zip
will createnorns-event-demo.zip
suitable for distribution / installation viamaiden
make install-dust
will copy the mod directly into/home/we/dust/code/
lua maintains separate package search paths, one for locating *.lua
files and a second for locating compiled *.so
files. matron
by default does not configure the package.cpath
variable which defines the search path for compiled modules. the mod/lib/mod.lua
file (which becomes norns-event-demo/lib/mod.lua
when built) takes care of:
- extending
package.cpath
such that the compiled module will be found at runtime - loading the compiled model via
require
making it globally available
the lub_event_demo.cpp
provides the implementation for (a) the functions used by matrons
event loop to handle events generated by this module and (b) some functions which are directly callable from lua as event_demo.start()
and event_demo.stop()
.
if a lua function called event_demo_handler
exists it will be called each time the custom event is popped from the queue. with this mod installed under dust/code
and enabled within the MENU try the following in the maiden
REPL:
-- define the function which the extension expects to call
function event_demo_handler(v) print("lua handler got", v) end
-- start the custom event generation thread
event_demo.start()
-- stop the custom event generation thread
event_demo.stop()