midi longdata

Discussion in 'comp.music.midi' started by vvvv, Jun 8, 2003.

  1. vvvv

    vvvv Guest

    My midiCallback is only putting the first 3 bytes of a sysex message into
    the prepared headers buffer. i am definitely getting the sysex, and the
    correct number of msgs are being received by my computer. i have tested
    the reception of the data using a separate midi echo program on two diff
    platforms and midi interfaces (1 serial, 1 usb).

    when i try to retrieve sysexbuffer, i only get 3 bytes. 0xF0, 0x41, 0x10.
    the next byte should be 0x00. there should be over 6600 bytes, and my byte
    counter proves that they are being passed to my routine, just not being put
    into my buffer because of a mistake. what am i doing wrong?

    thanks for your time...
    vvvv

    ////////////////////
    HMIDIIN hMidiIn;
    char sysexbuffer[10000];
    MIDIHDR midiHdr;
    LPCIRCULARBUFFER lpInputBuffer;


    short OpenMidiIn(int nodeNum, long hwnd){
    short err = 0;
    lpInputBuffer = AllocCircularBuffer((DWORD)(INPUT_BUFFER_SIZE *
    sizeof(EVENT)));
    if(lpInputBuffer==NULL){
    err = 111;
    return err;
    }

    if((lpCallbackInstanceData[nodeNum] = AllocCallbackInstanceData()) ==
    NULL){
    FreeCircularBuffer(lpInputBuffer);
    err = 222;
    return err;
    }

    inDevice = nodeNum;
    lpCallbackInstanceData[nodeNum] ->hWnd = (HWND)hwnd;
    lpCallbackInstanceData[nodeNum] ->dwDevice = (DWORD)nodeNum;
    lpCallbackInstanceData[nodeNum] ->lpBuf = lpInputBuffer;
    lpCallbackInstanceData[nodeNum] ->hOut = 0;

    if(!(err =
    midiInOpen(&hMidiIn,nodeNum,(DWORD)midiCallback,0,CALLBACK_FUNCTION))){
    midiHdr.lpData =sysexbuffer;
    midiHdr.dwBufferLength = sizeof(sysexbuffer);//10000
    midiHdr.dwFlags = 0;
    err = midiInPrepareHeader(hMidiIn,&midiHdr, sizeof(MIDIHDR));//preparing
    sysexbuffer
    if(err){
    return err;
    }
    err = midiInAddBuffer(hMidiIn, &midiHdr, sizeof(MIDIHDR));
    if(err){
    return err;
    }
    midiHdr.dwUser = 1;//flag used for midiInAddBuffer: don't add buffer if
    closing midi. dwUser set to 0 before closing
    err = midiInStart(hMidiIn);
    if(err){
    return err;
    }
    }

    return err;
    }

    void CALLBACK midiCallback(HMIDIIN handle, UINT iMsg,DWORD dwInstance,
    DWORD dwParam1, DWORD dwParam2) {
    LPMIDIHDR lpMIDIHeader;
    EVENT event;
    BYTE bStatusRaw = LOBYTE(LOWORD(dwParam1));


    unsigned char* ptr;
    DWORD bytes = 0;

    switch(iMsg){

    case MIM_OPEN:
    midiInGetErrorText(dwParam1,LPSTR(errStr), 50);
    MessageBox(NULL,errStr,"MIM_OPEN",MB_OK);
    break;

    case MIM_DATA:
    if((bStatusRaw==0xfe) || (bStatusRaw==0xf8)){//filter active
    sensing/system msg
    break;
    }
    event.dwEvent = 0;
    event.device = inDevice;
    event.data = dwParam1;

    event.timestamp = dwParam2;
    PutEvent(lpInputBuffer, (LPEVENT)&event);
    break;

    case MIM_LONGDATA://sysex
    lpMIDIHeader = (LPMIDIHDR)dwParam1;
    ptr = (unsigned char *)(lpMIDIHeader->lpData);
    while(bytes++ < lpMIDIHeader->dwBytesRecorded){
    gSysexLength++;//just counting messages
    }
    if(midiHdr.dwUser==1){
    midiInAddBuffer(hMidiIn, lpMIDIHeader, sizeof(LPMIDIHDR))
    }
    break;

    case MIM_MOREDATA:
    midiInGetErrorText(dwParam1,LPSTR(errStr), 50);
    MessageBox(NULL,errStr,"MIM_MOREDATA",MB_OK);
    break;

    }
    }
  2. vvv wrote
    > err = midiInAddBuffer(hMidiIn, &midiHdr, sizeof(MIDIHDR));
    > midiInAddBuffer(hMidiIn, lpMIDIHeader, sizeof(LPMIDIHDR))


    don't know exactly but I see one strange thing that looks wrong:
    sizeof(LPMIDIHDR) is not same as sizeof(MIDIHDR).

Share This Page