Jump to content
Why become a member? ×

Build your own MIDI controller. (I did!)


stoo

Recommended Posts

53 minutes ago, stoo said:

 

Fair enough - but the two different versions I've made and posted the details for use completely different codebases - so if you're asking questions about the code, we'd need to work out which one you're starting from as the answers will probably be different depending on which you've chosen.

 

 

Ah in that case - both of the ones I wrote send on channel 1 by default. And the HX stomp listens on channel 1 by default as well....

The only one I’ve been working with is the midiswtch4x2v0.2

  • Like 1
Link to comment
Share on other sites

On 14/01/2023 at 13:13, stoo said:

 

Fair enough - but the two different versions I've made and posted the details for use completely different codebases - so if you're asking questions about the code, we'd need to work out which one you're starting from as the answers will probably be different depending on which you've chosen.

 

 

Ah in that case - both of the ones I wrote send on channel 1 by default. And the HX stomp listens on channel 1 by default as well....

So I should technically be able to use this program with either 4 or 8 buttons and with or without a LED?

Link to comment
Share on other sites

4 minutes ago, stringvelocity said:

So I should technically be able to use this program with either 4 or 8 buttons and with or without a LED?

 

The arduino definitely won't care if you have less buttons..... it can't tell the difference between a button you aren't pressing and a button that doesn't exist.

 

I think you'd probably be fine with no OLED, but you'd have to test it and try.... I know the display startup sequence will flash an error LED if it doesn't correctly detect the OLED, but can't remember if it just flashes and moves on, or keeps blinking until you fix the problem. Either way, would only need to remove the display related bits of the code for it to work again.

Link to comment
Share on other sites

On 14/01/2023 at 13:13, stoo said:

 

Fair enough - but the two different versions I've made and posted the details for use completely different codebases - so if you're asking questions about the code, we'd need to work out which one you're starting from as the answers will probably be different depending on which you've chosen.

 

 

Ah in that case - both of the ones I wrote send on channel 1 by default. And the HX stomp listens on channel 1 by default as well....

Is it possible to change the 2 switch press to send a CC instead of pageup or down?

Link to comment
Share on other sites

4 hours ago, stringvelocity said:

Is it possible to change the 2 switch press to send a CC instead of pageup or down?

 

Sure - just look for this bit:

void changePageUp() {
  currentPage++;
  if (currentPage >= pageCount) { // we have gone past the last page
    currentPage = 0; // reset to first page
  }
}

void changePageDown() {
  currentPage--;
  if (currentPage > pageCount) { // we have scrolled back past the first page
    currentPage = (pageCount -1); // reset to last page
  }
}

 

And change it to something like :

 

void changePageUp() { // function adapted to send MIDI CC instead of controller Page Up
  const byte controlNumber = 49; // MIDI CC# number to send - CC49 is FS1
  const byte controlValue = 0; // MIDI Value to send - can be any 0-127 for CC49 -> FS1
  const byte midiSendChannel = 1; // MIDI channel to send this message on
  MIDI.sendControlChange(controlNumber,controlValue,midiSendChannel);
}

void changePageDown() { // function adapted to send MIDI CC instead of controller Page Down
  const byte controlNumber = 68; // MIDI CC# number to send - CC68 is tuner on/off
  const byte controlValue = 0; // MIDI Value to send - can be any 0-127 for CC68 -> tuner on/off
  const byte midiSendChannel = 1; // MIDI channel to send this message on
  MIDI.sendControlChange(controlNumber,controlValue,midiSendChannel);
}

 

Ideally you'd also also go through and change all the PageUp and PageDown functions, variable names and comments elsewhere to make things easier to follow / troubleshoot when you next come to look at the code. I'll leave that up to you to decide whether to bother though...

Link to comment
Share on other sites

5 hours ago, stoo said:

 

Sure - just look for this bit:

void changePageUp() {
  currentPage++;
  if (currentPage >= pageCount) { // we have gone past the last page
    currentPage = 0; // reset to first page
  }
}

void changePageDown() {
  currentPage--;
  if (currentPage > pageCount) { // we have scrolled back past the first page
    currentPage = (pageCount -1); // reset to last page
  }
}

 

And change it to something like :

 

void changePageUp() { // function adapted to send MIDI CC instead of controller Page Up
  const byte controlNumber = 49; // MIDI CC# number to send - CC49 is FS1
  const byte controlValue = 0; // MIDI Value to send - can be any 0-127 for CC49 -> FS1
  const byte midiSendChannel = 1; // MIDI channel to send this message on
  MIDI.sendControlChange(controlNumber,controlValue,midiSendChannel);
}

void changePageDown() { // function adapted to send MIDI CC instead of controller Page Down
  const byte controlNumber = 68; // MIDI CC# number to send - CC68 is tuner on/off
  const byte controlValue = 0; // MIDI Value to send - can be any 0-127 for CC68 -> tuner on/off
  const byte midiSendChannel = 1; // MIDI channel to send this message on
  MIDI.sendControlChange(controlNumber,controlValue,midiSendChannel);
}

 

Ideally you'd also also go through and change all the PageUp and PageDown functions, variable names and comments elsewhere to make things easier to follow / troubleshoot when you next come to look at the code. I'll leave that up to you to decide whether to bother though...

Thank you

  • Like 1
Link to comment
Share on other sites

On 16/01/2023 at 11:41, stoo said:

 

The arduino definitely won't care if you have less buttons..... it can't tell the difference between a button you aren't pressing and a button that doesn't exist.

 

I think you'd probably be fine with no OLED, but you'd have to test it and try.... I know the display startup sequence will flash an error LED if it doesn't correctly detect the OLED, but can't remember if it just flashes and moves on, or keeps blinking until you fix the problem. Either way, would only need to remove the display related bits of the code for it to work again.

Is there a big difference in programming the nano vs the nano every?

Link to comment
Share on other sites

On 21/01/2023 at 03:33, stoo said:

 

Sure - just look for this bit:

void changePageUp() {
  currentPage++;
  if (currentPage >= pageCount) { // we have gone past the last page
    currentPage = 0; // reset to first page
  }
}

void changePageDown() {
  currentPage--;
  if (currentPage > pageCount) { // we have scrolled back past the first page
    currentPage = (pageCount -1); // reset to last page
  }
}

 

And change it to something like :

 

void changePageUp() { // function adapted to send MIDI CC instead of controller Page Up
  const byte controlNumber = 49; // MIDI CC# number to send - CC49 is FS1
  const byte controlValue = 0; // MIDI Value to send - can be any 0-127 for CC49 -> FS1
  const byte midiSendChannel = 1; // MIDI channel to send this message on
  MIDI.sendControlChange(controlNumber,controlValue,midiSendChannel);
}

void changePageDown() { // function adapted to send MIDI CC instead of controller Page Down
  const byte controlNumber = 68; // MIDI CC# number to send - CC68 is tuner on/off
  const byte controlValue = 0; // MIDI Value to send - can be any 0-127 for CC68 -> tuner on/off
  const byte midiSendChannel = 1; // MIDI channel to send this message on
  MIDI.sendControlChange(controlNumber,controlValue,midiSendChannel);
}

 

Ideally you'd also also go through and change all the PageUp and PageDown functions, variable names and comments elsewhere to make things easier to follow / troubleshoot when you next come to look at the code. I'll leave that up to you to decide whether to bother though...

 

1 minute ago, stringvelocity said:

Is there a big difference in programming the nano vs the nano every?

 

Link to comment
Share on other sites

13 hours ago, stringvelocity said:

Is there a big difference in programming the nano vs the nano every?

 

Dunno - I haven't used the Nano Every, but it looks like it's the same form factor as an original Nano, but with a different processor.

 

I would guess they've tried to make it backwards compatible with code written for the original Nano, but there's always the risk that a library has tried to refer to specific parts of the hardware directly to maximise speed or efficiency.

 

Link to comment
Share on other sites

14 hours ago, stringvelocity said:

Is there a big difference in programming the nano vs the nano every?

 

From arduino.cc: "If you used Arduino Nano in your projects in the past, the Nano Every is a pin-equivalent substitute. Your code will still work, and you will NOT need to re-wire those motors you planned in your original design. The main differences are: a better processor, and a micro-USB connector."

  • Like 2
Link to comment
Share on other sites

3 minutes ago, tauzero said:

 

From arduino.cc: "If you used Arduino Nano in your projects in the past, the Nano Every is a pin-equivalent substitute. Your code will still work, and you will NOT need to re-wire those motors you planned in your original design. The main differences are: a better processor, and a micro-USB connector."

 

Bit more info on why I thought that might not always be the case:

 

https://emalliab.wordpress.com/2021/12/15/getting-to-know-the-arduino-nano-every/

 

Might be worrying about nothing for most use cases, but suspect it'll just depend on which libraries you end up using...

Link to comment
Share on other sites

11 hours ago, stoo said:

 

Bit more info on why I thought that might not always be the case:

 

https://emalliab.wordpress.com/2021/12/15/getting-to-know-the-arduino-nano-every/

 

Might be worrying about nothing for most use cases, but suspect it'll just depend on which libraries you end up using...

 

Right, I was going by the claims on the Arduino website.

Link to comment
Share on other sites

Hey @Stoo i was making the hx stomp switcher 2 , i was havin the same issue of Guillame, on page 6 of this topic, i followed your instruction and woah he nextion work but, yes there's another terrible issue, when i press the switch nothing happen but when i press The switch on pin 0 and pin 1 this makes the rx and lx led blink, soooo did you have any suggestion about? what can be wrong about? thank you stooo you are super!

Edited by DaveHx
Link to comment
Share on other sites

On 02/03/2019 at 13:16, stoo said:

I posted about this in the HX stomp thread, but in case it's of wider interest I thought I'd best make a separate one.

I wanted to add some more control options to my Stomp and was looking at controllers like the Morningstar MC6, but couldn't justify the £200 outlay.. so looked into making one myself - and it's turned out to be far easier and cheaper than I expected.

Total cost for all the electronics and switches is about £25 -30 depending on how confident you are at slightly fiddly soldering... the extra few quid gets you a pre-soldered microcontroller and an adaptor board with screw terminals, so the only soldering you'd need to do is for the wires to the tags on the footswitches and on the MIDI socket.

And then you'll need something to house it in. I made a 3d printed enclosure for mine, but any box you can buy/build/modify will do.

If anyone's interested in making something similar for themselves, I'd be happy to share wiring diagrams and the code I used. I'm no electronic engineer or programmer, so no doubt there's plenty of room for improvement, but I've got it to work well enough to do what I need it to, and maybe it'll work for you too? I'm happy to help with tweaking it for slightly different configurations if you'd want a different layout.

What it does:

You press a footswitch, and it sends a MIDI message. The way I have mine setup is that it either sends a MIDI PC (Program Change) message to change preset patch on my HX stomp, or a MIDI CC (Control Change) message to change any of a number of other settings or parameters. It could potentially send MIDI notes as well if you wanted to use it as a pedal keyboard to play a synth with, I suppose.

If you hold a footswitch down, it can send a different MIDI message (I only use this for activating the tuner by holding the tap tempo button so far, but it could be setup for any of the switches)

If you press more than one footswitch down at once, it can do something else again depending on which ones you press. Mine is set so that pressing 1+2 or 2+3 switches through different pages / banks of button configurations, and pressing 7 + 8 is a sort of panic mode which resets the HX stomp to preset 1, and resets the controller back to the first page.

What it can't do:

It's not programmable from the unit. To change the way the buttons are configured you need to tweak the code and then re-upload it. There's probably a more elegant way to deal with this, but it works well enough for me as is - I don't expect to need to reconfigure it very often once I've got it set up.

Right - I'm gonna stop there for now.... if no-one's interested then I'm just rambling into the void for nowt. If anyone is interested though, let us know and I can post more details. Or, if you know more than me and can spot where I've gone wrong or what I should have done better - lemme know and I'll try and improve it!

 

Cheers,

 

stoo

IMG_20190227_152329-med.jpg

IMG_20190301_202755-med.jpg

This is great but I have found an issue with pressing two buttons at once… not sure if the bounce needs to be change or if it’s my buttons… it seems to either go on/off or skip to the next depending on what it’s set too.. any thoughts??

Link to comment
Share on other sites

On 29/01/2023 at 22:57, DaveHx said:

Hey @Stoo i was making the hx stomp switcher 2 , i was havin the same issue of Guillame, on page 6 of this topic, i followed your instruction and woah he nextion work but, yes there's another terrible issue, when i press the switch nothing happen but when i press The switch on pin 0 and pin 1 this makes the rx and lx led blink, soooo did you have any suggestion about? what can be wrong about? thank you stooo you are super!

 

So.... if you press the buttons on the Nextion screen, the MIDI commands get sent to the stomp as you would expect? that bit works OK?

 

Do the other switches work as you would expect on pins 2 thru 7 ?

 

Pin 0 and Pin 1 on a Mega can be used as either regular digital pin inputs, or as a Serial channel as RX0/TX0 - I'm not entirely sure if it would be expected to see TX/RX lights illuminated when using Pins 0 and 1 as digital inputs.... I never noticed it happening on mine when I was building/testing it, but I wasn't particularly looking out for it at the time. I can't easily get to mine to check it at the moment. I think if you have somehow got the nextion or the midi trying to talk on Serial0 then strange things might happen, but if you're using a Mega and your code is the same is mine, then I can't see how that'd happen....?

 

Link to comment
Share on other sites

37 minutes ago, stringvelocity said:

This is great but I have found an issue with pressing two buttons at once… not sure if the bounce needs to be change or if it’s my buttons… it seems to either go on/off or skip to the next depending on what it’s set too.. any thoughts??

 

I think I know what you mean..... If you have, for example,

- switch 0 set to toggle FS1,

- switch 1 set to toggle FS2, and

- switch 1+2 set to scroll to next page,

then when you press switches 1 and 2 it might trigger FS1 or FS2 before eventually also triggering the next page.

 

If so, then that's a limitation of the way it was written. When the Arduino scans the buttons, as soon as it detects a button press it does the action assigned to that button straight away. Then it continues to scan the button states, and if it detects another button is pressed down before the first button was released then it checks if there's an action assigned to that combination of buttons.

 

Another way of doing it would be to wait for either the first button to be released, or a second button to be pressed, before triggering the action. This would allow you to prevent accidental triggers of the single switch function when you only wanted the combo function..... but it would have a really bad side effect. If you just wanted to trigger FS1, and so stepped on switch 0.... nothing would happen until you lift your foot off the switch again. This delay might not be too noticable if you instinctively tap and release each switch very quickly all the time..... but I definitely don't do that. If you have buttons configured for looper controls instead of just effects on/off toggles then the problem gets even worse.

 

Hope that makes sense

 

 

Link to comment
Share on other sites

i tried with and without midi out, nothing happen... as you can see in the video when i press something on the screen there's a little blink, and the switch doesn't work in every pin (strange cause i checked all the connection) i noticed even the previous page button doesn't do nothing, so this makes me think probably can be something wrong on nextion? i used this link https://nextion.ca/portfolio-items/nextion-iteadlib-and-mega-step-by-step/ as you said, and there i put on my nexConfig.h

/** 
 * Define DEBUG_SERIAL_ENABLE to enable debug serial. 
 * Comment it to disable debug serial. 
 */
#define DEBUG_SERIAL_ENABLE

/**
 * Define dbSerial for the output of debug messages. 
 */
#define dbSerial Serial

/**
 * Define nexSerial for communicate with Nextion touch panel. 
 */
#define nexSerial Serial3

 

and i changed   
    dbSerialBegin(250000);
    nexSerial.begin(115200);

on NexHardware.cpp

i changed only this in your code for now, i'ts the second switcher i made based on your code, the oled was mooooooore easy 😆 maybe cause i never used a Nextion and Mega before 😅 thank you stooooo🤗

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

5 hours ago, stoo said:

 

I think I know what you mean..... If you have, for example,

- switch 0 set to toggle FS1,

- switch 1 set to toggle FS2, and

- switch 1+2 set to scroll to next page,

then when you press switches 1 and 2 it might trigger FS1 or FS2 before eventually also triggering the next page.

 

If so, then that's a limitation of the way it was written. When the Arduino scans the buttons, as soon as it detects a button press it does the action assigned to that button straight away. Then it continues to scan the button states, and if it detects another button is pressed down before the first button was released then it checks if there's an action assigned to that combination of buttons.

 

Another way of doing it would be to wait for either the first button to be released, or a second button to be pressed, before triggering the action. This would allow you to prevent accidental triggers of the single switch function when you only wanted the combo function..... but it would have a really bad side effect. If you just wanted to trigger FS1, and so stepped on switch 0.... nothing would happen until you lift your foot off the switch again. This delay might not be too noticable if you instinctively tap and release each switch very quickly all the time..... but I definitely don't do that. If you have buttons configured for looper controls instead of just effects on/off toggles then the problem gets even worse.

 

Hope that makes sense

 

 

Sounds like you know this problem…. That exactly what I’m dealing with… the two button press works ish … even the fs4 and fs5 on single press is somewhat inconsistent… that maybe the buttons though

Link to comment
Share on other sites

18 hours ago, DaveHx said:

i tried with and without midi out, nothing happen... as you can see in the video when i press something on the screen there's a little blink, and the switch doesn't work in every pin (strange cause i checked all the connection) i noticed even the previous page button doesn't do nothing, so this makes me think probably can be something wrong on nextion? i used this link https://nextion.ca/portfolio-items/nextion-iteadlib-and-mega-step-by-step/ as you said, and there i put on my nexConfig.h

/** 
 * Define DEBUG_SERIAL_ENABLE to enable debug serial. 
 * Comment it to disable debug serial. 
 */
#define DEBUG_SERIAL_ENABLE

/**
 * Define dbSerial for the output of debug messages. 
 */
#define dbSerial Serial

/**
 * Define nexSerial for communicate with Nextion touch panel. 
 */
#define nexSerial Serial3

 

and i changed   
    dbSerialBegin(250000);
    nexSerial.begin(115200);

on NexHardware.cpp

i changed only this in your code for now, i'ts the second switcher i made based on your code, the oled was mooooooore easy 😆 maybe cause i never used a Nextion and Mega before 😅 thank you stooooo🤗

 

 

 

 

Do you have your switches connected to A0-A7 ?

 

Doesn't look like anything is connected to pins 0-7 on the Arduino at all.... that's where I had my switches connected....

 

image.png.5ee666407ab5b47a919b502ab0bcb603.png

 

Link to comment
Share on other sites

In this photo i tried only the switches connected like your schematic, but it was the same yesterday, it's d0 to d7 but it's not on analog pin... by the way i tried on the analog pin and nothing happen 🥲 i think i'm at the dead point... but even with this problem i try every day, just to understand where i'm wrong 🙄 always thank you stoo!

20230202_001809.jpg

Link to comment
Share on other sites

19 hours ago, DaveHx said:

In this photo i tried only the switches connected like your schematic, but it was the same yesterday, it's d0 to d7 but it's not on analog pin... by the way i tried on the analog pin and nothing happen 🥲 i think i'm at the dead point... but even with this problem i try every day, just to understand where i'm wrong 🙄 always thank you stoo!

20230202_001809.jpg

 

I'm not sure I understand what you're attempting here..... if you only have the footswitches connected, but not the screen or the MIDI output...... then not much is going to happen!

 

If you're using the code from my project, then the switches will need to be connected to the 0-7 switches as shown in your picture.... the Analog pins at the bottom can be used for inputs, but you'd need to change the code to listen on different pins.....

 

In the video you posted above, it shows you pressing the >> button, and then the screen changing the menu page.... That shows that you had the connection between the Arduino and the Nextion working OK. (The Nextion sends a notification to the Arduino that you've pressed the button on the screen, and then the Arduino updates the menu page and then sends an instruction back to the Nextion to change the display to match)

 

Once you have the Nextion working, it's easier to test the MIDI next. Hook up the MIDI socket and your HX device and then press the FS1 button on the Nextion screen..... something should happen on the HX (as long as you're in a patch that has an action assigned to FS1!)

 

Once you know that's working, then try the switch inputs on the Arduino. If you're not 100% confident in your footswitches, leave those disconnected and just use a test wire - Connect one end of it to a spare GND pin on the arduino, and then try touching it on any of the 0-7 pins (NOT the ANALOGIN A0-A7 pins!) and see if that does anything. If that works, then you know you need to investigate the wiring for your footswitches

 

Good luck!

Link to comment
Share on other sites

Okok, thank you stoo, i checked every switch, every pin and every single wire, everything is fine, and now something changed, when I press the switch for change the page it work! But not the single switch 😮💨 but at the least something on the switchpin work! 

I noticed even something strange when I open Serial Monitor, "recvRetCommandFinished ok

 recvRetCommandFinished ok

 recvRetCommandFinished err" 

And  i don't understand what it means 😅

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...