Programming MIDI Banks on Teensy

Status
Not open for further replies.

MistaDee

Member
For the last little while, I've been trying to construct a MIDI controller using the Teensy 3.1, but I've run into a little bit of a snag. I have 16 arcade buttons that are each programmed to send out one MIDI note, but I also have 4 other buttons that I want to use as Bank buttons. (Essentially what they will do is that when they are pressed, they will change the Midi Note value of the Arcade buttons until another Bank button is pressed). I was wondering how exactly I would program the teensy to do that?? Any help would be great!
 
Could you post your code, and maybe I could get an idea of how you're interpreting the inputs into outputs? I'm assuming you're just using the buit-in Teensy MIDI output thingy?

EDIT: Also, it might be helpful to know which DW you plan on using the controller with.
 
Last edited:
Read the state of the four bank buttons (that gives you up to 16 values). Use that value when deciding what note to send when a note button is pressed. For example you could send all 128 MIDI notes that way. Or send on different MIDI channels. It all depends on what you want to do and what software or hardware you are interacting with.
 
Ok, but how would that look in the form of code? (I'm pretty new to the arduino/teensy languages as a whole) Just need an example to get sort of up and runnning
 
There's a lot of stuff you could do to clean up your code, but you can deal with that some other time. Probably starting with arrays, so you can keep track of the buttons easier and use for loops instead of copy/pasting everything.

Now, to add banks, you can just make a bank integer that changes whenever you press one of the ank buttons, something along the lines of

///

if bank1.fallingEdge()) {
bank = 0;
}


if bank2.fallingEdge()) {
bank = 1;
}

///

etc.

Then you could have the button add whatever the bank value is (times the number of buttons + the number of keys) to the note number.

///

if (button1.fallingEdge()) {
usbMIDI.sendNoteOn(24 + bank * 22, 127, channel);
}

///

So that when the bank is 1, the output is 24 + 22, or 46.

Now, I also noticed that you are making a Midi Fighter 3D clone. I encourage you to buy one, because they're so much more than just arcade buttons, but I'll leave that decision up to you.

DJTechTools uses a different channel for the keys on the side, and changing that wouldn't be difficult.

Good luck with your project, let me know how it turns out.
 
Thank you so much for the help (actually have a Midi fighter 3D too, it's the bomb :D), but yeah I'll post some build pics once it's done. Now I've tried something similar to this method, but it never seems to work, but I'll definitely try it out, and see how it goes.
 
Ok, so I tried what you suggested on the programming side of things, and I seem to be running into a problem. To start, here's my code (it's a shortened version with 2 banks and 1 button, but same principles apply)

#include <Bounce.h>

Bounce button1 = Bounce (0,10);
Bounce bank1 = Bounce (1,10);
Bounce bank2 = Bounce (2,10);

void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
}

void loop() {

const int channel = 1;
int bank = 1;

bank1.update();
bank2.update();
button1.update();

if (bank1.fallingEdge()) {
bank = 2;
}

if (bank2.fallingEdge()) {
bank = 3;
}

if (button1.fallingEdge()) {
usbMIDI.sendNoteOn(24 + bank * 22, 127, channel);
}

if (button1.risingEdge()) {
usbMIDI.sendNoteOff(24 + bank * 22, 127, channel);
}
}

So my problem is that no matter what bank button I press, the same MIDI note always comes out. It seems to be that when I press the button, the int "bank" doesn't seem to be changing, or I've programmed it wrong. Have I done something wrong, or do I need to approach it from a different programmming technique?
 
you have the bank variable initializer inside the loop, so every time the loop starts, it sets the bank to one again, so the bank is only ever 2 or 3 for half a cycle. Move the 'int bank = 1;' outside of the oop and you will be golden.
 
Status
Not open for further replies.
Back
Top