What is the best way to plot a 'Synth()'?

EDIT : should have searched the forum before posting, the answer is here already.

BTW the reason why we can have { ... }.plot but not SynthDef(...).plot is:

  • When plotting a function, we can assume that the function’s return value (which is a network of UGen connections) is the signal that you want to plot.
  • If it’s a SynthDef, there is no guaranteed, reliable way to know what signal to plot. SynthDefs use Out.ar to write the signal to a bus. To plot, we would need to know which bus. There is a loose convention that SynthDefs should have an out argument for the output bus number. But if the user said outbus or bus or audioOutputBus, how would SynthDef:plot know this? (Worse, a lot of new users take a shortcut and write Out.ar(0, ...) in which case it would be impossible for a hypothetical SynthDef:plot method to isolate the signal from other things playing at the same time.)

poll is one workaround.

Another is to write a RecordBuf into the SynthDef (temporarily, delete it later), then plot the buffer’s contents.

I still think that having the RecordBuf inside the SynthDef is not convenient because you have to setup a “live” SynthDef and a “production” SynthDef.