wslib shortcuts

a number of syntax shortcuts featured in wslib


shortcuts documented here:

Synth:sched

Function:render

SCWindow:decorate ( margin, gap )

Env:kr ( doneAction, gate, mul, add, timeScale )

Array:fft ( imag ), Array:ifft ( imag )

String:spth / String.spath

Synth_ID

Synth:sched



shortcut methods


Synth:sched ( time, defName, args: [ arg1, value1, ... argN, valueN  ], target, addAction )

Same as Synth.new, but with a time offsed. Use for accurate timing from within Tasks and delayed synth starting


Synth.sched( 0.5, "default" ); //starts in 0.5 seconds


Function:render ( path, duration, fadeTime, sampleRate, headerFormat, sampleFormat, 

options, inputFilePath, prependScore, sfBuffer )

Render a function to disk in the same way as Function:play works.


{ SinOsc.ar( 550, 0, 0.1 ) }.render( "~/Desktop/testSine550.aif", 5 );


( 

// use sfBuffer argument to input a soundfile buffer, to be loaded by the NRT server


b = Buffer.new.path_( "sounds/a11wlk01-44_1.aiff" );


{ 

PlayBuf.ar(1, b.bufnum, 

SinOsc.kr(0.5).range(0.2,1.8), 

loop:1 )

}.render( "~/Desktop/testBuffer.aif", 5, sfBuffer: b );

)




SCWindow:decorate ( margin, gap )

Adds a FlowLayout decorator to the window's SCTopView.


w = SCWindow( ).front.decorate;  // typical use


( // replaces all this with one word

w = SCWindow( ).front;

w.view.decorator = FlowLayout( w.view.bounds );

)



Env:kr ( doneAction, gate, mul, add, timeScale )

Wrapper for EnvGen around Env. Makes the way I usually tend to use Env very easy


Env([0,1,0],[1,1]).kr(2); // typical use


// replaces:

EnvGen.kr( Env([0,1,0],[1,1]), doneAction: 2 );


// makes way for snappy syntax:

{ Env.perc.kr(2) * BPF.ar( PinkNoise.ar(0.2.dup), 1500 ) }.play;



Array:fft ( imag ), Array:ifft ( imag ), Complex:fft, Complex:ifft 

performs an fft or ifft directly on an array. Automatically generates costables and Signals internally. 

Returns a Complex with Signals in real and imag slots.


(

a = { |i| (( i / 255 ) * 2pi * 20).sin } ! 256;

a.plot;

a.fft.magnitude.plot;

)


String:spth / String:spath

shortcuts for standardizePath. This is not used anywhere in the wslib classes. Only for coding speed.


"~/scwork".spth;

"~/scwork".spath;



shortcut classes


Synth_ID

an alternative for Synth, which allows a nodeID to be specified at creation. Returns a regular Synth.


Synth_ID( "default", nodeID: 2000 );


Creation methods :

   new ( defName, args, target, addAction, nodeID )

   newPaused ( defName, args, target, addAction, nodeID )

   after ( aNode, defName, args, nodeID )

   before ( aNode, defName, args, nodeID )

   head ( aGroup, defName, args, nodeID )

   tail ( aGroup, defName, args, nodeID )

   replace ( nodeToReplace, defName, args, nodeID )