Go Down

Topic: MIDI Reset (Read 6118 times) previous topic - next topic

boguz

Hi

Well, i know this not an Audio question per se, but i thought this was anyway the right forum to post it on.

I am working on a MIDI Foot Controller.

In the past, with other midi instruments that had nothing to do with arduinos, it happend to me a couple of times that a note "got stuck".
I hope this won't happen with the foot controller, but, just to be on the safe side, i would like to include some kind of reset to it.

I have read a little bit about doing a "soft reset":
Code: [Select]

asm volatile ("  jmp 0");

for what i understand, this brings the sketch again to the beginning, so it's a kind of software reset.
But, as i don't understand that code, and i read several conflicting opinions about it, i am actually a little bit afraid of using it.
Any ideas and experiences with it?

the other idea i had, was to send an ALL NOTES OFF midi command:
Code: [Select]
0xFF
Would this do the trick?
It would not reset the Arduino, but it would Reset all the MIDI, right?
So any stuck notes would also be reseted?

Hmmm, one more question...
i am sending my midi like this:
Code: [Select]

Serial.write(cmd);
Serial.write(pitch);
Serial.write(vel);

What would be the correct way to send the 0xFF Reset message?
I assume the 0xFF is the command, so it would go on the "Serial.Write(cmd)", but what about the pitch and the vel, can i just leave them empty?


Any other ideas on how to achieve this reset effect?

Thank you!
=)

db2db

some things send all notes off command. other things send every note with a velocity of 0.

boguz

but what would be a good solution with an Arduino? Anyone ever made something similar?

I guess the easiest solution is just to unplug the usb cable and plug it again but well, that isn't so elegant!  ;)

db2db

If a note on an external device is tuck, you have send something to stop it. Resetting your arduino device won't change that.

boguz

so the all notes off command (0xFF) would be the way to go?

db2db

I'm not sure that's the correct all notes off command.

marco_c

Try reading this http://www.music-software-development.com/midi-tutorial.html

Quoting from the relevant bit in section 9:
Quote
1 - Using MIDI controller 123
If you send a MIDI controller 123 on one MIDI channel, the synthesizer will stop all notes playing on that channel. To reset all MIDI channels, send that message for each channel. Please note that some synthesizer do not respond to this message.

2 -MIDI Reset message
This is a one status byte message 0xFF, without data bytes. It should reset the synthesizer to its power-on default, so it also stops all notes playing. Use this message sparingly, as it reset the full synthesizer, not only the notes playing.

3 - MIDI NOTE OFF
You can also send, for each channel (0 to 15) and each note pitch (0 to 127) one MIDI NOTE OFF message. This is the total solution, but requires a lot of MIDI messages to be sent, which may have some reaction time according to the MIDI hardware system you use.

4 - MIDI NOTE OFF - Optimized
In this case, use a table to keep track of the NOTE ON and OFF messages you send for each channel. A buffer of 128 bytes for each channel, representing the number of NOTE ON messages sent to that note, should be incremented by a NOTE ON and decremented by a NOTE OFF. Then, when you want to reset every note, simply go through that table and send a NOTE OFF to each note that is still playing.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

boguz

Thank you, that seems like a nice page to with information about MIDI.
i will read it through tomorrow when i have a little time!
=)

maxscorda

This works for me. Try both!
Code: [Select]

void MIDIhardreset()
{
Serial.write(0xFF);
}

void MIDIsoftreset()
{
Serial.write(0xF0);
Serial.write(0x7F);
Serial.write(0x7F); //device id 7F = 127 all channels
Serial.write(0x02);
Serial.write(0x7F); // command format 7F = all devices
Serial.write(0x0A); // action 0x0A= reset
Serial.write(0xF7);
}

boguz

Thanks, i will try it out!  8)

Have you used it in any project? Did it work well?

Grumpy_Mike

The problem is that 0xF0 is system exclusive message. It will only work on some systems.

Quote
System Exclusive.
This message makes up for all that MIDI doesn't support. (iiiiiii) is usually a seven-bit Manufacturer's I.D. code. If the synthesizer recognizes the I.D. code as its own, it will listen to the rest of the message (ddddddd). Otherwise, the message will be ignored. System Exclusive is used to send bulk dumps such as patch parameters and other non-spec data. (Note: Real-Time messages ONLY may be interleaved with a System Exclusive.) This message also is used for extensions called Universal Exclusive Messages.


This is a good place to look for such data:-
http://www.midi.org/aboutmidi/index.php

maxscorda

#11
Jul 23, 2013, 01:04 pm Last Edit: Jul 23, 2013, 01:39 pm by maxscorda Reason: 1
Both works perfectly.
The difference is with hardreset software like Ableton and PC needs restart, softreset don't .
I had problems with midi cable like this
http://www.ebay.it/itm/180943062588
NOT with this one
http://www.ebay.it/itm/161006079225
Look well the images, they are different and works different.
Now with softreset both works well

boguz

what about something like this:

Code: [Select]

void sendReset () {
  int n = 12;
  while (n < 108) {
    noteOn(0x80, n, 0x00);
    n++;
  }
} // end void sendReset

(12~107 are the notes available in my sketch)

Like this, in practical terms, if a note would get stuck by sending this notes off i would "unstuck" it (is this a word?!  8)  )?
I think this would be a simple solution.
I tried it a couple of times and it seems to work, but i won't know for sure until i get a real stuck note!
;)



The difference is with hardreset software like Ableton and PC needs restart, softreset don't .

Not having to restart any software would be great!

Grumpy_Mike

Yes that should work. It will take a time though.
Unstuck is a word.

maxscorda

I'm sure your code is good for stuck notes but not for me.
My problem was that every time I compile, MIDI stop to work and I had to disconnect MIDI e Arduino USB cable to work again.
It happened only with one kind of cable not the others (I've got two for both)
With softreset  everything fine now

Go Up