Env for real-time frequency control

Hi all,

I’d like to follow the concept of using Env().discretize to produce an array of frequency values, but I’d like to shape the envelope in real-time, so I can change the curve parameter of the Env with a UGen.

If Env().discretize is used to update the array of frequencies from the language side (from what I understand), it works fine:

(
~nf = 10;
SynthDef(\src,{
	x = SinOsc.ar(\freq.kr(1!~nf));
	x = Splay.ar(x) * -30.dbamp;
	Out.ar(0,x);
}).add;
)
(
x = Synth(\src,[
	\freq, Env([0,1],[1],1).exprange(70,3e3).discretize(~nf);
]);
)
(
{
	(1,1.01..6).do{|i|
		i.postln;
		x.set(
			\freq, Env([0,1],[1],i).exprange(70,3e3).discretize(~nf)
		);
		0.01.wait;
	}
}.fork;
)

But if I want to control the Env’s curvature with a UGen:

(
~nf = 10;
SynthDef(\src,{
	x = MouseY.kr(0,4);
	x = Env([0,1],[1],x).exprange(70,3e3).discretize(~nf);
	x = SinOsc.ar(x);
	x = Splay.ar(x) * -30.dbamp;
	Out.ar(0,x);
}).add;
)

it returns an error message.

Even if .discretize creates Signal[] with an array of values, those values can’t seem to be used as signals. Is that right?

In any case I’m not sure how to make this work, any help on how to solve this is appreciated!

Best,
cd

Had a quick play. This seems to work:

(
~nf = 10;
SynthDef(\src,{
	x = Env([0,1], [1], 'lin').discretize(~nf);
	x = x.collect({arg val;
		DC.kr(val).lincurve(0, 1, 0, 1, MouseY.kr(0,4)).linexp(0, 1, 70,3e3)
	});
	x = SinOsc.ar(x);
	x = Splay.ar(x) * -30.dbamp;
	Out.ar(0,x);
}).play;
)

Best, Paul

Correct. A “signal” in the server isn’t a Signal.

What we often call a “signal” (server side) exists in the language only as a structure defining calculations that will be performed later. From the language’s point of view, these are abstract operations; the language doesn’t directly see the concrete results of the calculation.

A Signal is an array of single-precision floating point numbers, where the concrete values do exist in the language (so a Signal isn’t the same as a server-side future calculation), and if a Signal is to be used in the server, it has to be transmitted to the server either via OSC messages or using a disk file.

The fact that we’re using the same word for both doesn’t indicate that they mean the same thing.

hjh