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

[sc-dev] reading an array from lang to C

Hi James,

 Here is some code that attempts to implement sysex output.
It appears that I am not successfully reading the Int8Array that is
the sysex packet prSendsysex.  What am I doing wrong?

void sendsysex(MIDIEndpointRef dest, int size, Byte* data);
void sendsysex(MIDIEndpointRef dest, int size, Byte* data)
    MIDISysexSendRequest mpktlist;
    MIDISysexSendRequest *pk = &mpktlist;
    pk -> destination = dest;
    pk -> data = data;
    pk -> bytesToSend = size;

int prSendSysex(VMGlobals *g, int numArgsPushed);
int prSendSysex(VMGlobals *g, int numArgsPushed)
    int err, uid, size;
    PyrInt8Array* packet = g->sp->uob;
    size = packet->size;
    Byte data[size];
    memcpy(data,packet->b, size);

    PyrSlot *u = g->sp - 1;
    err = slotIntVal(u, &uid);
    if (err) return err;

    MIDIEndpointRef dest;
    MIDIObjectType mtype;
    MIDIObjectFindByUniqueID(uid, (MIDIObjectRef*)&dest, &mtype);
    if (mtype != kMIDIObjectType_Destination) return errFailed;
    if (!dest) return errFailed;

    sendsysex(dest, size, data);
    return errNone;

// in the lang:  +MIDIOut { sysex { arg uid, Int8Array; _SendSysex } }