Probably not very useful info for a beginner, but ...
There's a very promising C++ library
RtMidi I wish I'd translate (currently finishing another project), and there are chances I will, at least I'm going to test it as is.
Interesting part it is crossplatform, has C interface (suitable for Pascal), supports multiple MIDI backends (Jack, Alsa) on Mac and Linux.