in reply to listen to a midi keyboard
In the arena of musical notation software, I have tried several (including commercial products such as Sibelius), and hands down I have settled on ... an open-source, free product: MuseScore. Runs on Windows, OS/X, and Linux, with numerous packages and ready-made installers. Yes, this is meant as a two-thumbs-up endorsement.
It is strictly a musical notation program, not a DAW, and don’t expect to “play a tune on your MIDI keyboard and have a score come out.” It doesn’t do that ... that is excluded from the scope of its design. It does include a SoundFont-based synthesizer ... standard files are included, with references to and instructions for downloading many more. This is intended specifically to allow you to “proof” your scores as you are composing them, and as a matter of fact it does a very good job. You can export your music as MusicXML (its native format), MIDI, and various sound files. However, it is primarily a musical score-creation tool.
After all, I don’t just “do Perl” for my daily bread. This is the tool that I have contentedly settled upon.
Since MusicXML is an open-standard format, understood by many applications, you could use Perl to manipulate it as XML. Likewise, CPAN includes many libraries for MIDI files. I would not attempt to use Perl to create a device-interface, but I would if necessary consider using it to manipulate the captured musical data.