Multiple if else statements in for loop not working (bug?)
Hi all,
So I've been working on a simulation within gen~. I want different calculations if the difference in v between the cells is positive or not. what's happening right now is that it's only computing the first if else statement, the second one is completely ignored. I know this because when I put the other if else statement on top it only computes that one. here's the code:
c=in1;
dt=1/samplerate;
for(i=0;i<=dim(p)-1;i+=1){
A=0;
B=0;
vn0=peek(v, i-1);
vn=peek(v, i);
vn1=peek(v, i+1);
pn0=peek(p, i-1);
pn=peek(p, i);
pn1=peek(p, i+1);
if(vn0-vn<=0){
A=max(vn0/pn0-vn*pn, -c*pn);
}
else{
A=vn0*pn0-vn/pn;
}
if(vn1-vn<=0){
B=vn1*pn1-vn/pn;
}
else{
B=min(vn1/pn1-vn*pn, c*pn);
}
poke(a, A, i);
poke(a, B, i);
}