1
0
Fork 0

first real commit

main
Luka Prinčič 2020-12-14 02:18:17 +01:00
parent fe7a1da952
commit 46b098cc38
2 changed files with 393 additions and 0 deletions

130
scd/lib/octoPanOut.scd Normal file
View File

@ -0,0 +1,130 @@
(
// a function to position sound in space
~octoPanOut = {
arg in, in_x, in_y, fact;
var s1_x=0, s1_y=0, s1_amp,
s2_x=0, s2_y=360, s2_amp,
s3_x=0, s3_y=720, s3_amp,
s4_x=0, s4_y=1080, s4_amp,
s5_x=650, s5_y=1260, s5_amp,
s6_x=650, s6_y=900, s6_amp,
s7_x=650, s7_y=540, s7_amp,
s8_x=650, s8_y=180, s8_amp ;
var factor = (1 / (5000000 * fact)); // exponential curve of amplification calculated from distance? log????
//var distance = {|x1,y1,x2,y2| ((x2-x1).squared + (y2-y1).squared).sqrt};
var distance = {|x1,y1,x2,y2| (x2-x1) hypot: (y2-y1) }; // hypothenuse
var amp = 1 / (1 + (distance.cubed * factor));
//in_x = (in_x + 1) * 0.5 * 650;
in_x = in_x * 650;
//in_y = (in_y + 1) * 0.5 * 1260;
in_y = in_y * 1260;
s1_amp = amp.value(in_x,in_y,s1_x,s1_y);
s2_amp = amp.value(in_x,in_y,s2_x,s2_y);
s3_amp = amp.value(in_x,in_y,s3_x,s3_y);
s4_amp = amp.value(in_x,in_y,s4_x,s4_y);
s5_amp = amp.value(in_x,in_y,s5_x,s5_y);
s6_amp = amp.value(in_x,in_y,s6_x,s6_y);
s7_amp = amp.value(in_x,in_y,s7_x,s7_y);
s8_amp = amp.value(in_x,in_y,s8_x,s8_y);
[in * s1_amp, in * s2_amp, in * s3_amp, in * s4_amp, in * s5_amp, in * s6_amp, in * s7_amp, in * s8_amp]
};
SynthDef("octoPanner", {
arg inBus, x=0, y=0.14, radius=1, outBus;
var snd = In.ar(inBus,1);
snd = ~octoPanOut.value(snd, x, y, radius);
Out.ar(outBus, snd);
}).add;
);
(
SynthDef("reverBusser", {
arg inBus, outBus, verb1wet=0, verb2wet=0, verb3wet=0, verb4wet=0;
var verb1, verb2, verb3, verb4;
var snd = In.ar(inBus, 8);
snd.put(0, Limiter.ar(in:snd.at(0), level:-6.dbamp, dur:0.04));
snd.put(1, Limiter.ar(in:snd.at(1), level:-6.dbamp, dur:0.04));
snd.put(2, Limiter.ar(in:snd.at(2), level:-6.dbamp, dur:0.04));
snd.put(3, Limiter.ar(in:snd.at(3), level:-6.dbamp, dur:0.04));
snd.put(4, Limiter.ar(in:snd.at(4), level:-6.dbamp, dur:0.04));
snd.put(5, Limiter.ar(in:snd.at(5), level:-6.dbamp, dur:0.04));
snd.put(6, Limiter.ar(in:snd.at(6), level:-6.dbamp, dur:0.04));
snd.put(7, Limiter.ar(in:snd.at(7), level:-6.dbamp, dur:0.04));
verb1 = JPverb.ar(snd.at([0,1]) * verb1wet);
verb2 = JPverb.ar(snd.at([2,3]) * verb2wet);
verb3 = JPverb.ar(snd.at([4,5]) * verb3wet);
verb4 = JPverb.ar(snd.at([6,7]) * verb4wet);
snd.put(0, snd.at(0) + verb1.at(0) );
snd.put(1, snd.at(1) + verb1.at(1) );
snd.put(2, snd.at(2) + verb2.at(0) );
snd.put(3, snd.at(3) + verb2.at(1) );
snd.put(4, snd.at(4) + verb3.at(0) );
snd.put(5, snd.at(5) + verb3.at(1) );
snd.put(6, snd.at(6) + verb4.at(0) );
snd.put(7, snd.at(7) + verb4.at(1) );
Out.ar(outBus, snd);
}).add;
);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// pseudo-UGen proposition by 'elgiano'
// https://scsynth.org/t/simple-spatialisation-function-synthdef-pseudo-ugen-or-ugen/1783/5
/*
OctoPan : MultiOutUGen {
classvar <>speakers = #[
[0,0],[0,360],[0,720],[0,1080],[650,1260],[650,900],[650,540],[650,180]
];
*ar { arg in,x=0,y=0,speakers;
^this.multiNew('audio', in,x,y);
}
*new1 { arg rate,in,x,y;
var amps = this.speakers.collect{|coords|
var dist = coords - [x,y];
1/(1+dist[0].hypot(dist[1]))
};
^in*amps;
}
}
*/

263
scd/octopoda.scd Normal file
View File

@ -0,0 +1,263 @@
(/*
Copyright (c) 2020 Luka Prinčič, All rights reserved.
This program is free software distributed under
GNU General Public Licence. See COPYING for more info.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TECHNOKINSHIP - OCTOPODA ////////////////////////////////////
██████╗ ██████╗████████╗ ██████╗ ██████╗ ██████╗ ██████╗ █████╗
██╔═══██╗██╔════╝╚══██╔══╝██╔═══██╗██╔══██╗██╔═══██╗██╔══██╗██╔══██╗
██║ ██║██║ ██║ ██║ ██║██████╔╝██║ ██║██║ ██║███████║
██║ ██║██║ ██║ ██║ ██║██╔═══╝ ██║ ██║██║ ██║██╔══██║
╚██████╔╝╚██████╗ ██║ ╚██████╔╝██║ ╚██████╔╝██████╔╝██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
*/
#[\internal, \local].do { |s|
s = Server.perform(s);
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 8;
s.options.memSize = 2097152; // 2 gigs
};
Server.default.waitForBoot {
// library path
var libPath = PathName(thisProcess.nowExecutingPath.dirname +/+ "lib");
// for each files in that lib folder
libPath.filesDo({|afile|
// tell me what you're executing:
postln(" ." + afile.fileName);
// execute it:
this.executeFile(afile.fullPath);
});
});
// octoPan busses //////////////
(
// free busses and panners when re-trying things?
~octoBus1.free; ~octoBus2.free; ~octoBus3.free; ~octoBus4.free;
~panBus1x.free; ~panBus1y.free; ~panBus1r.free;
~panBus2x.free; ~panBus2y.free; ~panBus2r.free;
~panBus3x.free; ~panBus3y.free; ~panBus3r.free;
~panBus4x.free; ~panBus4y.free; ~panBus4r.free;
~revBus.free;
// octoBus1 + panners and control busses:
~octoBus1 = Bus.audio(s,1);
~panBus1x = Bus.control(s,1);
~panBus1y = Bus.control(s,1);
~panBus1r = Bus.control(s,1);
~panBus1y.value = 0.14; // set a fixed value to a bus
~panBus1x.value = 0;
~panBus1r.value = 1;
// octoBus2 + panners and control busses:
~octoBus2 = Bus.audio(s,1);
~panBus2x = Bus.control(s,1);
~panBus2y = Bus.control(s,1);
~panBus2r = Bus.control(s,1);
~panBus2y.value = 0.14; // set a fixed value to a bus
~panBus2x.value = 0;
~panBus2r.value = 2;
// octoBus3 + panners and control busses:
~octoBus3 = Bus.audio(s,1);
~panBus3x = Bus.control(s,1);
~panBus3y = Bus.control(s,1);
~panBus3r = Bus.control(s,1);
~panBus3y.value = 0.14; // set a fixed value to a bus
~panBus3x.value = 0;
~panBus3r.value = 2;
// octoBus4 + panners and control busses:
~octoBus4 = Bus.audio(s,1);
~panBus4x = Bus.control(s,1);
~panBus4y = Bus.control(s,1);
~panBus4r = Bus.control(s,1);
~panBus4y.value = 0.14; // set a fixed value to a bus
~panBus4x.value = 0;
~panBus4r.value = 2;
// 8chan reverb bus
~revBus = Bus.audio(s,8);
">>> loaded all busses".postln;
);
r = Recorder(s);
r.recHeaderFormat = "wav";
r.record(numChannels:8);
r.stopRecording;
( ///////////////////////////////////////////////////////////////////////////////
var timeLine;
"\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>".postln;
"--- O C T O P O D A -----".postln;
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n".postln;
"--- loading octoPanners ...".postln;
~octoPanner1 = Synth("octoPanner", [\inBus, ~octoBus1, \outBus, ~revBus], addAction: \addToTail);
~octoPanner1.map(\x, ~panBus1x);
~octoPanner1.map(\y, ~panBus1y);
~octoPanner1.map(\radius, ~panBus1r);
~octoPanner2 = Synth("octoPanner", [\inBus, ~octoBus2, \outBus, ~revBus], addAction: \addToTail);
~octoPanner2.map(\x, ~panBus2x);
~octoPanner2.map(\y, ~panBus2y);
~octoPanner2.map(\radius, ~panBus2r);
~octoPanner3 = Synth("octoPanner", [\inBus, ~octoBus3, \outBus, ~revBus], addAction: \addToTail);
~octoPanner3.map(\x, ~panBus3x);
~octoPanner3.map(\y, ~panBus3y);
~octoPanner3.map(\radius, ~panBus3r);
~octoPanner4 = Synth("octoPanner", [\inBus, ~octoBus4, \outBus, ~revBus], addAction: \addToTail);
~octoPanner4.map(\x, ~panBus4x);
~octoPanner4.map(\y, ~panBus4y);
~octoPanner4.map(\radius, ~panBus4r);
// 4 x stereo reverbs are fixed to outputs ([0,1][2,3][4,5][6,7]) not panners!
~reverb = Synth("reverBusser", [\inBus, ~revBus, \outBus, 0], addAction: \addToTail);
// some default oscilations of pan and reverb
~panner1y.free; ~panner2y.free; ~panner3y.free; ~panner4y.free;
~panner1x.free; ~panner2x.free; ~panner3x.free; ~panner4x.free;
~reverb1wetBus.free; // ~wetOsc.free; // clean up
~reverb2wetBus.free; // ~wetOsc.free; // clean up
~reverb3wetBus.free; // ~wetOsc.free; // clean up
~reverb4wetBus.free; // ~wetOsc.free; // clean up
~reverb1wetBus = Bus.control(s, 1); // create control bus
~reverb.map(\verb1wet, ~reverb1wetBus); // map an argument to control bus
~reverb2wetBus = Bus.control(s, 1); // create control bus
~reverb.map(\verb2wet, ~reverb2wetBus); // map an argument to control bus
~reverb3wetBus = Bus.control(s, 1); // create control bus
~reverb.map(\verb3wet, ~reverb3wetBus); // map an argument to control bus
~reverb4wetBus = Bus.control(s, 1); // create control bus
~reverb.map(\verb4wet, ~reverb4wetBus); // map an argument to control bus
~wetOsc1.free; ~wetOsc2.free; ~wetOsc3.free; ~wetOsc4.free;
~wetOsc1 = SynthDef(\randomVerb1, {Out.kr(~reverb1wetBus, LFNoise2.kr(1).range(0, 0.8)) }).play;
~wetOsc2 = SynthDef(\randomVerb2, {Out.kr(~reverb2wetBus, LFNoise2.kr(1).range(0, 0.8)) }).play;
~wetOsc3 = SynthDef(\randomVerb3, {Out.kr(~reverb3wetBus, LFNoise2.kr(1).range(0, 0.8)) }).play;
~wetOsc4 = SynthDef(\randomVerb4, {Out.kr(~reverb4wetBus, LFNoise2.kr(1).range(0, 0.8)) }).play;
// ~wetOsc.free;
// ~reverb.set(\verb1wet, 0);
// ~reverb.set(\verb1wet, 1);
// ~reverb.set(\verb2wet, 1);
//);
//(
//var timeLine;
/*
timeLine = Routine {
"--- starting main routine ...".postln;
"--- end of the TIMELINE ---".postln
};
timeLine.play;
*/
);
// testing stuff! ///////////////////////////////////////////////////////////////////////////////////////
// do stuff with panning:
"--- starting panner1y sin Oscilation ...".postln;
~panner1y = SynthDef(\sinPanY1, { Out.kr(~panBus1y, SinOsc.kr(0.01).range(0.3,0.5))}).play;
~panBus1x.value = 1;
~panBus1r.value = 1;
"--- return to static duration, abruptly...".postln;
~panner1y.free; ~panner2y.free;
~panBus1y.value = 0.1;
~soil1.set(\dur, 0.0001);
wait(1);
~soil2.set(\dur, 0.0001);
~panBus2y.value = 0.9;
~panBus1y.value = 0; // set a fixed value to a bus
~panBus1x.value = 0;
~panBus1r.value = 0.1;
// or
~paner2y.free; ~panner3y.free; ~panner4y.free; ~panner2x.free; ~panner3x.free; ~panner4x.free;
~panner1y = SynthDef(\randomPanY1, { Out.kr(~panBus1y, LFNoise1.kr(0.1).range(0,1))}).play;
~panner2y = SynthDef(\randomPanY2, { Out.kr(~panBus2y, LFNoise1.kr(2).range(0,1))}).play;
~panner3y = SynthDef(\randomPanY3, { Out.kr(~panBus3y, LFNoise1.kr(1).range(0,1))}).play;
~panner4y = SynthDef(\randomPanY4, { Out.kr(~panBus4y, LFNoise1.kr(1).range(0,1))}).play;
~panner2x = SynthDef(\randomPanX2, { Out.kr(~panBus2x, LFPulse.kr(0.3).range(0,1))}).play;
~panner3x = SynthDef(\randomPanX3, { Out.kr(~panBus3x, LFPulse.kr(0.44).range(0,1))}).play;
~panner4x = SynthDef(\randomPanX4, { Out.kr(~panBus4x, LFPulse.kr(0.22).range(0,1))}).play;
// ... etc /////////////////////////////////////////////////////////////////////////////////
(
SynthDef(\fhnTrigRing, {
arg out=0, freq=1000, min=1, max=10, decay=0.1, ffreq=1000, amp=1, gate=1, fadeTime=1;
var snd, in, env;
in = FhnTrig.ar(min,max);
snd = Ringz.ar(in, freq, decay);
snd = LPF.ar(snd, ffreq);
env = EnvGen.kr(
Env([0, 1, 0], [fadeTime, fadeTime], \sin, 1),
gate, doneAction: Done.freeSelf);
snd = snd * env * amp;
Out.ar(out,snd)
}).add;
);
~fhnTrig2 = Synth(\fhnTrigRing, [\out, ~octoBus1, \freq, 2110, \amp, 0.5, \min, 2, \max, 20, \amp, 0.5, \fadeTime, 10]);
~fhnTrig2.free;
~hpfHenon = Synth(\henonLsynth1, [\out, ~octoBus3, \hpfreqmin, 100]);
~hpfHenon = Synth(\henonLsynth1, [\out, ~octoBus1, \hpfreqmin, 100]);
~hpfHenon.set(\hpfreqmin, 1000)
~hpfHenon.free;
~bassLatoo = Synth(\latooThroBass, [\out, ~octoBus1, \amp, 0.2]);
~bassLatoo.free;
~henonSquare = Synth(\henonSquare, [\out, ~octoBus1, \amp, 0.2]);
~henonSquare.set(\gate,0);
// recording
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -