Web Server + other things to do quickly, how to handle priorities correctly

Hello guys!
Probably a dumb question but I'm not secure how to handle this situation:

I have a sketch where my Arduino due is receiving MIDI messages, doing some stuff and sending UDP messages accordingly the MIDI message received.
This must be done "as soon as possible" because I want to have this with less delay possible.

This is all working fine but now I would like to add a web server for remote configuration of the arduino. Which for me looks pretty "heavy" to handle.
I want to have it a secondary thing, don't care if the webserver is slow or laggy, messages must come out first.

This should be done easily if I had interrupts on received MIDI message and handle them in the interrupt before going back to the main loop but, unfortunately, the USB MIDI library needs to call USBMIDI.Read() for getting MIDI Messages.

I was thinking how I can handle this priorities thing as best for performance. Now I'm thinking to use a timer interrupt running really fast calling the read function and handling the webserver settings in the main loop.

Do you have any better Idea for that?
Is Arduino capable to handle different interrupt priorities?

Hope you guys have some time for me
Thanks!

Lorenz

You could use a multi-tasking macro like this , or, for more flexibility (if you have enough RAM for all the stacks) a 'proper' RTOS like this

I'm using DUE but I'm thinking to continue with Teensy in future.. so ram is not a problem.

Thanks for the hint, I will have a look...
and what about a really fast timer interrupt? more difficult?

The RTOS library will be using fast interrupts to switch between tasks. Yes, you could try to write task-switching yourself, but it's not easy.