Live Audio Formant shifting

Hi all,
I’m currently working on a harmonizer for live audio input to re-pitch audio using midi input.
I have a crude script working that I can successfully pitch shift incoming audio and do so with multiple voices.

Is there any way in SuperCollider to change the format of live audio in order to “normalize” the pitch shifted audio? I’m guessing Fourier analyses and transform would be the way to go but I can’t find any resources that show this is possible.

PitchShiftPA might also be a solution but, I’d like to use stock uGens as I plan to use this script on devices where SuperCollider runs kind of in the background alongside LUA and prefer for the users in these communities not to have to install extra extensions to make it work.

Here’s the work in progress:

Live Pitch Shift
MIDIClient.init;

MIDIIn.connectAll;


~aNotes = Array.newClear(128);
(
MIDIdef.noteOn(\noteOnTest,{
	arg vel, nn, chan, src;
	[vel, nn].postln;
	~aNotes[nn] = Synth.new(
		\aTune,
		[
			\nFreq, nn.midicps,
			\amp, vel.linexp(1,127,0.1,0.3),
			\gate, 1,
		]
	);
});

MIDIdef.noteOff(\noteOffTest,{
	arg vel, nn;
	[vel, nn].postln;
	~aNotes[nn].set(\gate, 0);
	~aNotes[nn] = nil;
});
)


(SynthDef.new(\aTune, {
	arg gate = 0, nFreq = 4, amp = 0.3;
	var in, freq, hasFreq, out, trig, env;
	trig = Impulse.ar(1);

	in=AudioIn.ar(1);

	# freq, hasFreq = Pitch.kr(in,440, 80, 700, ampThreshold: 0.02, median: 7);
	freq = Clip.ar(freq, 1.midicps, 128.midicps);
	out = 	PitchShift.ar(in, 0.1, ((Demand.ar(trig, 0, nFreq) + 20).midicps / freq), 0, 0.01);

	env = EnvGen.kr(Env.adsr(releaseTime: 0.1), gate, doneAction: 2);
	out = out * env * amp;
	Out.ar([0,1],out);
	nFreq.postln;
}).add;

)