The shape of astrid’s python renderer changed a fair bit today. Until
this morning the python renderer and a full python interpreter was
embedded inside the main astrid program. Working on wrapping the new
astrid_instrument_start and friends today I realized since
I’m opening a queue to send messages to the python interpreter anyway,
the renderer doesn’t really need to be running inside an embedded
environment. I moved the cyrenderer module into
pippi.renderer (which might just become astrid
eventually since that’s what it wraps) and changed the way instrument
scripts work slightly so that they can be run standalone as normal
python scripts.
For example here’s the simple.py script from yesterday
modified in the new style:
from pippi import dsp, oscs, renderer
def play(ctx):
ctx.log('Rendering simple tone')
yield oscs.SineOsc(freq=330, amp=0.5).play(1).env('pluckout')
# This is the new thing:
if __name__ == '__main__':
renderer.run_forever('simple', __file__)
The renderer was already loading the script as a module, collecting the
play methods and executing them on demand, so adding a single line to
the python main routine doesn’t interfere
with live-reloading at all, and lets the script initialize itself in the
background, load itself as a module and wait for messages instead of
relying on a special console.py runner like I’ve been doing
for ages.
In the process I decided that the old astrid dac,
adc, seq, and renderer programs
have run their course. They all live on embedded inside the
astrid_start_instrument routine which starts the jack
thread, the message listener thread and the sequencer thread – all of
which are started with renderer.run_forever from the python
script.
I haven’t yet figured out how to fit the new linenoise console into python instruments but I’d like them to feel the same as the C instruments and drop into an astrid console when started…