• 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: MidiReadProc to Text Field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MidiReadProc to Text Field


  • Subject: Re: MidiReadProc to Text Field
  • From: Haynes Electronics <email@hidden>
  • Date: Thu, 07 Mar 2013 14:56:44 -0500

Polling from the UI side with NSTimer to call the "writeToField" message works fine. This may be the best way to do it as far as overhead goes.
But, I really wanted to learn how to communicate with the proc.
As suggested, I replaced the struct with a list of @properties and passed "self" to the midireadproc. Works great !
I've learned a few things today. Thanks to all of you for your help.

William (Al) Haynes

On Mar 6, 2013, at 11:31 AM, Christian Blomert wrote:

When creating your input port with: 


The program closely follows the CABook - here's the callback part :
MIDIInputPortCreate(
midiInfo.client,
CFSTR("Input port"),
MIDIEchoReadProc,
&midiInfo,
&midiInfo.inPort),
and the read proc :
void MIDIEchoReadProc(const MIDIPacketList *pktlist,
                           void *refCon,
                           void *connRefCon) {
MIDIEchoStruct *midiInfo = (MIDIEchoStruct*) refCon;
---  do midi processing --- works
--- echo to destination --- works
--- printf to console ---   works
[myTextField setIntValue:midiInfo->mVelIn];doesn't work
- or -
[self myWriteToTextfieldMethod];doesn't work - self is undefined
}


instead of &midiInfo, put a link to 'self' as (void*)inRefCon, and put your midiInfo in the interface & properties of your main class
In the read proc you can then create a pointer named self to refCon:


MIDIInputPortCreate(
midiInfo.client,
CFSTR("Input port"),
MIDIEchoReadProc,
self,
&midiInfo.inPort),
and the read proc :
void MIDIEchoReadProc(const MIDIPacketList *pktlist,
                           void *refCon,
                           void *connRefCon) {
MyMainClass * self = (MyMainClass*) refCon;
MIDIEchoStruct *midiInfo = self->midiInfo;
---  do midi processing --- works
--- echo to destination --- works
--- printf to console ---   works
[self->myTextField setIntValue:midiInfo->mVelIn]
- or -
[self myWriteToTextfieldMethod];
}


But as this is a high priority audio thread, it would be better to 'read' a current value from the main thread (that you could store easily as an int in said pointer to self on the audio thread)

Cheers,
Chris

 _______________________________________________
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

References: 
 >MidiReadProc to Text Field (From: Haynes Electronics <email@hidden>)

  • Prev by Date: Re: properties data size
  • Next by Date: Re: Debugging an AudioServer plugin
  • Previous by thread: Re: MidiReadProc to Text Field
  • Next by thread: [VST2.4 -> AU] host and property notifications
  • Index(es):
    • Date
    • Thread