gligli/p600fw — pull request #44 by polluxsynth (2014-10-04 22:26:54+00:00)
Title: Release

These commits add a dead band for the bend wheel and zero-center parameters. This attempts to fix issue #24.

I've left the individual commits in place, feel free to squash them to one if you want to.

A couple of comments:
1. I've tested that the bend range ends up being exactly what it is set to, i.e. if set to an octave, operating the bend wheel will bend exactly an octave up or down. My friend who actually owns the P600 I'm working on uses this feature from time to time.
2. In order to reach the complete range, I've added a 'guard' zone in the case of the bend wheel, which is a range at the end of the pot travel where the resulting value from the ADC doesn't change. There is really the same issue with all panel pots (on the machine I have here, none of them display more than 96 or 97 as their maximum), but in trying to keep the behavior consistent across firmware upgrades, I haven't added a guard zone for the panel pots. It could easily be done if needed.
3. The dead band and guard band settings have been done empirically using the P600 I have at hand. Please do check if they seem ok for your machine too. There are separate settings for the pitch wheel and panel pots.
4. The pot value display in non-preset mode still reflects the actual pot value, not the deadband-adjusted value. I'm not sure if this is good or bad...
5. I got a bit carried away and implemented a pre-run calculation of the dead band factor. The reason is that I figure since the CPU doesn't have a division instruction, but does have multiplication instructions, division operations will be costly in terms of execution time, compared to multiplication. So instead of doing a multiplication and subsequent division to rescale the bender value, I multiply by a pre-calculated factor that leaves the resulting value in the high word of the 32-bit result, which can then be simply shifted down (with a bit of luck the compiler will just fetch the high word from the relevant registers without doing any actual shifting operations). I realize though that there are lots of other division operations so just omitting the one in the case of bend will not make a huge (or even noticeable) difference, especially since the calculation only takes place while operating the bend wheel.