Plot a function faster?

Is it possible to plot a function faster than it’s attributed time window? I want to check what my function does over 2 minutes. I don’t want to wait the 120 seconds for the graph being spat out. Can I make it happen faster?

A simple example:

{LFNoise0.kr}.plot(120)

There’s a thread on this and I made a suggestion for NRT rencdering, take the second version from here:

Well, and plot is actually not designed for a visualisation of 120 seconds. The artifacts won’t give you something meaningful. However, if you have the data in the language you can inspect parts.
Therefore we can build in an action function into the fast plot, it would pass the array, then you can plot parts. Moreover you can inspect the audio file in the SC recordings directory with an external editor.

/ helper synthDef to indicate storage of temporary SynthDef of passed function

(
SynthDef(\finishedStore, {
	SendReply.ar(Impulse.ar(0), '/finishedStore');
	Line.ar(dur: 0.001, doneAction: 2);
	Silent.ar
}).store
)


(
~plotNRT = { |function, duration = 1, numChannels = 1, action|
	var soundFile, array;
	var synthDef = function.asSynthDef;
	var dateString = Date.getDate.stamp;
	var renderString = "render_" ++ dateString;
	var soundFileName = Platform.recordingsDir +/+ renderString ++ ".aiff";
	var options = ServerOptions().numOutputBusChannels = numChannels;
	var oscFunc = OSCFunc({ |msg|
		// produces score and renders aiff
		Score.recordNRT(
			[
				[0.0, [\s_new, synthDef.name, 1000, 0, 0]],
				[duration, [\c_set, 0, 0]]
			],
			("~/" ++ renderString ++ ".osc").standardizePath,
			soundFileName,
			options: options,
			duration: duration,
			// after rendering is finished we can plot
			action: {
				soundFile = SoundFile.new;
				soundFile.openRead(soundFileName);
				{
					array = FloatArray.newClear(soundFile.numFrames);
					soundFile.readData(array);
					function.notNil.if { action.(array) };
					array.plot;
					soundFile.close;
				}.defer

			}
		);
	}, '/finishedStore').oneShot;
	// triggers synth finishedStore which triggers OSCFunc
	synthDef.store(completionMsg: [\s_new, \finishedStore, -1]);
}
)


// plot 120 seconds
// audio file stored in SC recordings directory

~plotNRT.({ LFDNoise3.ar(150) }, 120, action: { |x| a = x })

a.size
-> 5292032

a[(400000..420000)].plot
1 Like

Thanks for the answers. My goal is to inspect very slow random LFOs or similar controlsignals that interact over a long time, several minutes to hours. Maybe rendering and inspect in a editor is the way, but a bit cumbersome…

Ok, in this case again plot might be sufficient. See the first example with an LFO over 10 seconds.

Really ? if you have prepared the plot function or a method with it, it takes a few moments to render (3 seconds fro 2 minutes) and polling from a SC directory to an external editor is one drag (I use ocenaudio rather than a DAW for that).

But there’s another thing: the patch uses renderNRT which assumes ar. I’m not aware atm how to render a control rate signal, but that should be much faster.

Maybe someone can chime in and elaborate on this ?