• 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: question about CoreMIDI & cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about CoreMIDI & cocoa


  • Subject: Re: question about CoreMIDI & cocoa
  • From: john <email@hidden>
  • Date: Tue, 28 Sep 2004 17:31:21 -0400

Hi Khamba,

I've never used CoreMIDI, but I am familiar with calling ObjC methods from C callbacks and I do find it rather trivial. Maybe Robert is referring to some other aspect since I know nothing about CoreMIDI. In any case I'm sure checking out the MIDIMonitor source will be very helpful overall.

Assuming there is a refcon parameter to your C callback, you can just pass an ObjC object (using "self") as that parameter. In your C callback, you can use the refcon parameter as a regular ObjC object and make methods calls.

Here is an example of it with the SoundConverter callback in QT:

// making the call to QT
SoundConverterFillBuffer(theSoundConverter,
theFillBufferDataUPP,

self,
*decompressionBuffer,
length,
&actualOutputBytes,
&outputFrames,
&outputFlags))

// the C callback as referenced from "theFillBufferDataUPP" above
BOOL SoundConverterWriteDataProc(SoundComponentDataPtr *outData, void *inRefCon)
{
// just call ourselves
return [(MyObjCObject*)inRefCon SoundConverterWrite: outData];
}

-- John


Now that Kurt Revis has made the spectacularly useful MIDI Monitor source available I highly recommend you take a look:

http://www.snoize.com/MIDIMonitor/Source/

The long answer is - this topic keeps coming up because the solution is not as trivial as everyone would like - and thus there is not one right answer.

Robert.

Hi,

Not exactly Core_Audio_ related but here goes.. (is there a coremidi list?)

I've setup the midi callback so that a standard C function is called when
a midi message is received by the system. I'd like to make this C function
signal a method in an ojbc class, in order to let that method update an
NSTextView in my programs window.

Now, the callback is called when a signal is received; it can call a method
in my MIDI class, which also seems to work (some printf()s showed me).
However, when I try to send a message to the NSTextView outlet from the
method called by the C callback, the program buserrors. I suppose this
happens because the C function lives in the midi thread which is automatically
created by CoreMIDI?

What can I do to call a function/send a message to the MIDI class so I can
safely update the NSTextView?

One way I'm trying to avoid is to copy the received midi messages in a struct
and let the MIDI class periodically check and clear this struct..


Kind regards,

-- Khamba Staring
 _______________________________________________
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: question about CoreMIDI & cocoa
      • From: Robert Grant <email@hidden>
References: 
 >question about CoreMIDI & cocoa (From: Khamba Staring <email@hidden>)
 >Re: question about CoreMIDI & cocoa (From: Robert Grant <email@hidden>)

  • Prev by Date: Re: No dolby/DTS with DVD player?
  • Next by Date: Re: question about CoreMIDI & cocoa
  • Previous by thread: Re: question about CoreMIDI & cocoa
  • Next by thread: Re: question about CoreMIDI & cocoa
  • Index(es):
    • Date
    • Thread