Plotting with SC

I assume you're familiar with Stethoscope ({}.scope) and FreqScope ({}.freqscope) already

plot //highlight the method name 'plot' and ask for classes which implement it (cmd+Y on Mac)

Function plotting lets you check synthesis and draw diagrams!

//one cycle of a triangle wave at 100 Hz


//observe frequency modulation close up


//observe stereo frequency modulation at a distance



Env([0,1,1,0],[0.5,1.0,2.0],[10,0,-4]).plot //this one you've probably seen before in learning about Env?

i= InterplEnv([0,1,1,0],[0.5,1.0,2.0],[10,0,-4]).plot

If you've not seen InterplEnv before, it's used with an IEnvGen


It can therefore replace using the Index UGen (which requires a buffer to be allocated), but also allows continuous ranges

Plotting an ArrayedCollection


Plotting a Buffer,Platform.resourceDir +/+ "sounds/a11wlk01.wav"); 



//get to language safely

b.loadToFloatArray(0,-1,{arg data; a=data;})


//manipulate using language

a= a.collect{|val| if(0.1.coin,{val*val},{val*val*val}) }; 


//return to buffer




(also see Shaper, Osc, Signal, Wavetable help files)

A wavetable has a special efficient data format which can be loaded to a buffer for use with the Osc and Shaper UGens. 

You either have to use some special Wavetable creating class methods (for example, sineFill and chebyFill) or create one via a Signal

a= Signal.fill(256,{arg i; var t= (i/255.0)+0.1.rand;  (t*t)-t+(0.3*t*t*t)}); 

a= a.asWavetable

a.size //doubles size; adds interpolated values that are the secret ingredient of a wavetable

Plotting a wavetable will show you the wavetable with the special interpolating values hidden.




b.plot //this will show the hidden values too; looks weirder!

{,440,0,0.2)}.play //buzzy Synth

{,,500,'exponential'),0,0.2),,10000,'exponential'))}.play //filter, but probably already aliasing



f= SoundFile.openRead(Platform.resourceDir +/+ "sounds/a11wlk01.wav");

f.plot //uses the SCSoundFileView

Some other graphing functions

histograms via Collection:histo

Array.rand(1000,0.0,1.0).histo(10,0,1).plot(minval:0,maxval:200)   //histo first argument is number of histogram bins


advanced (requires use of Extensions folder/Quarks, see Extending SC): 

For fun: Dan Stowell's HeatMap (it's a Quark, example from the help file)

// This distribution is interesting, but .plot doesn't really show why:

a = 20.collect{|x|20.collect{|y| (x+y/pi).sin.rand}}.flat;


a.heatMap(20); // Much better!

// Choose your colour scheme:

a.heatMap(20, colscheme: \red);

a.heatMap(20, colscheme: \brw);

a.heatMap(20, colscheme: \coals);