New kr triggering

Hello,

I love not having to set up control busses for passing triggers around anymore, but now I have a question about what’s going on behind the scenes with all this. If I have something like this in a synth (below), I have a FluidNormalize before and after the MLP, all being trigger by the same Implulse.kr. Right now it’s hard for me to understand what is happening, especially since the actually processing of the buffers is happening in a different synth in a different place in scsynth. I’m trusting that the buffers are getting filled properly and not overwritten too early, but it’s hard for me to think through exactly what happens in what order to know that that is the case. Any explanations here will be very appreciated.

Thank you!

...
var in_buf = LocalBuf(input_vec_size);
var in_buf_norm = LocalBuf(input_vec_size);
var out_buf = LocalBuf(3);
var out_buf_scaled = LocalBuf(3);
var trig = Impulse.kr(30);

in_buf.numFrames.do({
	arg i;
	BufWr.kr(vector[i],in_buf,i,1); // vector is a kr stream of analysis parameters
});

x_scaler.kr(trig,in_buf,in_buf_norm); // normalize the vector data 
nn.kr(trig,in_buf_norm,out_buf); // mlp prediction
y_scaler.kr(trig,out_buf,out_buf_scaled,invert:1); // scale it back up

out_vec = out_buf_scaled.numFrames.collect({
	arg i;
	BufRd.kr(1,out_buf_scaled,i,1); // convert back to kr stream
});

out_vec.poll;
...

These are all normal UGen calls, unlike the FluidBuf*.kr: i.e. everything happens in one thread, in the order written, within a single invocation, i.e. when triggered, your normalizers and MLP will be doing their thing within a single signal vector. So you ought to be able to trust that your buffer operations are happening in order.

If you’re concerned that they might not be, we can probably construct a test case to verify.

The more complex bit will be the interaction with other synths, if any of that stuff isn’t using just using straightforward UGens, because the synchronisation is harder to reason about once NRT jobs are involved.

Cool. Thanks for the confirmation. To be clear, I used the word trust, not because I don’t trust you guys, but because I do trust you guys–and it was my understanding that was lacking.

1 Like

It’s all good, I didn’t feel impugned :heart:

1 Like