This blog has moved

This blog is now at

Tuesday 2 November 2010

How to Write BBCut FX

First, here's my file:

CutMask : CutSynth { 
 var <>bits,<>sr,<>bitadd,<>srmult; 
 var synthid;
 //makes SynthDef for filter FX Synth 
 *initClass { 
   StartUp.add({{arg i;

  SynthDef.writeOnce("cutmaskchan"++((i+1).asSymbol),{ arg inbus=0, outbus=0, bits; 
  var input, fx;
  fx =, bits);,fx);
 *new{arg bits=16,sr,bitadd=1,srmult=1;
 ^ ?? {Server.default.sampleRate/2}).srmult_(srmult);
 setup { 
 //tail of cutgroup
 synthid= cutgroup.server.nextNodeID;
 cutgroup.server.sendMsg(\s_new, \cutmaskchan++(cutgroup.numChannels.asSymbol), synthid, 1,cutgroup.fxgroup.nodeID,\inbus,cutgroup.index,\outbus,cutgroup.index, \bits, bits);

//can't assume, individual free required for cut fx
//synth should be freed automatically by group free
 free {

 renderBlock {arg block,clock;
  var samprate,bitstart,bitarray,srarray, s;
  s= cutgroup.server;

  bitstart= bits.value(block);
  samprate= sr.value(block);
  srarray= Array.geom(block.cuts.size,samprate,srmult.value(block));
  bitarray= Array.series(block.cuts.size,bitstart,bitadd.value(block));

  bitarray= 0.5**((bitarray).max(2)-1);{arg cut,i;
  block.msgs[i].add([\n_set, synthid,\bits,bits]);
  //don't need to return block, updated by reference


What I did there: I took and did a saveAs Then I changed the name of the class to CutMask.

In initClass

I changed the synthdef name to cutmaskchan

I changed the arguments to the SynthDef

I put in my own code for the fx = line. That's where the magic happens!

In new

I changed cutgroup.server.sendMsg to so it uses my synthdef name and my synthdef arguments

In renderBlock

I changed block.msgs[i].add( to have my synthdef arguments

since mine doesn't change, I could skip sending anything, afaik

No comments:

Commission Music

Commission Music
Bespoke Noise!!