Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7932795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:07:31+00:00 2026-06-03T21:07:31+00:00

Here is an extremely simple CoreMIDI OS X application that sends MIDI data. The

  • 0

Here is an extremely simple CoreMIDI OS X application that sends MIDI data. The problem is that it doesn’t work. It compiles fine, and runs. It reports no errors, and does not crash. The Source created becomes visible in MIDI Monitor. However, no MIDI data comes out.

Could somebody let me know what I’m doing wrong here?

#include <CoreMIDI/CoreMIDI.h>

int main(int argc, char *args[])
{
    MIDIClientRef   theMidiClient;
    MIDIEndpointRef midiOut;
    MIDIPortRef     outPort;
    char pktBuffer[1024];
    MIDIPacketList* pktList = (MIDIPacketList*) pktBuffer;
    MIDIPacket     *pkt;
    Byte            midiDataToSend[] = {0x91, 0x3c, 0x40};
    int             i;

    MIDIClientCreate(CFSTR("Magical MIDI"), NULL, NULL,
                     &theMidiClient);
    MIDISourceCreate(theMidiClient, CFSTR("Magical MIDI Source"),
                     &midiOut);
    MIDIOutputPortCreate(theMidiClient, CFSTR("Magical MIDI Out Port"),
                         &outPort);

    pkt = MIDIPacketListInit(pktList);
    pkt = MIDIPacketListAdd(pktList, 1024, pkt, 0, 3, midiDataToSend);

    for (i = 0; i < 100; i++) {
        if (pkt == NULL || MIDISend(outPort, midiOut, pktList)) {
            printf("failed to send the midi.\n");
        } else {
            printf("sent!\n");
        }
        sleep(1);
    }

return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:07:33+00:00Added an answer on June 3, 2026 at 9:07 pm

    You’re calling MIDISourceCreate to create a virtual MIDI source.

    This means that your source will appear in other apps’ MIDI setup UI, and that those apps can choose whether or not to listen to your source. Your MIDI will not get sent to any physical MIDI ports, unless some other app happens to channel it there. It also means that your app has no choice as to where the MIDI it’s sending goes. I’m assuming that’s what you want.

    The documentation for MIDISourceCreate says:

    After creating a virtual source, use MIDIReceived to transmit MIDI messages from your virtual source to any clients connected to the virtual source.

    So, do two things:

    • Remove the code that creates the output port. You don’t need it.
    • change MIDISend(outPort, midiOut, pktList) to: MIDIReceived(midiOut, pktlist).

    That should solve your problem.

    So what are output ports good for? If you wanted to direct your MIDI data to a specific destination — maybe a physical MIDI port — you would NOT create a virtual MIDI source. Instead:

    1. Call MIDIOutputPortCreate() to make an output port
    2. Use MIDIGetNumberOfDestinations() and MIDIGetDestination() to get the list of destinations and find the one you’re interested in.
    3. To send MIDI to one destination, call MIDISend(outputPort, destination, packetList).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm coding an extremely simple shell script and it doesn't really work as it
Here's the deal: I'm in the process of planning a mid-sized business application that
I have this extremely simple splash page here: http://iph0wnz.com It has the main graphic
This is one of this things that should be extremely simple and I just
Alright here's the situation, I have an application written in the Zend_Framework, that is
I have an extremely simple page that isn't displaying properly in IE6. In this
I have an extremely simple BizTalk orchestration that takes a HIPAA 837 file in,
As a proof of concept, I'm building this extremely simple Twitter Friends crawler. Here's
I can't get this extremely simple jsfiddle to work. Its just supposed to alert
I've been trying to do something extremely simple, yet I can't make it work!

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.