In the thread I mentioned above there is ~samples.size - 1. I quote the part below:
The problem is that there is no ~samples in this code, but there is ~samples1. So ~samples.size will return 0. (I think this is a typo.) So the author of the code will expect that turning the knob will change the buffer, but it will not work as intended, because val.linlin(0, 127, 0, ~samples.size - 1) is val.linlin(0, 127, 0, -1).
I can’t remember if I’ve come across cases like this before, but I usually make a lot of typos, so I’m not immune.