• 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
Simple MIDI Output fails
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simple MIDI Output fails


  • Subject: Simple MIDI Output fails
  • From: James Wylder <email@hidden>
  • Date: Thu, 10 Feb 2005 20:05:13 -0600

I am just trying to send a single note on and off command to the Simple Synth but something isn't working out. When I run my code, I hear the note the first time I run it but I have to shutdown the "Simple Synth" to get it to go again. I also can't seem to ever play two notes.


#include <stdio.h>

MIDIPortRef gOutPort = NULL;

OSStatus my_send(MIDIEndpointRef dest, Byte event, Byte note)
{
MIDIPacketList pktList;
MIDIPacket * pkt = NULL;
Byte data[3];

data[0] = event;
data[1] = note;
data[2] = 0xFF; // Velocity

pkt = MIDIPacketListInit(&pktList);
MIDITimeStamp now = AudioGetCurrentHostTime();
(void) MIDIPacketListAdd(&pktList, sizeof(pktList), pkt, now, 3, data);

return MIDISend(gOutPort, dest, &pktList);
}

OSStatus noteOn(MIDIEndpointRef dest, Byte note)
{
return my_send(dest, 0x90, 60);
}

OSStatus noteOff(MIDIEndpointRef dest, Byte note)
{
return my_send(dest, 0x80, 60);
}

int main(int argc, char * argv[])
{
MIDIClientRef client = NULL;
int destCount = 0;
int i;

MIDIClientCreate(CFSTR("MIDITest"), NULL, NULL, &client);
MIDIOutputPortCreate(client, CFSTR("Outputport"), &gOutPort);
destCount = MIDIGetNumberOfDestinations();
printf("Number of Destinations = %d\n", destCount);
for (i = 0; i < destCount; ++i)
{
MIDIEndpointRef dest = MIDIGetDestination(i);
printf("Sending Note On (Destination %d)\n", i);
if( noteOn(dest, 60) )
{
printf(" failed\n");
}
if (noteOff(dest, 60))
{
printf(" failed\n");
}
}
return 0;
}

_______________________________________________
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: Simple MIDI Output fails
      • From: Yoshiharu Honjo <email@hidden>
  • Prev by Date: Re: Host Time epoch
  • Next by Date: Re: Getting notifications for AudioUnit ProcessBufferLists
  • Previous by thread: Re: AUs "disappear" in 10.3.8 - Bug?
  • Next by thread: Re: Simple MIDI Output fails
  • Index(es):
    • Date
    • Thread