Skip to content

Instantly share code, notes, and snippets.

@DarienBrito
Created February 19, 2018 22:51
Show Gist options
  • Save DarienBrito/ed87a0b3812804903a987d8cb31dd41d to your computer and use it in GitHub Desktop.
Save DarienBrito/ed87a0b3812804903a987d8cb31dd41d to your computer and use it in GitHub Desktop.
ProgrammingMusic2
///////////////////////////////////////////////
// Using the very comfotable Ndef from JITLIB
///////////////////////////////////////////////
(
Ndef(\reverb, {
| in = 2, roomsize = 200, revtime = 40, damping = 0.1, inputbw = 0.5,
spread = 15, drylevel = 0.2, earlylevel = 0.1, taillevel = 0.2, wet = 0.8 |
var sig = \in1.ar;
sig = GVerb.ar(sig, roomsize,
revtime,
damping,
inputbw,
spread,
drylevel,
earlylevel,
taillevel,
roomsize,
mul: wet );
});
Ndef(\drone, { |
freq = 20 , levelA = 0.25, levelB = 0.1, index = 1,
harmonicity = 2, cFreq = 1000, feedback = 0, delay = 0.1, amp = 1.0, wrap = 1.0 |
var osc1, osc2, sig, finalFreqA, finalFreqB;
var freqA = freq;
var freqB = freq * 2;
var mod1 = freqA * harmonicity;
var mod2 = freqB * harmonicity;
var widthModA = SinOsc.ar(freq * 0.01).range(0.0,1.0);
var widthModB = SinOsc.ar(freq * 0.005).range(0.0,1.0);
var modOsc1 = Pulse.ar(mod1, widthModA) * LFNoise1.kr(3).range(0.2,1.0);
var modOsc2 = Pulse.ar(mod2, widthModB ) * LFNoise1.kr(2).range(0.3,0.9);
var envA = LFNoise2.kr(0.1).range(0.1, 1.0);
var envB = LFNoise2.kr(0.1).range(0.1, 1.0);
finalFreqA = freqA + ( modOsc1 * (mod1*index) );
finalFreqB = freqB + ( modOsc2 * (mod2*index) );
osc1 = SinOsc.ar([finalFreqA, finalFreqA + 0.1]) * envA * levelA;
osc2 = SinOsc.ar([finalFreqB + 0.1, finalFreqB]) * envB * levelB;
sig = osc1 + osc2;
sig = LPF.ar(sig, cFreq);
sig = sig.distort;
sig = sig + Fb({|fb| fb*feedback + (sig * 0.5) }, 1.0, delay);
sig = sig.clip(-0.9, 0.9);
sig = sig.wrap(wrap * -1 , wrap); // Very nice agressive distortion
sig = LeakDC.ar(sig);
sig = Limiter.ar(sig, 0.98);
sig * amp
});
)
Ndef(\reverb) <<>.in1 Ndef(\drone);
Ndef(\reverb).play;
Ndef(\drone).set(\freq, 80);
///////////////////////////////////////////////
// The same with a SynthDef
///////////////////////////////////////////////
(
SynthDef(\reverb, {
| in = 2, roomsize = 200, revtime = 40, damping = 0.1, inputbw = 0.5,
spread = 15, drylevel = 0.2, earlylevel = 0.1, taillevel = 0.2, wet = 0.8 |
var sig = \in1.ar;
sig = GVerb.ar(sig, roomsize,
revtime,
damping,
inputbw,
spread,
drylevel,
earlylevel,
taillevel,
roomsize,
mul: wet );
Out.ar(0, sig)
}).add;
SynthDef(\drone, { |
freq = 20 , levelA = 0.25, levelB = 0.1, index = 1,
harmonicity = 2, cFreq = 1000, feedback = 0, delay = 0.1, amp = 1.0, wrap = 1.0 |
var osc1, osc2, sig, finalFreqA, finalFreqB;
var freqA = freq;
var freqB = freq * 2;
var mod1 = freqA * harmonicity;
var mod2 = freqB * harmonicity;
var widthModA = SinOsc.ar(freq * 0.01).range(0.0,1.0);
var widthModB = SinOsc.ar(freq * 0.005).range(0.0,1.0);
var modOsc1 = Pulse.ar(mod1, widthModA) * LFNoise1.kr(3).range(0.2,1.0);
var modOsc2 = Pulse.ar(mod2, widthModB ) * LFNoise1.kr(2).range(0.3,0.9);
var envA = LFNoise2.kr(0.1).range(0.1, 1.0);
var envB = LFNoise2.kr(0.1).range(0.1, 1.0);
finalFreqA = freqA + ( modOsc1 * (mod1*index) );
finalFreqB = freqB + ( modOsc2 * (mod2*index) );
osc1 = SinOsc.ar([finalFreqA, finalFreqA + 0.1]) * envA * levelA;
osc2 = SinOsc.ar([finalFreqB + 0.1, finalFreqB]) * envB * levelB;
sig = osc1 + osc2;
sig = LPF.ar(sig, cFreq);
sig = sig.distort;
sig = sig + Fb({|fb| fb*feedback + (sig * 0.5) }, 1.0, delay);
sig = sig.clip(-0.9, 0.9);
sig = sig.wrap(wrap * -1 , wrap); // Very nice agressive distortion
sig = LeakDC.ar(sig);
sig = Limiter.ar(sig, 0.98);
sig * amp;
Out.ar(0, sig);
}).add;
)
(
~rev = Group(s);
~drone = Synth(\drone,[\freq, 40], ~rev);
)
~drone.set(\freq, 40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment