Thinking in csharp

Clyde Carey
2 min readDec 24, 2020

--

I’ve long been doing my best to start learning how to give instructions. To really describe tasks in detail. To really find ways of explaining the nature of nouns and the functions of verbs. Even with simpler programming languages aimed at Digital Signal Processing in blocks, I’ve traditionally had a very hard time with even rather simple flow of operations. Even something as seemingly simple as a ping pong delay has been rather elusive.

slider1:0<0,13000,1>Delay (ms) (0=tempo sync)
slider2:-5<-120,6,1>Feedback (dB)
slider3:0<-120,6,1>Mix In (dB)
slider4:-6<-120,6,1>Output Wet (dB)
slider5:0<-120,6,1>Output Dry (dB)
slider6:0<0,100,1>Ping-Pong Width (%)
slider7:0.25<0.0625,4,0.0625>Tempo Sync (fraction of whole note)

in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output

@init
delaypos=0;
pongloc=0;

@slider
odelay=delaylen;
beat = 240 * slider7;
wetmix = 2 ^(slider2/6);
drymix = 2 ^(slider3/6);
wetmix2 = 2 ^(slider4/6);
drymix2 = 2 ^(slider5/6);
pongwidth = slider6/100;
pongpan=(1-pongwidth)/2;

@block
slider1==0 ? (
delaylen=min((beat / tempo)*srate,500000);
):(
delaylen=min(slider1 * srate / 1000,500000);
);

@sample
dpint = delaypos*2;
os1=dpint[0];
os2=dpint[1];

dpint[0]=min(max(spl0*drymix + os1*wetmix,-4),4);
dpint[1]=min(max(spl1*drymix + os2*wetmix,-4),4);

switching=0;

abs(delaypos)<400 ? (
switch = pongloc ? abs(delaypos)/400 : ((400 — abs(delaypos))/400);
);

(delaypos+=1) >= delaylen ? (
delaypos=0;
pongloc = (pongloc * -1) + 1;
);

os = (os1 + os2) / 2;
panloc = pongpan + pongwidth * switch;

spl0=spl0*drymix2 + os*wetmix2*(panloc);
spl1=spl1*drymix2 + os*wetmix2*(1-panloc);

I have two problems here. One of course is being able to read the code and knowing what its doing exactly. THAT I’m getting better at.

The second is being able to describe, in a way that can be translated to actual code, the logic, the steps, that go into it.

In the course of this Unity journey, I am more and more able to describe those steps. 95% of the time, I am wrong, and need to tweak the code over and over until I get the behavior I expected, but that’s much much better than the 99% of the time just a few weeks ago.

The big surprise, that began really happening to me over the weekend, is that in my head, when I’m not even at the computer, I have begun instinctively describing these steps in c# syntax! I’m beginning to think directly in the language itself, hopefully that’s a good thing!

--

--

No responses yet