AllenDowney / ThinkDSP

Think DSP: Digital Signal Processing in Python, by Allen B. Downey.
https://allendowney.github.io/ThinkDSP/
3.93k stars 3.2k forks source link

Should quantize be noninclusive of the upper bound? #101

Open gitonthescene opened 4 months ago

gitonthescene commented 4 months ago

Maybe there's a subtlety I'm missing, but should quantize normalize when the max(ys) >= 1? Or maybe it's more about quantize handling the upper bound.

>>> quantize(np.array([-1,0,1]), bound, np.int16)
array([-32768,      0, -32768], dtype=int16)
>>>

I was trying to follow along with the code in another programming language and was getting clicks which I tracked down to this. When eyeballing the code to try to see how thinkdsp.py handled it I spotted this.

Probably not the biggest deal or maybe I missed something but thought I'd pass it on in any event.

Regards