Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting CCPotentiometer range #1051

Open
Rolbista opened this issue Jun 13, 2024 · 3 comments
Open

Setting CCPotentiometer range #1051

Rolbista opened this issue Jun 13, 2024 · 3 comments

Comments

@Rolbista
Copy link

Is it possible to set a range for a potentiometer? Something similar to Behringer BCR2000 where you can set min value and max value when configuring a knob. If it is possible, is it possible to update it dynamically, ie. during a controller's operation, like selecting a bank?

Describe the solution you'd like
I want to be able to set a minimal and max CC value sent by a controller (potentiometer).
Let's say a synthesizer has negative modulation from 0 to 63 and positive modulation from 64 to 127. I would like to be able to set my controller to send CC messages only between 0 and 63.

Another example: I want to control a synthesizer filter cutoff, but only in a range betweet 74 and 98 (arbitrary range).

I imagine it as either being able to update a property on a CCPotentiometer class, or entering some kind of config mode to set it.

Describe alternatives you've considered
I could try setting a range by hardware on analog level (lowering 5V sent to a potentiometer as reference). That would be imprecise would not allow for arbitrary range setting.

Additional context
I already use banks to change CC number on a pot, here is the code for reference:

@tttapa
Copy link
Owner

tttapa commented Jun 14, 2024

Using the map function is indeed the recommended approach. See #483 (reply in thread) for inspiration. (In your case, you would use also change the last two arguments to the Arduino map function.)

@Rolbista
Copy link
Author

Rolbista commented Jun 18, 2024

Hi, thanks for your suggestions, I managed to get it to work, at first statically and then using the template method from thread #483
Looks like I can update ranges at runtime, but I have to pass the index literally to the template:

      potentiometers[whichPot - 1].map(mappingFunction<0>);

I still need to figure out how to pass the index dynamically, I wrote this but it doesn't compile:
https://github.com/Rolbista/MidiBoi/pull/9/files#diff-b504ffd5a862888858ea88879a136a63bd6cbe7d35c02d22570cf24d58dd6c55R226

      minimum_values[whichPot - 1] = 35;
      maximum_values[whichPot - 1] = 100;
      whichPotTemp = whichPot - 1;
      potentiometers[whichPot - 1].map(mappingFunction<whichPotTemp>);

      showLastCC = true;  

Can you suggest an approach here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants