Created
April 4, 2024 17:23
-
-
Save catfact/206b25b8a2f4e81c9239c75c5a44b7ea to your computer and use it in GitHub Desktop.
stereo-experiments.scd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postln("stereoize hello"); | |
s = Server.default; | |
s.waitForBoot { | |
r = Routine { | |
// note that the bands here are not phase-corrected... | |
SynthDef.new(\splitDelay, { | |
var input = In.ar(\in.kr(0)); | |
var fc = \fc.kr(1000); | |
var lo =LPF.ar(LPF.ar(input, fc), fc); | |
var hi =HPF.ar(HPF.ar(input, fc), fc); | |
var delLo = AllpassC.ar(lo, delaytime:\delayTimeHi.kr(0.01), decaytime:0); | |
var delHi = AllpassC.ar(hi, delaytime:\delayTimeLo.kr(0.02), decaytime:0); | |
var output = delLo.dup; | |
output = output + Pan2.ar(hi, \hiDryPos.kr(-1)) + Pan2.ar(delHi, \hiWetPos.kr(1)); | |
//input.poll; | |
//[lo, hi].poll; | |
//output.poll; | |
Out.ar(\out.kr(0), output); | |
}).send(s); | |
SynthDef.new(\msMatrix, { | |
var snd = In.ar(\in.kr(0), 2); | |
var mid = snd[0] + snd[1]; | |
var side = snd[0] - snd[1]; | |
var lside = \lside.kr(1); | |
var rside = \rside.kr(1); | |
var lmid = \lmid.kr(1); | |
var rmid = \rmid.kr(1); | |
var l, r; | |
l = (mid*lmid) - (side * lside); | |
r = (mid*rmid) + (side * rside); | |
Out.ar(\out.kr(0), [l, r] * \amp.kr(0.5)); | |
}).send(s); | |
s.sync; | |
b = Dictionary.new; | |
b[\src_mono] = Bus.audio(s, 1); | |
b[\src_stereo] = Bus.audio(s, 2); | |
b[\split] = Bus.audio(s, 2); | |
b[\rebalanced] = Bus.audio(s, 2); | |
s.sync; | |
/* | |
~src_stereo_s = { | |
var hz = [\hz1.kr(109), \hz2.kr(111)]; | |
var pink = Array.fill(2, { PinkNoise.ar }) * \pinkAmp.kr(1/8); | |
var sines = hz.collect({ arg x; SinOsc.ar(x) }) * \sineAmp.kr(1/4); | |
var pulse = hz.collect({ arg x; | |
var h = LFNoise0.ar(4).linlin(-1, 1, 1, 16).round(1); | |
Pulse.ar(x * Lag2.ar(h)) | |
}) * \pulseAmp.kr(1/16); | |
var snd = pink + sines + pulse; | |
Out.ar(b[\src_stereo].index, snd) | |
}.play(target:s, addAction:\addToTail); | |
n:\addToTail); | |
*/ | |
/* | |
~src_s.set(\sineAmp, 0.125) | |
~src_s.set(\pinkAmp, 0) | |
*/ | |
~src_mono_s = { | |
var hz = [\hz1.kr(109), \hz2.kr(111)]; | |
var pink = Array.fill(2, { PinkNoise.ar }) * \pinkAmp.kr(1/8); | |
var sines = hz.collect({ arg x; SinOsc.ar(x) }) * \sineAmp.kr(1/4); | |
var pulse = hz.collect({ arg x; | |
var h = LFNoise0.ar(4).linlin(-1, 1, 1, 16).round(1); | |
Pulse.ar(x * Lag2.ar(h)) | |
}) * \pulseAmp.kr(1/16); | |
var snd = pink + sines + pulse; | |
snd = Mix.new(snd); | |
Out.ar(b[\src_mono].index, snd) | |
}.play(target:s, addAction:\addToTail); | |
/* | |
~src_pan_s = { | |
Out.ar(b[\src_stereo], Pan2.ar(In.ar(b[\src_mono], 1), \pos.kr(0)) * \amp.kr(1)); | |
}.play(target:s, addAction:\addToTail); | |
*/ | |
s.sync; | |
~split_s = Synth.new(\splitDelay, [ | |
\in, b[\src_mono].index, | |
\out, b[\split].index | |
], target:s, addAction:\addToTail); | |
s.sync; | |
~bal_s = Synth.new(\msMatrix, [ | |
\in, b[\split].index, | |
\out, b[\rebalanced].index | |
], target:s, addAction:\addToTail); | |
s.sync; | |
~sink_s = { | |
var snd = In.ar(b[\rebalanced].index, 2); | |
Out.ar(\out.kr(0), snd * \amp.kr(1.0)) | |
}.play(target:s, addAction:\addToTail); | |
{ | |
w = Window.new("split", Rect(100, 100, 300, 150)); | |
Slider(w, Rect(0, 0, 300, 30)).action_({|sl| | |
var val = sl.value.linexp(0, 1, 100, 3000); | |
("split freq: " ++ val).postln; | |
~split_s.set(\fc, val) | |
}); | |
Slider(w, Rect(0, 30, 300, 30)).action_({|sl| | |
var val = sl.value.linexp(0, 1, 0.001, 0.021) - 0.001; | |
("low delay (ms): " ++ (val * 1000)).postln; | |
~split_s.set(\delayTimeLo, val) | |
}); | |
Slider(w, Rect(0, 60, 300, 30)).action_({|sl| | |
var val = sl.value.linexp(0, 1, 0.001, 0.021) - 0.001; | |
("high delay (ms): " ++ (val*1000)).postln; | |
~split_s.set(\delayTimeHi, val) | |
}); | |
Slider(w, Rect(0, 90, 300, 30)).action_({|sl| | |
var val = sl.value.linlin(0, 1, -1, 1); | |
("high dry pos: " ++ val).postln; | |
~split_s.set(\hiDryPos, val) | |
}); | |
Slider(w, Rect(0, 120, 300, 30)).action_({|sl| | |
var val = sl.value.linlin(0, 1, -1, 1); | |
("high wet pos: " ++ val).postln; | |
~split_s.set(\hiWetPos, val) | |
}); | |
w.front; | |
}.defer; | |
{ | |
w = Window.new("rebalance", Rect(100, 100, 300, 120)); | |
Slider(w, Rect(0, 0, 300, 30)).action_({|sl| | |
var val = sl.value.linlin(0, 1, -1, 1); | |
("left side: " ++ val).postln; | |
~bal_s.set(\lside, val) | |
}); | |
Slider(w, Rect(0, 30, 300, 30)).action_({|sl| | |
var val = sl.value.linlin(0, 1, -1, 1); | |
("right side: " ++ val).postln; | |
~bal_s.set(\rside, val) | |
}); | |
Slider(w, Rect(0, 60, 300, 30)).action_({|sl| | |
var val = sl.value.linlin(0, 1, -1, 1); | |
("left mid: " ++ val).postln; | |
~bal_s.set(\lside, val) | |
}); | |
Slider(w, Rect(0, 90, 300, 30)).action_({|sl| | |
var val = sl.value.linlin(0, 1, -1, 1); | |
("right mid: " ++ val).postln; | |
~bal_s.set(\rside, val) | |
}); | |
w.front; | |
}.defer; | |
/* | |
{ b[\src_mono].scope }.defer; | |
{ b[\src_stereo].scope }.defer; | |
{ b[\split].scope }.defer; | |
*/ | |
{ b[\rebalanced].scope }.defer; | |
}.play; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment