click a button, output a MIDI note?

I’ve been searching and searching, but haven’t gotten an answer that seems to work for me. I want to build a super simple “app” in Xcode with an array of clickable or keyboard equivalent buttons that when clicked put out a simple MIDI note on and accompanying note off message. I’ve built little “applescript-lications” before that present a user with a big interface full of big buttons to when clicked send applescripts and when clicked with accompanying modifiers set (sliders, check boxes, etc) send specifically altered scripts, so the rest of the work isn’t a problem for me - the part i’m stumped about is is there a simple way to do this, like “call” CoreMIDI in some fashion to send notes?

In the most super - simple form i can think of I’d like to let a user press a keyboard key and/or click a window button with a mouse and have that generate a note on/note off. If I can solve this problem I’d like to tie the little app to an Xkeys Pro USB button box.

Can anyone point me at information on making my little app put out midi notes natively without relying on other software installed and running?

Thanks in advance,

WM

PS - yes indeedy, there’s a multitude of products that seem to do the opposite.

There’s no native MIDI support in Applescript. In order to do what you want, you’ll need to look through the CoreMIDI framework and use Applescript Studio’s “call method” statement to call a MIDI routine out of Core Audio. Check out the developer site at Apple. Here’s a good starting point.