Get more intution about nested ugens

I would like to gain some intuition about what is happening below: The lfnoise is creating 10 random numbers per second which is served as the freq for lfpulse. If the first random number is e.g. 9, then pulse will output 9 pulses for the first second? Then comes the next random number from lfnoise (e.g. 6) which make lfpulse output 6 other pulses in the 2. second and so on. How could I get more intuition about how nested ugens (as in this example) interact with eachother, at which rate is the output of one consumed by the other? Any one can help?

(
{
	LFPulse.kr(
		freq: LFNoise1.kr(10).range(1, 10),
		width: 0.1
	).poll
}.play
)

Your intuition here is basically correct. Every 1/10 of a second the LFNoise will output a new random value. This will be the new frequency value for the LFPulse, which will output pulses at that frequency. There’s not a “rate” that values are consumed (and least not in th way I think you are thinking of?) - they both output continuous signals that are updated either every sample (for .ar ugens) or every 64 samples dependijg on the block size setting (for .kr). One result of the fact that they’re continuous is: if your nested LFNoise changes it’s value between pulses, it will update the pulse frequency exactly at that point - so you will likely NOT get super clean, perfectly synced pulse trains (unless you do the math exactly right).

If you want a better idea of what the UGen combination is outputting, you can use .plot instead of .play to see the value plotted on a graph - it’s often easier to see what’s going on this way. You might also check the .poll method, which can be appended to any UGen to print it’s values to the console.
(Oops you’re already using poll :slight_smile: )

1 Like

actually if I can be pedantic, LFNoise1 will change target every tenth of second and make a ramp there. LFNoise0 would do the stepped version (still continuously outputting as you clearly pointed out)

I hope this helps to visualise the difference to the OT:

{[LFNoise0.kr(10), LFNoise1.kr(10)]}.plot(1)

Thanks for the plot, but this actually doesn’t answer my question.

:smiley: but it looks sooooo goooood :smiley:

seriously, it does though:

There is a confusion here about the rate of change. you describe a change every second (so 1Hz for the modulator) for an oscillator, between 1 and 10, and it seems you want them to be integer. so this is what you want I think (audio rate so you can hear it instead)

(
{
	LFPulse.ar(
		freq: LFNoise0.kr(1).range(1,11).trunc,
		width: 0.1,
		mul: 0.1
	)
}.play
)