Sunday, July 8, 2012

Output HTML Documentation of Your Code with Textmate

Just a tip - if you want to publish code examples from TextMate and include the syntax highlighting of your TextMate theme, you can run the command:

Bundles -> Textmate -> Create HTML from Document

There's also a command in there to create a css stylesheet from your theme.



  

/* define synths and send to servers */
~z.collect({|z|
SynthDef("pulser",{|freq=100,m=#[1,1,1,1], atk=1,fatk=1, rel=1, sus=1, w=0.5,amp=0.005,pan =0,gate=0,sw=8,r=(0.5),out=0,mrate=1|
  Out.ar(out,Mix.ar(Pan2.ar(RLPF.ar(Pulse.ar( m * freq ,w
,0.5 * 5 * amp/(((freq)+256))),(LFPulse.ar(mrate,0,0.5,0,w)*freq*EnvGen.ar(Env.asr(fatk,sw, rel*2,'sine'),gate, doneAction:2)).clip(32,2**14),r,1),pan)) * EnvGen.ar(Env.asr(atk,1, rel,'sine'),gate, doneAction:0) );}).send(z);
});

~z.collect({|z|
SynthDef("sine-cluster",{|freq=100, atk=1, rel=1, sus=1, amp=0.005,pan =0,gate=0|
  Out.ar(0,Mix.ar(Pan2.ar(FSinOsc.ar(  [1,1] * freq,0,7 * amp/(((freq)+256))),pan)) * EnvGen.ar(Env.perc(atk,rel, 1,sus),gate, doneAction:2) );}).send(z);
});

/* Define functions for playing our synths */
~sineClusterplayer = {|f=64,scaleDegree=1,overtones=([1,3,7,13,16]),articulation=1,cycle=1,amp=1,step=1|
  //step thru a collection of overtones
  overtones.collect({|overtone,num|
    //play a tight cluster of 8 sines, slightly detuned from the overtone
    8.do({|clusterTone|
        var sn = Synth("sine-cluster",nil,~z.wrapAt(clusterTone+num)),freq,
          accent=(((~scale.wrapAt(scaleDegree+cycle)%~scale.size)+1)/~scale.size);
        freq = f * scaleDegree * overtone;
        freq = freq * (freq > 128).if({~pitchTweak.(clusterTone,cycle,num)},{1});//just a little detune if we're not too deep in the bass
        sn.set(\freq,freq);
        sn.set(\atk,(1/64) + ((num*overtone)/64) );//higher overtones have longer attack
        sn.set(\amp,1.5 * amp);
        sn.set(\rel,(48 * ~t * ~tempo) / ~scale.size.clip(2,32).log2);
        sn.set(\sus,-1.125 * articulation * accent * (scaleDegree%overtone).clip(2,~scale.size).asInt.factors[0].log2);
        sn.set(\pan,([1,-1] /.x (2..6)).sort.wrapAt(clusterTone+step+num));
        sn.set(\gate,1);
    });
  });
};

No comments:

Post a Comment