SuperCollider - Question about Bus and execution order

Just started learning SuperCollider, I have a question about Bus.

2 lines executed in the following order produce a FM sound :

({Out.ar(0, SinOsc.ar(500 + (In.ar(5,1) * 1000),0,0.1))}.scope; // Carrier
{Out.ar(5, SinOsc.ar(550,0,1))}.scope;) // Modulator

But with an opposite execution order, it only produces a Sine tone, as if no modulator presents. In scope, there is signal in Bus 5.

({Out.ar(5, SinOsc.ar(550,0,1))}.scope; // Modulator
{Out.ar(0, SinOsc.ar(500 + (In.ar(5,1) * 1000),0,0.1))}.scope;) // Carrier

What’s the reason behind this behaviour? Thanks.

2 Likes

Maybe bus is not allocated in second code snippet, so out cannot connect to anything?

the bus is fine, it’s about execution order of the synths. the modulator has to execute before the carrier.

each Group has processing order including default root Group of default Server.

by default, { }.play and { }.scope add to the head of the processing queue. so first snippet works (car is created, then mod added to execute first)

this also works, explicitly setting order by reference:

~mod = {Out.ar(5, SinOsc.ar(550,0,1))}.play; // Modulator
~car = {Out.ar(0, SinOsc.ar(500 + (In.ar(5,1) * 1000),0,0.1))}.play(target:~mod, addAction:\addAfter); // Carrier

and i think using InFeedback in carrier would work regardless of order, so more flexible, but adds 1 blocksize latency.

for more details and examples see Synth helpfile

4 Likes

Thank you for the help!

Here are the 2 related tutorials I found :
https://doc.sccode.org/Guides/Order-of-execution.html
https://doc.sccode.org/Classes/InFeedback.html

2 Likes