• 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
Re: MIDI In OK, No MIDI Out
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIDI In OK, No MIDI Out


  • Subject: Re: MIDI In OK, No MIDI Out
  • From: Charlie Roberts <email@hidden>
  • Date: Sun, 19 Jun 2011 01:15:15 -0700

Hi Eric,

If it's getting to your Uno it seems like most of the work should be done. Try sending 127 as the value for for the noteon instead of 128. The range of values should be 0 - 127, not 1 to 128. I'm not sure exactly what the extra bit would do to the packet list but would guess that it would screw it up... a one in the the most significant bit of any byte in a standard MIDI message is used to indicate the start of a new message (a status byte) instead of the continuation of a message (a data byte).

- Charlie

On Sat, Jun 18, 2011 at 6:29 PM, Eric Kampman <email@hidden> wrote:
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


 _______________________________________________
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: Eric Kampman <email@hidden>
References: 
 >MIDI In OK, No MIDI Out (From: Eric Kampman <email@hidden>)

  • Prev by Date: MIDI In OK, No MIDI Out
  • Next by Date: Re: kAudioOutputUnitProperty_CurrentDevice with error -2147450879
  • Previous by thread: MIDI In OK, No MIDI Out
  • Next by thread: Re: MIDI In OK, No MIDI Out
  • Index(es):
    • Date
    • Thread