Midi controler with mega 2560 and encoders

If you need just the encoders and a couple of push buttons, you might get away with just polling them for changes. If there's much other stuff going on in your code, you'll have to resort to interrupts, which is much more tricky.

These examples could prove helpful:

If you want to go the interrupt route, see: