Can Flucoma tools be better than this patch?

Hi everyone. I’m currently studying this code for pitch detection from the SuperCollider book. The code can be found on page 454, example n 15.7. However, I’m not sure why it’s giving me errors. I’ve checked multiple times to ensure that I’ve copied the code correctly.

Instead of delving into this, I was wondering if I could use machine learning and new AI tools to achieve better results. Thank you."

the code is this



b = Buffer.alloc(s, 512);

//this SynthDef will make no sound, just analyses input
	var in, amp, freqdata, chain, onsets, trigger;
	in =;
	amp = RunningSum.rms(in, 64); //get rms amplitude value per control block
	freqdata =; 
	//allow synchronous polling, Internal Server only,freqdata);,amp);
	chain = FFT(b, in);
	// - move the mouse left/right to change the threshold:
	onsets =,,1), \complex);
	trigger =;



var freqlist=List(), amplist=List(); 
var notelist= List(), numnotes=10; //will hold the last 10 notes 
var lasttime, started=false; 
var maxlength=0.5, maxkperiods, waittime;

maxkperiods = ((maxlength*(s.sampleRate))/(s.options.blockSize)).asInteger;
waittime = (s.options.blockSize)/(s.sampleRate);

// register to receive message
a= OSCresponder(s.addr,'/tr',{ arg time,responder,msg;
	var newnote;
	//finalise previous note as [starttime, ioi= inter onset interval, dur, medianpitch, maxamp]	
	newnote = 	[lasttime, time-lasttime, (time-lasttime).min(maxlength), if(freqlist.notEmpty, {freqlist.median.cpsmidi},{nil}),amplist.maxItem.ampdb];
	//remove oldest note if over size
	},{started = true;}); 
	//reset lists for collection
	freqlist = List();
	amplist = List(); 
	lasttime = time;

x= Synth(\pitchandonsets); 

//poll values
		var freq, hasfreq, rmsamp;
		freq = s.getSharedControl(0);
		hasfreq = s.getSharedControl(1);
		rmsamp = s.getSharedControl(2);
		//don't allow notes of longer than 500 control periods or so
		if((hasfreq>0.5) and: (amplist.size<maxkperiods), {freqlist.add(freq)});
		if(amplist.size<maxkperiods, {amplist.add(rmsamp)});
		//poll every control period, intensive


a.remove; //Free the OSCresponder; // Free the synth; // Free the buffer
1 Like

The latest pitch detection, and i guess it’s an offline method, and it doesn’t seem to exist in supercollider is crepe. I’m not sure what flucoma or the standard pitch tracking in supercollider uses. There’s probably a lot of others by now too.

1 Like

The FluCoMa pitch tracker (FluidPitch for real-time analysis or FluidBufPitch for buffer analysis) don’t use machine learning, just machine listening pitch analysis algorithms.

Both the NRT and RT algorithms above can choose from 3 different pitch analysis algorithms. You can read more about those on this page: Learn FluCoMa