MIDI-bass-pedal with individual tranpose function for every of the 5 pedals, for Arduino micro

Hi,

this is my first post in this forum.
My skills in arduino programming on a scale from 0 to 10 is between 0 and 1. So I am a real beginner in that matter. My General PC skills are medium.

I spent about 3 hours of time searching in this forum and the pjrc Forum for a solution but I got not the right information for me.
For example I have carefully read the lower link for a teensy board but I have no chance to transform the code into my needs for the micro because I really understand nothing!

https://forum.pjrc.com/threads/28816-Building-A-25-Key-Midi-Pedalboard?highlight=Midi+bass+pedal

My hardware:
PC with Win 10 and a Arduino micro

So here is what I want to have:
A simple MIDI Bass Pedal with 5 non-velocity-sensitive Switches.

Functions:

  1. The pedals should send note on when pressed and note off when unpressed
  2. For each pedal I wanna have 2 small switches. The first one to transpose the Note Number for Pedal No. 1 down, the second one to transpose it up.
    For the other 4 pedals I wish to have also 2 extra switches per each pedal.
    So I will have 5 pedal switches and 10 transpose switches
    The transpose steps should work in one seminote by click and the range, let’s say about 2 octaves down and 2 octaves up

Here is the code I started with (For simplicity I only programmed one pedal):

  • /
    #include <MIDI_Controller.h> // This lets the microcontroller speak “MIDI”

const uint8_t velocity = 0b1111111; // This sets default velocity to 100% (127 value)
const uint8_t C4 = 60; // Name the note you want to play when the button is pushed(can be anything, C3…D5…E2)

Digital button1(2, 60, 1, velocity); // Format is this: button[number] (pin, note, channel, velocity)

void setup() {
// put your setup code here, to run once: nothing to put here this time

}

void loop() {
// put your main code here, to run repeatedly:
MIDI_Controller.refresh();

}

Function No1 is working well:
If pedal is pressed the synth in my DAW makes a sound, when pedal is unpressed the sound turns off.

Now my big question:
How can I implement function No. 2 ?

Thanks for every help!

Sascha

the code you posted doesn’t do anything but call refresh(). I see unused velocity and a C4 variables. i see no code inputting a pedal switch. can you post the code containing Function No 1?

can you explain what each pedal means and the “small switches”?

does a each pedal switch represent a specific note? how is it represented (are there predefined symbols or frequencies)?

does each “small” switch change the pedal switch note by +/- one semitone?

When i google ‘MIDI_Controller.h’ i get to github where the repository states:

The MIDI Controller library has been obsoleted by its successor, the Control Surface library.

Which is written and supported by one of the active members of this forum @PieterP

The library that you use doesn’t appear to have a method for doing what you want. The object object is declared with it’s outgoing note, which can not be modified. Maybe Control-Surface.h does but Pieter for sure can tell you.

Thanks for the @ @Deva_Rishi.

The Control Surface library has a Transposer class that does what you want: Transposer.ino
For your application, you would create an array of 5 transposers and an array of 5 selectors (these selectors read the small semitone up/down buttons). Finally create an array of 5 Bankable::NoteButtons and give each NoteButton its own Transposer from the array.

IIRC, you should be able to achieve something very similar using banks in the MIDI_Controller library, but it’s not as simple and as mentioned on GitHub, I no longer provide support for MIDI_Controller, so I highly recommend upgrading to Control Surface.

Hi, gcjr:
I transfered the code from Arduino IDE (1.8.13) via copy and paste into the forum and sure, the code does the follow: It reads a switch that I mounted (physically) to Pin 1 of my micro and converts the impulse on/off into my DAW. The synthesizer reacts exactly with that small part of code loaded onto my micro. I don’t know how it does it, but it does it :slight_smile:

I say small switches for the transpose-switches. These will be mounted inside the arduino housing. And the “pedal switches” are inside a self-made Footpedal with 5 big wooden “fingers”. So while making music, I can push a pedal and it produces exactly one note with a predefined notenumber, e.g. C4, that should be transposable,
because:
While I am playing this footpedalboard simultaniously with one of my handpans (aka Hang), I need a special matrix of Notes that I can play with the 5 Pedals.
For the one handpan I need a D2 on Pedal 1, an A2 on Pedal 2, an Bb2 on Pedal 3, a C3 on Pedal 4 and a D3 on pedal 5.
For the next hanpan I need a total different matrix.
So I wanna have the possibility to upper or lower each pedal note, so that I can create an individual Matrix of 5 Bass-Notes for each scale of my Handpans, depending on which I play at the moment.
(The handpans do not have a chromatical scale, each of them have individual scales, for example my D Kurd has 9 notes of the D minor note scale)

I hope that I could explain everything…

Hi PieterP
Thanks for the hint to the Controler Surface (I think I once binded it in to my Arduino Software).
How exact code do I have to insert into my sketch?
For example the bass pedal is linked to pin 1
the Transpose(+)-button for pedal 1 is mounted to Pin 2
the transpose(-)-button is mounted to pin 3

I really need help with every (for me not understandable) syntax inside the sketch otherwise I am sooo lost :wink:

In that case, you would use

Transposer<-12, +12> transposer;
IncrementDecrementSelector<transposer.getNumberOfBanks()> selector {
  transposer,
  {2, 3}, // pin +, pin -
  Wrap::Clamp,
};
Bankable::NoteButton button {
  transposer,
  1,          // pin
  note(D, 2), // MIDI address
};

Connect the pedals and buttons with one leg to the specified Arduino pin, and the other leg to ground. You do not need external pull-up resistors, the internal ones are enabled by the library.

The example code I linked to before has links to the relevant documentation for each class or function. The different constructor arguments are documented there. Some arguments are classes themselves, so you have to click those links as well.

To understand the actual C++ syntax, you’ll have to study a C++ tutorial/book/course, that’s not something you can learn from a couple of forum posts. Following a structured introduction to the language is much more productive.

Thanks, PieterP

I hope my beginner questions are not too boring :wink:
My goal is not to learn coding, i only wanna create this one project and probably than i will forget everything what i have learned here…

Now I tried this code:

#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

using namespace MIDI_Notes;

// Instantiate a Transposer that can transpose from one octave down to one
// octave up
Transposer<-12, +12> transposer;

// Instantiate a Selector to change the transposition
IncrementDecrementSelector<transposer.getNumberOfBanks()> selector = {
transposer,
{2, 3},
Wrap::Clamp,
};

// Instantiate an array of NoteButton objects
Bankable::NoteButton buttons = {
{transposer, 1, note(D, 2)}
};

void setup() {
Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
Control_Surface.loop(); // Update the Control Surface
}

it is one step closer to my goal: it does the tranpose for the pedal mounted to pin 1, that’s good.

The next question is:
How can I implement the transpose-values of the other 8 +/- switches?

Let me explain exactly what my pedalboard should do:
(Sorry for my english, it’s not my mother language…)

I will have 5 pedal-switches:
pedal 1, pedal 2, pedal 3, pedal 4, pedal 5

Now, 2 extra switches will be “assigned” to every single pedal.
So that pedal 1 has it’s own +/- switches, pedal 2 has it’s +/- switches
and so on.
In the end i will have 5 pedals and 5 + switches and 5 - switches.

I think in this code above the tranpose value is like a global tranpose function.
The question for me is how can i define 5 individual tranpose values?

I think that has been answered.

It’s not.
You pass the transposer as an argument to the NoteButton constructor. Each button can have its own Transposer.

Ok…
But where in the code must i define, on which pins the +/- switches for each pedal is soldered to?

I.e
pedal 1 is on Pin 1
It’s + switch is on pin 2
It’s - switch is on pin 3

pedal 2 is on pin 4
it’s + switch is on pin 5
and - switch is on pin 6

I can’t imagine, how this is defined in the array:

Is it the number after “transpose”?

// Instantiate an array of NoteButton objects

Bankable::NoteButton buttons = {

{transposer, 2, note(C, 4)}, {transposer, 3, note(D, 4)},

{transposer, 4, note(E, 4)}, {transposer, 5, note(F, 4)},

{transposer, 6, note(G, 4)}, {transposer, 7, note(A, 4)},

{transposer, 8, note(B, 4)}, {transposer, 9, note(C, 5)},

};

I already showed you in a previous reply.

There are 5 NoteButtons. Each NoteButton needs a Transposer which determines the transposition of the note messages it sends when pressed. You can mix and match Transposers and NoteButtons as you see fit, multiple NoteButtons can use the same transposer, or you can create a separate Transposer for each button. From what I understand, you want the latter.

// Array of transposers
Transposer<-12, +12> transposers[5];

// Array of buttons using these transposers
Bankable::NoteButton buttons[] {
  {
    transposers[0], // use the first transposer for this button
    1,              // pin connected to the pedal
    note(D, 2),     // MIDI address to send to when pressed/released
  }, {
    transposers[1], // use the second transposer for this button
    4,              // pin connected to the pedal
    note(A, 2),     // MIDI address to send to when pressed/released
  }, {
    transposers[2], // use the third transposer for this button
    7,              // pin connected to the pedal
    note(Bb, 2),    // MIDI address to send to when pressed/released
  },
  // Idem for 4th and 5th pedal
};

Note that I didn’t mention the +/- buttons yet.
You now need some code to change the transposition of the transposers. The IncrementDecrementSelector class manages a single Transposer. It reads the input from two buttons and increments or decrements the transposition of that Transposer. It is independent from the NoteButtons from before, it only directly affects the Transposers. The Transposers then affect their corresponding NoteButtons.
Since you want to be able to control the note number of each NoteButton, and therefore the transposition of each Transposer, you need 5 Selectors, one for each Transposer:

IncrementDecrementSelector<transposers[0].getNumberOfBanks()> selectors[] {
  {
    transposers[0], // control the first transposer
    {2, 3}, // using the switches connected to these pins (pin +, pin -)
    Wrap::Clamp,
  }, {
    transposers[1], // control the second transposer
    {5, 6}, // using the switches connected to these pins (pin +, pin -)
    Wrap::Clamp,
  }, {
    transposers[2], // control the third transposer
    {8, 9}, // using the switches connected to these pins (pin +, pin -)
    Wrap::Clamp,
  }
  // Idem for the 4th and 5th selector
};

Hi PieterP,

I put your lines into my sketch and it does exactly what I want !!!
And plus: there is a reset-function when + and - are pushed together :open_mouth:
You made me really happy, thanks!

One question at the end:
Does the micro have a storage function for the individual transpose setting when turned off?
It’s not the most important thing, but if a few command lines could make this possible, it would be nice

This is not something that’s supported out of the box, but you can implement this yourself with a couple of lines of code using the EEPROM library. The Transposer class has methods to get and set the transposition. IIRC, the API is not really consistent: the setter expects a zero-based index (i.e. selecting setting zero selects the lowest transposition), whereas the getter returns the actual transposition (i.e. it can be negative). This should be fixed in the 2.0 release this summer.

Ok thanks

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.