| OK, I'm a little clearer where in the woods you are exploring.
As long as you are working with WebAssembly then as soon as Csound is
performing, it is running in the background.
You can control it programmatically in various ways. One way is simply
to generate a Csound score in JavaScript and send it to Csound while
it is performing using csound.readScore(text). I do this both for
fixed media pieces and for interactive pieces.
I looked at Steven's Python example. It won't work as is in
WebAssembly but you can get it to work by simply leaving out the
performKsmps loop entirely. csound.start(), as I said, does this for
you. To get the channel values into Csound, you just call
csound.setControlChannel(name, value) whenever you want.
In the example, this happens every kperiod. You can mimic this to some
extent in JavaScript by setting up a timer to call
csound.setControlChannel() every 100th of a second or whatever you
want, like this which fires an anynomous function every 10
milliseconds. You would call this one time just after calling
csound.start():
var timer_id = setInterval( function() {
csound.setControlChannel("amp", 0.5); csound.setControlChannel("freq",
440); }, 10);
To allow the values to change over time you simply use variables in
the anonymous function that are in an enclosing scope (this is what
they mean by a closure):
var amp = 0;
var freq = 440;
var timer_id = setInterval( function() {
csound.setControlChannel("amp", amp); csound.setControlChannel("freq",
freq); amp = amp + 0.0001; freq = freq + 1;}, 10);
You can also, of course, do the same thing in Csound code in an
always-on instrument.
You could also compute values in JavaScript and put them into Csound
function tables... and so on and so on...
Hope this helps,
Mike
-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com
On Thu, Nov 2, 2017 at 8:55 PM, James Hearon wrote:
> Thank you for helping to explain this better. I'm not totally certain about what I was up to yet. Just looking at the nuts and bolts of the api so to speak to try to figure out what's possible at the code control loop level without resorting to gui control. I have been interested in the python howtos: https://github.com/csound/csoundAPI_examples/blob/master/python/example7.py which are stepbystep instructive and useful. So I'm a bit unclear how to control channel change values over time in the wasm webpage without performksmps. In the python ex. it's done using a RandomLine class with a reset method as long as perform ksmps equals zero, or the duration of the o |