Newbie - Midi sysex controller including saving and recalling sysex dumps

Status
Not open for further replies.
Hi all,

This is going to be my first Teensy project so I'm just looking for a bit of advice about how technical coding will be for it - I'm creating a Midi controller to modify some parameters on a sound module which can only be controlled through either NRPN/RPN or through Sysex. I'm opting for Sysex, because I am hoping that I might also be able to use the controller to send and receive sysex dumps from the module.

I can make adjustments to some parameters (Vibrato rate, depth, delay; cut off; resonance; attack; sustain; release) on the module (Roland SC-155) but it is challenging to access these from a standard midi controller without numerous button presses, and there is no way of having separate encoders assigned to each (all of the parameters are accessed through CC6). Also, the module itself cannot store a set of parameter values to be recalled, although it can send/receive sysex dumps.

So, I would have 8 rotary encoders that controlled the parameters through Sysex, a rotary potentiometer that selected which channel the encoders were active on (1-16), and then around 16 buttons which would read/write the sysex dumps.

I am comfortable in modifying some existing codes to handle some endless rotary encoders modifying the parameters, but I am unsure about the dumps.

Any advice on whether this is a little ambitious as a first project would be appreciated.

Cheers,
Lewis
 
Forget the sysex dump for now.

You may find you have more than enough challenge with the encoders and sysex messages.

Sysex may still have a byte limit hard coded in the library... not insurmountable if that's still there but it's the kind of thing that you may run into and, without some experience, can be daunting.

My posted code from my first project has a simple sysex example with send and receive of small sysex messages. There are others too...

Start small!
 
Thanks for the response. I'm thinking that I don't want to mess around making more than one controller, so perhaps I build this up on a breadboard and get the encoders dialled in, then add the buttons later.
 
If you're handy with hardware you can build the finished controller but don't get bogged down with features that are not essential too early on the software side.

Breadboarding each hardware element separately can certainly help you avoid wiring mistakes but it's the software side that really needs to be incremental.

And don't skip breadboarding Paul's tutorials if you have not programmed Arduino or Teensy before. It's fine to borrow code you partially understand but you need the basics to be successful in integrating features into your project; even if you are just merging code fragments from others.

Of the features you've listed sysex dump is by far the most challenging. Encoders can be tricky... but there are existing projects you can follow. Definitely spend time breadboarding the encoder you choose.
 
Last edited:
The hardware side is no problem, and I had thought about making it all up and then coding afterwards but I don't want to tie myself in to anything that I can't alter depending on how the coding goes.

Have you got any links to those tutorials?

Thanks
 
It finally occurred to me you need a DIN connection so your biggest hardware headache will be the midi interface

https://www.pjrc.com/teensy/td_libs_MIDI.html

In particular conversion to 3.3 volt is not well documented yet. Definitely figure out how you intend to house the tiny curcuit and its required optocoupler and breadboard it first.

Before that.... the basic tutorials are the ones off the navigation list
https://www.pjrc.com/teensy/tutorial.html

You were confidant in your first post you could alter code... but you've not said if you have any Teensy experience. I found configuring the software and learning the Arduino IDE much harder than understanding the example sketches.

Don't try to sort out encoders and midi at the same time as you work out MIDI features. I would say a potentiometer-based breadboard setup is essential.
https://www.pjrc.com/teensy/tutorial4.html

DIN-plug MIDI and usbMIDI are nearly identical to use but Arduino examples often complicate things by using serial.write to write bytes directly rather than using the libraries. Even if you're not intending midi going to your computer you should be aware of the usbmidi library and how to use it.
https://www.pjrc.com/teensy/td_midi.html

I would stick to usb midi while figuring out encoders unless you've got DIN midi fully sorted first.

https://www.pjrc.com/teensy/td_libs_Encoder.html

I have very little experience with encoders but there are lots of existing posts that cover the potential pitfalls and lots of expertise among active members.

Divide and conquer :)
 
You also need to understand buttons (digital input) and using pull-ups:
https://www.pjrc.com/teensy/td_digital.html

Debouncing buttons is essential and using the BOUNCE library is the 'standard' means of dealing with contact chatter except for special cases (multiplexed input for example):
https://www.pjrc.com/teensy/td_libs_Bounce.html

And here's my generic buttons and dials controller code that uses ResponsiveAnalogRead library to smooth out signal from potentiometer voltage dividers:
https://forum.pjrc.com/threads/45376-Example-code-for-MIDI-controllers-with-Pots-and-Buttons

Other than smoothing the signal; potentiometers-as-voltage-dividers are very simple compared with encoders. You could start with pots and upgrade your hardware later to rotary encoders later or just do a breadboard setup with pots until you understanding mapping the data to the MIDI range and generating MIDI messages. You might be able to get your encoders producing data first and then deal with the MIDI (avoiding pots and analog input) but only once you have reliable data.

Using serial.print() to send data to the Ardunio serial monitor is a great way to sort out inputs before worrying about generating MIDI messages:
https://www.pjrc.com/teensy/td_serial.html

If/when you have the hardware working as desired adding sysex dump won't be all that challenging if you are just saving to EEPROM or SD card; just don't get bogged down with it too early.
 
Last edited:
...
a rotary potentiometer that selected which channel the encoders were active on (1-16)...
Just noticed this... it's easy enough to map the data output from the voltage divider (defaults to 10 bit) down to four-bits needed for channel selection but the lack of tactile response would seem a bit strange to me... and stability might be a problem.

An encoder with detents or up/down selector buttons for channel selection or even DIP switches could be use instead...

I'd leave it as a constant value in the code to start:
const int channel = 1; // MIDI channel

Then you can change it to a variable when you're ready to add the feature very easily without breaking the code in a bunch of places (which happens if you hardcode the value in each MIDI message code line).

A 16 position hardware-rotary is also an option but I'd want to make it into a voltage divider (adding resistors between terminals and using one analog input like your pot version) or figure out how to read the setting on the switch with no more than four digital pins rather than using 16 digital pins pins of which only one-at-a-time will be active.

(Here's a product that does this for you: https://www.alibaba.com/product-detail/SP4T-SP8T-SP10T-SP16T-digital-fan_1817956892.html)

It's another minor issue but it's not nothing.
 
Last edited:
HI oddison, thanks for the detailed multiple replies, I really appreciate the input!!


It finally occurred to me you need a DIN connection so your biggest hardware headache will be the midi interface

https://www.pjrc.com/teensy/td_libs_MIDI.html

In particular conversion to 3.3 volt is not well documented yet. Definitely figure out how you intend to house the tiny curcuit and its required optocoupler and breadboard it first.

Before that.... the basic tutorials are the ones off the navigation list
https://www.pjrc.com/teensy/tutorial.html

You were confidant in your first post you could alter code... but you've not said if you have any Teensy experience. I found configuring the software and learning the Arduino IDE much harder than understanding the example sketches.

Don't try to sort out encoders and midi at the same time as you work out MIDI features. I would say a potentiometer-based breadboard setup is essential.
https://www.pjrc.com/teensy/tutorial4.html

DIN-plug MIDI and usbMIDI are nearly identical to use but Arduino examples often complicate things by using serial.write to write bytes directly rather than using the libraries. Even if you're not intending midi going to your computer you should be aware of the usbmidi library and how to use it.
https://www.pjrc.com/teensy/td_midi.html

I would stick to usb midi while figuring out encoders unless you've got DIN midi fully sorted first.

https://www.pjrc.com/teensy/td_libs_Encoder.html

I have very little experience with encoders but there are lots of existing posts that cover the potential pitfalls and lots of expertise among active members.

Divide and conquer :)


I'd like to begin with DIN plug from the beginning. The controller will be used in a hardware only set up so will not be plugged into a computer at any point. I could use a USB converter cable but I will then need a separate power source.

With regards to this section of the project, I would get the DIN working first, then set up the encoders through the DIN. The encoders are essential (as opposed to pots) because the encoders will be used for multiple parameters and will need to recognise the starting value.

Thanks for the link, I'm reading through :)




Other than smoothing the signal; potentiometers-as-voltage-dividers are very simple compared with encoders. You could start with pots and upgrade your hardware later to rotary encoders later or just do a breadboard setup with pots until you understanding mapping the data to the MIDI range and generating MIDI messages. You might be able to get your encoders producing data first and then deal with the MIDI (avoiding pots and analog input) but only once you have reliable data..

Thanks for that info, lots of bedtime reading for me.

Pots will not work for what I need. Because the value is fixed based on the position of the pot, when I change the channel that I am working on the parameter value will change to the value it's at. With an encoder, it can potentially receive the current value of the new parameter and then adjust up or down from there.



A 16 position hardware-rotary is also an option but I'd want to make it into a voltage divider (adding resistors between terminals and using one analog input like your pot version) or figure out how to read the setting on the switch with no more than four digital pins by hardwiring the four bits directly off each contact from the switch rather than using 16 digital pins pins of which only one-at-a-time will be active.

(Here's a product that does this for you: https://www.alibaba.com/product-detail/SP4T-SP8T-SP10T-SP16T-digital-fan_1817956892.html)

It's another minor issue but it's not nothing.


This is exactly what I was thinking. The channel is one part of a sysex string, so I would create a script, and then modify it for each channel, e.g. if the switch is in position 1, it runs the script that corresponds to channel 1, if its in position 2, it runs the same script but with the channel section of the sysex string altered etc etc.

Thanks :)
 
I'm think I'm going to order the teensy, 2x DIN, 8x encoders, and other necessary components to get this wired up on a breadboard and then I'll get back to you with results!

Most projects I've seen have used the LC but I was thinking of a 3.6 because of the storage and extra input points?
 
MIDI controllers tend use very little of the processing available so the LC makes the most sense as the cheapest alternative but pin counts can point to the 3.5 instead.

Unless you squander pins on channel selection your project should be fine on an LC but any Teensy would work.

Learn each part on its own with simple breadboarding rather than trying to cobble one part on top of the last. This will also help if you need to post code here when looking for help. It's very hard to help someone with some small part of partially-functioning Frankencode.

Once you understand the pieces then start to merge them together.

Best of luck
 
I'd like to begin with DIN plug from the beginning. The controller will be used in a hardware only set up so will not be plugged into a computer at any point. I could use a USB converter cable but I will then need a separate power source.
You need to sever the electrical connection between the USB power and your Teensy if you are planning to power externally AND allow USB connections for data transfers or software updates. Otherwise just make sure you disconnect your power before applying USB power when programming.

This page covers the issue (I've never used any of these options): https://www.pjrc.com/teensy/external_power.html

...I would get the DIN working first, then set up the encoders through the DIN. The encoders are essential (as opposed to pots) because the encoders will be used for multiple parameters and will need to recognise the starting value.

Ok... but DON'T just add encoders to a DIN-MIDI project or vice-versa as hardware interactions can make finding problems very difficult.

Can't stress this point enough... one thing at a time
...especially when there are potential issues with both software and hardware.




The channel is one part of a sysex string, so I would create a script, and then modify it for each channel, e.g. if the switch is in position 1, it runs the script that corresponds to channel 1, if its in position 2, it runs the same script but with the channel section of the sysex string altered etc etc.
Not sure you're getting this part or I'm not getting you.

You need to be able to communicate four-bits of data from your controller to select the channel.

  • You can have one button and just increment the values until it rolls over at 15 (channel 16 is binary 15) - needs just one pin and is very simple to code
  • You can have two buttons, one to increment and one to decrement - needs two pins and is fairly simple
  • You can have a 16 position switch (SP16T) and connect every output to a Teensy pin and set the channel to whatever corresponds to whichever pin is pulled low, but you'd be wasting 12 pins
  • You can put resistors between each contact to make tap-based voltage divider on the same switch and read the value as a 10-bit analog value and then map that value to the 4-bit MIDI channel
  • You can figure out some fancy wiring or some sort of logic circuit to generate the binary values from a SP16T switch.
  • You can use DIP switches that are already binary - these can be four slide switches or a rotary like in the link above.
Very few devices seem to opt for the SP16T due to cost. Usually it's part of an integrated parameter selection mechanism, typically with increament/dectrement buttons but sometimes using note-keys instead on keyboard controllers (but if you have no indicator already in use for something else then these are at least self contained unlike incremented selectors ).

For now you don't need to get bogged down on this point as long as you don't hard-code the MIDI channel into your MIDI.send commands or remember to fix them ALL when you go to add the feature.

If you are saying the behaviour of your script is different depending on the active channel then things get a bit complicated.

If, however, you merely mean the sysex is to be sent on the selected channel then you can just replace the constant value definition (const int channel = 1; ) with a variable you set by reading the hardware state of a selector or by tracking an incremented/decremented variable based on up/down switches.

But you don't need to write different code for different channels if the only difference is the channel value you are sending.

:)
 
Last edited:
You need to sever the electrical connection between the USB power and your Teensy if you are planning to power externally AND allow USB connections for data transfers or software updates. Otherwise just make sure you disconnect your power before applying USB power when programming.

This page covers the issue (I've never used any of these options): https://www.pjrc.com/teensy/external_power.html


The USB would be purely for power, the DIN would be for data. I assume that would work OK? Will be connecting the DIN as per the link in your second post.






Ok... but DON'T just add encoders to a DIN-MIDI project or vice-versa as hardware interactions can make finding problems very difficult.

Can't stress this point enough... one thing at a time
...especially when there are potential issues with both software and hardware.


I don't follow? I was planning to connect up the DIN and encoders and code from there.


[*]
[*]You can use DIP switches that are already binary - these can be four slide switches or a rotary like in the link above.

This was my original plan - I was looking at this - http://uk.rs-online.com/web/p/rotary-switches/8779397/




[*]You can have two buttons, one to increment and one to decrement - needs two pins and is fairly simple

Would an encoder work for this? How would I know what channel I was sending on? Could I used a pot with 16 detents?





If, however, you merely mean the sysex is to be sent on the selected channel then you can just replace the constant value definition (const int channel = 1; ) with a variable you set by reading the hardware state of a selector or by tracking an incremented/decremented variable based on up/down switches.

But you don't need to write different code for different channels if the only difference is the channel value you are sending.

:)

That is exactly what I meant, and it sounds easier than I thought it was going to be. :)
 
I don't follow? I was planning to connect up the DIN and encoders and code from there.
Troubleshooting two hardware devices at the same time generally leaves you guessing which one isn't working.

I don't know encoders but you'll want to get the midi in circuit running without relying on any other hardware to test... but you can always step back and try the pieces separately if you try the together first and something doesn't work.

EDIT if you don't need MIDI-IN things are much simpler, but make sure you use smaller resistors for 3.3 volt Teensy and not 220 ohm that is shown almost everywhere for midi-out.

An detent encoder for midi selector will work... it was in my options on the earlier message... but like any increment selector you would need something to display which channel is active.

Everything you want to do is feasible once you are able to read and write basic code and learn about each of the components if you don't get lost in too much complexity too soon....

Here's are standard warnings from Paul on the issue... he sometimes adds an extra 'many' to the "many people..."
https://forum.pjrc.com/threads/3537...ing-Teensy-3-2?p=109816&viewfull=1#post109816
https://forum.pjrc.com/threads/46172-Teensy-MIDI-and-motorized-faders?p=152524&viewfull=1#post152524
 
Last edited:
Status
Not open for further replies.
Back
Top