Smarter histogram detection for theremin (with better debugging too)