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

Pedal Pitch Bend +- octave #1099

Open
Wallirec opened this issue Nov 24, 2024 · 7 comments
Open

Pedal Pitch Bend +- octave #1099

Wallirec opened this issue Nov 24, 2024 · 7 comments

Comments

@Wallirec
Copy link

Wallirec commented Nov 24, 2024

Thanks for the best library!
I want to make a pitch bend pedal (like Wammy).
What I've got so far: I found (here) and adjusted the sketch for my homemade pedal on a Hall sensor.
(Arduino Pro Micro).

#include <Control_Surface.h>

USBMIDI_Interface midi;

PBPotentiometer potentiometers[] = {
  { A0, CHANNEL_1, },
};

template <analog_t MinVal, analog_t MaxVal>
analog_t mappingFunction(analog_t raw) {
  raw = constrain(raw, MinVal, MaxVal);
  return map(raw, MinVal, MaxVal, 0, FilteredAnalog<>::getMaxRawValue());
}

void setup() {
  potentiometers[0].map(mappingFunction<7900, 14900>);
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}

Now the pedal lowers the sound by one tone.
I want the sound to be lowered by an octave.
And I would also like (with an additional button) to invert the pedal to increase the pitch.
Please tell me how to do this!

@Wallirec
Copy link
Author

By moving the midpoint from 0 to 7900 and adjusting MaxVal, I adjusted the counter to increase the tone.

#include <Control_Surface.h>

USBMIDI_Interface midi;

PBPotentiometer potentiometers[] = {
  { A0, CHANNEL_1, },
};

template <analog_t MinVal, analog_t MaxVal>
analog_t mappingFunction(analog_t raw) {
  raw = constrain(raw, MinVal, MaxVal);
  return map(raw, MinVal, MaxVal, 7900, FilteredAnalog<>::getMaxRawValue());
}

void setup() {
  potentiometers[0].map(mappingFunction<7900, 11900>);
  Control_Surface.begin();
}

void loop() {  
  Control_Surface.loop();
}

All that remains is to combine them and expand the pitch range - please advise!

@Wallirec Wallirec changed the title Pedal Pitch Bend +- oktava Pedal Pitch Bend +- octave Nov 25, 2024
@Wallirec
Copy link
Author

I think I'm starting to guess that the pitch bend range depends on the instrument settings.
I found a midi implementation for my instrument - tell me what I need to add to the sketch to increase the range to +- 24 semitones
Midi

@tttapa
Copy link
Owner

tttapa commented Nov 25, 2024

(Untested)

  Control_Surface.sendControlChange(MIDI_CC::RPN_MSB, 0x00);
  Control_Surface.sendControlChange(MIDI_CC::RPN_LSB, 0x00);
  Control_Surface.sendControlChange(MIDI_CC::Data_Entry_MSB, 12);
  Control_Surface.sendControlChange(MIDI_CC::Data_Entry_LSB, 0);
  Control_Surface.sendControlChange(MIDI_CC::RPN_MSB, 0x7F);
  Control_Surface.sendControlChange(MIDI_CC::RPN_LSB, 0x7F);

@Wallirec
Copy link
Author

Pieter, thanks for your response (this is not your library's problem).
Sketch does not compile - error: 'Data_Entry_LSB' is not a member of 'CS::MIDI_CC'
Control_Surface.sendControlChange(MIDI_CC::Data_Entry_LSB, 0);
suggested alternative: 'Data_Entry_MSB'

#include <Control_Surface.h>

USBMIDI_Interface midi;

PBPotentiometer potentiometers[] = {
  { A0, CHANNEL_1, },
};

template <analog_t MinVal, analog_t MaxVal>
analog_t mappingFunction(analog_t raw) {
  raw = constrain(raw, MinVal, MaxVal);
  return map(raw, MinVal, MaxVal, 7900, FilteredAnalog<>::getMaxRawValue());
}

void setup() {
  potentiometers[0].map(mappingFunction<7900, 11900>);
  Control_Surface.sendControlChange(MIDI_CC::RPN_MSB, 0x00);
  Control_Surface.sendControlChange(MIDI_CC::RPN_LSB, 0x00);
  Control_Surface.sendControlChange(MIDI_CC::Data_Entry_MSB, 12);
  Control_Surface.sendControlChange(MIDI_CC::Data_Entry_LSB, 0);
  Control_Surface.sendControlChange(MIDI_CC::RPN_MSB, 0x7F);
  Control_Surface.sendControlChange(MIDI_CC::RPN_LSB, 0x7F);
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}

@tttapa
Copy link
Owner

tttapa commented Nov 26, 2024

Are you using the latest version of the library?

@Wallirec
Copy link
Author

I updated the library and all my sketches stopped compiling (they are all on your library).

@Wallirec
Copy link
Author

Wallirec commented Nov 26, 2024

I updated all the libraries the sketch worked - Great!!!
Thank you very much!
All that remains is to combine the sketch.

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

2 participants