{"id":237,"date":"2010-11-02T20:36:00","date_gmt":"2010-11-02T20:36:00","guid":{"rendered":"http:\/\/www.celesteh.com\/blog\/2010\/11\/02\/how-to-write-bbcut-fx\/"},"modified":"2015-06-19T00:23:30","modified_gmt":"2015-06-18T23:23:30","slug":"how-to-write-bbcut-fx","status":"publish","type":"post","link":"https:\/\/www.celesteh.com\/blog\/2010\/11\/02\/how-to-write-bbcut-fx\/","title":{"rendered":"How to Write BBCut FX"},"content":{"rendered":"<p>First, here&#8217;s my file:<\/p>\n<pre>\nCutMask : CutSynth { \n var bits,sr,bitadd,srmult; \n var synthid;\n \n \/\/makes SynthDef for filter FX Synth \n *initClass { \n \n   StartUp.add({\n  \n  2.do({arg i;\n\n  SynthDef.writeOnce(\"cutmaskchan\"++((i+1).asSymbol),{ arg inbus=0, outbus=0, bits; \n  var input, fx;\n  \n  input= In.ar(inbus,i+1);\n  \n  fx = MantissaMask.ar(input, bits);\n  \n  ReplaceOut.ar(outbus,fx);\n  \n  }); \n  });\n  \n  });\n  \n } \n \n *new{arg bits=16,sr,bitadd=1,srmult=1;\n  \n ^super.new.bits_(bits).bitadd_(bitadd).sr_(sr ?? {Server.default.sampleRate\/2}).srmult_(srmult);\n }\n \n setup { \n \/\/tail of cutgroup\n synthid= cutgroup.server.nextNodeID;\n  \n cutgroup.server.sendMsg(s_new, cutmaskchan++(cutgroup.numChannels.asSymbol), synthid, 1,cutgroup.fxgroup.nodeID,inbus,cutgroup.index,outbus,cutgroup.index, bits, bits);\n   \n } \n\n\n\/\/can't assume, individual free required for cut fx\n\/\/synth should be freed automatically by group free\n free {\n  cutgroup.server.sendMsg(n_free,synthid); \n }\n\n renderBlock {arg block,clock;\n  var samprate,bitstart,bitarray,srarray, s;\n  \n  s= cutgroup.server;\n\n  bitstart= bits.value(block);\n  samprate= sr.value(block);\n  \n  srarray= Array.geom(block.cuts.size,samprate,srmult.value(block));\n  bitarray= Array.series(block.cuts.size,bitstart,bitadd.value(block));\n\n  bitarray= 0.5**((bitarray).max(2)-1);\n\n  block.cuts.do({arg cut,i;\n  \n  block.msgs[i].add([n_set, synthid,bits,bits]);\n  \n  });\n  \n  \/\/don't need to return block, updated by reference\n }\n \n\n}\n<\/pre>\n<p>What I did there:  I took CutBit1.sc and did a saveAs CutMask.sc.  Then I changed the name of the class to CutMask.<\/p>\n<h4>In initClass<\/h4>\n<p>I changed the synthdef name to cutmaskchan<br \/>\nI changed the arguments to the SynthDef<br \/>\nI put in my own code for the fx = line.  That&#8217;s where the magic happens!<\/p>\n<h4>In new<\/h4>\n<p>I changed cutgroup.server.sendMsg to so it uses my synthdef name and my synthdef arguments<\/p>\n<h4>In renderBlock<\/h4>\n<p>I changed block.msgs[i].add( to have my synthdef arguments<br \/>\nsince mine doesn&#8217;t change, I could skip sending anything, afaik<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, here&#8217;s my file: CutMask : CutSynth { var bits,sr,bitadd,srmult; var synthid; \/\/makes SynthDef for filter FX Synth *initClass { StartUp.add({ 2.do({arg i; SynthDef.writeOnce(&#8220;cutmaskchan&#8221;++((i+1).asSymbol),{ arg inbus=0, outbus=0, bits; var input, fx; input= In.ar(inbus,i+1); fx = MantissaMask.ar(input, bits); ReplaceOut.ar(outbus,fx); }); }); }); } *new{arg bits=16,sr,bitadd=1,srmult=1; ^super.new.bits_(bits).bitadd_(bitadd).sr_(sr ?? {Server.default.sampleRate\/2}).srmult_(srmult); } setup { \/\/tail of cutgroup synthid= cutgroup.server.nextNodeID; &hellip; <a href=\"https:\/\/www.celesteh.com\/blog\/2010\/11\/02\/how-to-write-bbcut-fx\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to Write BBCut FX<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[1],"tags":[142,76,64],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-bbcut","tag-celesteh","tag-supercollider"],"_links":{"self":[{"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":1,"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":2437,"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions\/2437"}],"wp:attachment":[{"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.celesteh.com\/blog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}