• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
MIDI In OK, No MIDI Out
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MIDI In OK, No MIDI Out


  • Subject: MIDI In OK, No MIDI Out
  • From: Eric Kampman <email@hidden>
  • Date: Sat, 18 Jun 2011 18:29:13 -0700

I'm out of ideas. In my test setup MidiKeys can play my external synth. No CoreMIDI code I've written can. The 'MIDI Out' led on my M-Audio Uno flashes at the right moments but no sound. Below is bare-bones code that cycles through the possible destinations and does a note down and an un-note down once a second. Can anyone see what I'm doing wrong? 

#import <Foundation/Foundation.h>
#include <CoreAudio/CoreAudio.h>
#include <CoreMIDI/CoreMIDI.h>

//#include <time.h>  /* nanosleep */
//#include <stdio.h> /* printf */

MIDIPortRef gOutPort = 0;

Byte data_dn[] = { 0x90, 0x29, 0x80 };
Byte data_up[] = { 0x90, 0x29, 0x00 };

static OSStatus sendOnOff(MIDIEndpointRef endpointRef)
{
MIDITimeStamp timeStamp = 0; // AudioGetCurrentHostTime();
MIDIPacketList mpl;
MIDIPacket *mp;
OSStatus ret = 0;
struct timespec waitime = { 1, 0 };


mp = MIDIPacketListInit(&mpl);
mp = MIDIPacketListAdd(&mpl, sizeof(mpl), mp,  timeStamp, 
  3, data_dn);
ret = MIDISend(gOutPort, endpointRef, &mpl);


nanosleep(&waitime, NULL);
waitime.tv_sec = 1;

mp = MIDIPacketListInit(&mpl);
mp = MIDIPacketListAdd(&mpl, sizeof(mpl), mp,  timeStamp, 
  3, data_up);
ret = MIDISend(gOutPort, endpointRef, &mpl);
nanosleep(&waitime, NULL);


return ret;
}

int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

MIDIClientRef client = 0;
MIDIClientCreate(CFSTR("MIDI Test"), NULL, NULL, &client);


MIDIOutputPortCreate(client, CFSTR("Output Port"), &gOutPort);

ItemCount count = MIDIGetNumberOfDestinations();
bool finished = NO;
MIDIEndpointRef dest;
CFStringRef pname;
char name[64];


while (!finished) {
for (int i = 0; i < count; i++) {
dest = MIDIGetDestination(i);


MIDIObjectGetStringProperty(dest, kMIDIPropertyName, &pname);
CFStringGetCString(pname, name, sizeof(name), 0);
printf("Dest Endpoint Ref = %u\n", dest);
printf("Sending note on/off to '%s'\n", name);


sendOnOff(dest);
}
}
[pool drain];
return 0;
}

FWIW Snow Leopard, 10.6.7. 
Thanks
Eric


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: MIDI In OK, No MIDI Out
      • From: Bob Lang <email@hidden>
    • Re: MIDI In OK, No MIDI Out
      • From: Charlie Roberts <email@hidden>
  • Prev by Date: MatrixMixer - handling a lot of inputs
  • Next by Date: Re: MIDI In OK, No MIDI Out
  • Previous by thread: MatrixMixer - handling a lot of inputs
  • Next by thread: Re: MIDI In OK, No MIDI Out
  • Index(es):
    • Date
    • Thread