All right! So I poked around a little bit and I think I got a least part of what is going on.
I got that make-instrument requires both a <name>_note and a <name>_fx closure.
At this point, it still feels a little bit like alchemy, but it works! I modified the saw_synth example this way (basically copying the example into the base_note from instruments.xtm):
(bind-func saw_synth_note
(lambda ()
(lambda (data:NoteData* nargs:i64 dargs:SAMPLE*)
(let ((starttime (note_starttime data)) ;; start time
(frequency (note_frequency data)) ;; you'll probably want the note frequency (in hz)
(amplitude (note_amplitude data)) ;; you'll probably want the note amplitude (0.0-1.0)
(duration (note_duration data))
(sawl (saw_c 0.))
(sawr (saw_c 0.)))
(lambda (time:i64 chan:i64)
(if (> (- time starttime) duration) (note_active data #f))
(cond ((= chan 0)
(sawl amplitude frequency))
((= chan 1)
(sawr amplitude frequency))
(else 0.0)))))))
(bind-func saw_synth_fx
(lambda ()
(lambda (in:SAMPLE time:i64 chan:i64 dat:SAMPLE*)
in)))
However, upon compilation, I get the message:
Unable to locate 5266453129974903 in closure environment b
Unable to locate id in closure environment type: {i8*, i8*, {i8*, i8*, float (i8*, i8*, i64, i64)*}** (i8*, i8*, %NoteData*, i64, float*)*}** d
It still compiles, and it otherwise seems to work fine. What does that message mean?