A Quark or a Plug-in visualising SynthDef

Dear advanced and experienced users,

Could anyone recommend a Quark or a Plug-in visualising SynthDef similar to Max or pd?
I appreciate your help in advance!

Best regards,

1 Like

For those not knowing Max and pd, can you explain what you are trying to achieve ?

1 Like

like this:

?

2 Likes

This is worth looking into:

http://sccode.org/1-5fA


It’s one of the more recent post to sccode… only 1200 characters:

s.boot;

(
var bufferSize = s.sampleRate * 1; // Buffer size is fixed. s.sampleRate * seconds makes sense.

if( ~plotterIn == nil, { ~plotterIn = Bus.audio( s, 2 ) } ); // Declare a global channel for the plotter input, stereo

if( ~plotterBuffer != nil, { ~plotterBuffer.free } ); // Reset the buffer if existant
~plotterBuffer = Buffer.alloc( s, bufferSize, 2 ); // Create our buffer, stereo

SynthDef( \toBuffer, { // A simple routing synth
	| bufNum |
	var in = In.ar( ~plotterIn, 2 ); // Takes an input
	RecordBuf.ar( in, bufNum, loop: 0, doneAction: 2 ); // And outputs it in our buffer
} ).add;
)

( // Demo Synth
SynthDef( \demoSynth, {
	| out = 0, freq = 220 |

	var snd = SinOsc.ar( freq!2 );
	snd = snd * EnvGen.kr( Env.perc( 0.1, 0.9 ), doneAction: 2 );

	Out.ar( out, snd );
} ).add
)

(
Synth( \toBuffer, [ \bufNum, ~plotterBuffer ] ); // Trigger the buffer synth
Synth( \demoSynth, [ \out, ~plotterIn, \freq, 110 ] ); // Then our favorite synth
)

// You will need to wait the bufferSize length before plotting it !
~plotterBuffer.plot // Finally print the result

if( ~plotterBuffer != nil, { ~plotterBuffer.free } ); // Free the buffer if existant
1 Like

They are visual programming languages for music and multimedia. Please refer to the following websites:

In Max and pd, users make objects in a patcher window and connect them using wires or using objects [send] and object [receive].

What I want to achieve is visualising the structures of networked Ugens.
For example, the following code

Out.ar(0, SinOsc.ar)

could be visualised as follows:
Screenshot 2022-02-24 at 10.37.14 AM

Yes, thank you!
Installed Graphviz in a terminal window under macOS 12.2.1 as follows:

brew install graphviz

However, Apple Page is launched when evaluating the following code:

Dot.view("/tmp/sc3-dot.dot");

Graphviz is successfully installed, but I cannot find an application Graphviz.
How could I let SC open the sc3-dot.dot file with graphviz using an SC code?

Thanks in advace!

Hello,

Thank you very much for referring to this post!
I have never thought that someone may interpret my question as one about plotting the waveform of a synthDef.
Probably my question was somewhat ambiguous.
In future, I will describe more accurately what I need to know!

No need to apologize – your question was completely clear.

hjh

1 Like

not sure about the Graphviz program but brew will install the dot program which you can execute like this:

dot -Tpdf /tmp/sc3-dot.dot -o test.pdf; open test.pdf
RDot.view

would need to be updated along the lines of

(
~view = {|fn|
    "dot -Tpdf % -o %.pdf; open %.pdf &".format(fn, fn, fn).systemCmd
}
)
~view.("/tmp/sc3-dot.dot");
1 Like

You can also open .svg files directly in Sc.

I’ve added a very simple viewer, it’s fine for small graphs, but for larger graphs you’ll want something nicer. Browsers are one option.

Dot.viaSvg = true; // run dot to generate an .svg file and view that
Dot.svgViewer = “chromium”; // use an external viewer, if nil (the default) opens directly in sc

2 Likes

On my end (m1max MBP, macOS 12.2.1), unixCmd and systemCmd do not work, but runInTerminal work with the slightly modified code, which you provided for me, as follows:

(
~view = {|fn|
    "dot -Tpdf % -o test.pdf; open test.pdf".format(fn).runInTerminal
}
)
~view.("/tmp/sc3-dot.dot");

I’ve made some changes so that sc3-dot works here under MacOs (12.2.1).

Here I need to set the absolute path to dot, and use either the ‘svg’ or ‘pdf’ render mode.

Dot.dotCmd = “/opt/homebrew/bin/dot”;
Dot.renderMode = ‘pdf’; // run dot to generate an .pdf file and view that, also ‘svg’ works

If it’s not working there’s a Dot.verbose flag that prints out what it’s trying to do.

Here .pdf files open in Preview and .svg files open in Chrome.

Revised archive is at the address above.

Perhaps this helps?

1 Like

Thank you for your kind response!

I resolved it by installing Graphviz using port command as follows:
sudo port install graphviz

Now it works perfectly!