I've put together a Midi application that takes input from my source (electronic) piano, modifies the velocity per a pre-defined curve, and echoes the midi packet back to the same piano. I thought this would be hard, but the Core Audio book showed me what to do. Now for the "easy" part - I would simply like to write the velocity values to a text field as the notes are played. I haven't been able to figure out how to do it ! The midiReadProc must be in another world - it apparently doesn't know anything about my world except what it gets from my midiInfo refCon :
typedef struct MIDIEchoStruct { MIDIClientRef client; MIDIEndpointRef dest; MIDIPortRef inPort; MIDIPortRef outPort; MIDIPacketList outList; int mNote; int mVelIn; // from source int mVelOut; // to destination int mCommand; NSMutableArray *velocityCurve; } MIDIEchoStruct; MIDIEchoStruct midiInfo; (I may have more stuff in the struct than necessary, but I like having it all together)
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 }
(I can manually read out the values in my text field by pressing an IBAction button, so the values are available) How can I get the midiReadProc to communicate with the rest of my program ?
Thanks ! - William |