[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] [sc3] midi in

i made a new version of the midi input, which takes more care on the language side. all references to receiver ports are stored in a global classvar of MIDIClient,
midievents are handled by a MIDIEvent.
it also supports note on messages now.
so first i put it at:


OK it's been a while but I've looked at this code and it has a problem that can cause heap corruption. You cannot store an SC object into a C object unless you have done something on the
language side to insure that it cannot get garbage collected.
All of your midi-in objects need to be in some global classvar array (in the same way that windows and files are done) in order to insure that they don't get garbage collected out from under you. In your example you store it in an interpreter variable, so it is safe there, but in the general case you need to make sure your object does not become garbage.
other problems:
You should use slotIntVal() to get the integer value of argument b.
It may not be of class Integer.
int prJtMIDIconnect(VMGlobals *g, int numArgsPushed){
    //connect port to client
    PyrSlot *a, *b;
    a = g->sp - 1;
    b = g->sp ;

    JtInitMidiInput(b->ui, a->uo);

--- james mccartney   james@xxxxxxxxxxxxxx   <http://www.audiosynth.com>
SuperCollider - a real time synthesis programming language for the PowerMac.

sc-dev mailing list