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

FeatureReq - Send SysEx message on button press #51

Open
mungewell opened this issue Jun 25, 2018 · 8 comments
Open

FeatureReq - Send SysEx message on button press #51

mungewell opened this issue Jun 25, 2018 · 8 comments
Assignees

Comments

@mungewell
Copy link

A little request; to be able to send a SysEx command when a button is pressed.

I imagine that this would be a new definition (say 'DigitalSysEx()') and take a string of hex digits which would be sent each time the button was pressed.

This is respect to creating a start/stop device for the Akai MPC, as seen here:
https://www.youtube.com/watch?v=2PngH1TE_dA

Required SysEx are described here:
https://www.dropbox.com/s/71crq2qvd378zbg/MPC%20and%20MC6%20Editor%20Notes.pdf?dl=0

Thanks,
Simon.

@mungewell
Copy link
Author

I had a go at implementing:
https://github.com/mungewell/MIDI_controller/tree/20180627_DigitalSE

it compiles, but I don't have an Arduino to test it on (they're on order).

@tttapa
Copy link
Owner

tttapa commented Jun 28, 2018

I plan on restructuring the Digital and Analog classes to make them less dependent on the send implementation. Once that's done, adding SysEx support should be easy.

@tttapa tttapa self-assigned this Jun 28, 2018
@mungewell
Copy link
Author

mungewell commented Jun 29, 2018

After circling around for quite a while with a very puzzled look, I finally realized that the board (Arduino UNO) I am using is actually using the serial port (rather than USB) and got something coming out of the port.

Then the 2nd realization struck - arduino_midi doesn't support SysEx:
ddiakopoulos/hiduino#20

Well some progress was made.... and a few bugs were squashed.

Might work for other boards.

@mungewell
Copy link
Author

I should add the Uno is borrowed, whilst I wait for my Pro Micros to arrive. The Micros appear to have inbuilt USB, so I'm still hopeful it will work.

@mungewell
Copy link
Author

@tttapa
Copy link
Owner

tttapa commented Jun 29, 2018

I see that you use separate bytes to pass to the constructor. You could pass the SysEx as an array: either as a pointer to the first element of the array (C-style):

void sendSysEx(uint8_t *data, size_t length) {
  for (size_t i = 0; i < length; i++) {
    Serial.println(data[i]);
  }
}

Alternatively, you can use a reference to an array (C++-style):

template <size_t N>
void sendSysEx(uint8_t (&data)[N]) {
  for (const uint8_t &data_byte : data) {
    Serial.println(data_byte);
  }
}

I use this approach at multiple points in the library already, for example here: https://github.com/tttapa/Control-Surface/blob/1293f468d0cbacf1039d41bf5584ca8b17bc8f76/src/ExtendedInputOutput/AnalogMultiplex.h#L12
One thing to keep in mind is that if you initialize it using a brace-enclosed initializer list, the lifetime of the array is the lifetime of the function. If the function in question is a constructor, you can't just save the array reference, you have to copy it.

@mungewell
Copy link
Author

Found this other implementation of the UNO MIDI firmware:
https://github.com/TheKikGen/USBMidiKliK

It's passing the SysEx stream, but for some reason I am having missing bytes....

@mungewell
Copy link
Author

Still having difficulties with that alternative, seems that sending 5 bytes is broken but 6 bytes work...

Found another alternative (via pedalino which uses your code):
https://github.com/alf45tar/Pedalino
https://github.com/kuwatay/mocolufa

On the topic of creating instance with bytes or array, I figured that bytes might be easier for a not-to technical person. Happy either way.... when creating banks of buttons does it matter?

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