• 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: General CoreMIDI Newbie-Questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: General CoreMIDI Newbie-Questions


  • Subject: Re: General CoreMIDI Newbie-Questions
  • From: Kurt Revis <email@hidden>
  • Date: Sat, 28 Dec 2002 17:01:51 -0800

On Saturday, December 28, 2002, at 04:04 PM, Oliver Jaun wrote:

I create an IPC Pipe. After sending the Sysex Message I do a read() on the pipe. This will block until I read a response...let's say "deviceInquiryResponse". Additionally I could use a select() system call to specify a timeout. I guess that should work.

Sure, if that's what you want to do. It's best to avoid blocking in the main thread of your application, though. The main thread is where all UI happens, so user input and drawing will not happen while you are blocked. You could create a new thread and do the blocking call there, but that raises other issues (of course).

There is lower-level API which will do the same thing, and may be easier to use. I suspect you're using Carbon so you might look into the Multiprocessing API, which provides locking primitives. Or use pthreads, which is probably even easier.

But I have yet another question...It's more a general C/C++ Question: How can I pass function pointer of a non static function in C++? I'm asking this regarding the MIDIResponseProc. I attached the source code of my "application" (very short). Unfortunately I get the following message if I try to compile it with

g++ -framework CoreAudio -framework CoreMIDI -framework CoreFoundation -o scuba DataProvider.cpp

DataProvider.cpp:71: invalid use of member `DataProvider::fileDescriptor' in
static member function

If MyReadProc wasn't static I would not get this message but then I don't know how to pass a function pointer.

You probably want to pass 'this' as the refCon to MIDIInputPortCreate(). Your MIDIReadProc will then receive that refCon as an argument. Cast that to a (DataProvider *) and then you can use it... for instance

void DataProvider::MyReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
{
DataProvider *this = (DataProvider *)refCon;

this->_someVariable = 0; // access variables
this->DoStuffWithPacketList(pktList); // and member functions
}

My C++ is kind of rusty, but that's the general idea.

--
Kurt Revis
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: General CoreMIDI Newbie-Questions (From: Oliver Jaun <email@hidden>)

  • Prev by Date: Re: General CoreMIDI Newbie-Questions
  • Next by Date: Is there a best way to put simultaneous notes in a MusicSequence?
  • Previous by thread: Re: General CoreMIDI Newbie-Questions
  • Next by thread: Is there a best way to put simultaneous notes in a MusicSequence?
  • Index(es):
    • Date
    • Thread