Hi,

        Have recently completed a test app using portmidi to send sysex
messages to some hardware we are working on. Using a USB analyzer it
became clear that there was an error in the library (portmidi28aug06) we
tracked this down to the winmm_end_sysex() function, here is the
offending code.
I don't have an explanation for this just that it now works.

static PmError winmm_end_sysex(PmInternal *midi, PmTimestamp timestamp)
{
    midiwinmm_type m = (midiwinmm_type) midi->descriptor;
    PmError rslt = pmNoError;
    assert(m);
    if (midi->latency == 0) {
        /* Not using the stream interface. The entire sysex message is
           in m->hdr, and we send it using midiOutLongMsg.
         */

// Here are the changes... this,
//       m->hdr->dwBytesRecorded = m->sysex_byte_count;
// becomes this.
         m->hdr->dwBytesRecorded = 0;
           m->hdr->dwBufferLength = m->sysex_byte_count;
        /*
        { int i; int len = m->hdr->dwBytesRecorded;
          printf("OutLongMsg %d ", len);
          for (i = 0; i < len; i++) {
              printf("%2x ", msg_buffer[i]);
          }
        }
        */
        m->error = midiOutLongMsg(m->handle.out, m->hdr,
sizeof(MIDIHDR));
        if (m->error) rslt = pmHostError;
    } else if (m->hdr) {
        /* Using stream interface. There are accumulated bytes in m->hdr
           to send using midiStreamOut
         */
        /* add bytes recorded to MIDIEVENT length, but don't 
           count the MIDIEVENT data (3 longs) */
        MIDIEVENT *evt = (MIDIEVENT *) m->hdr->lpData;
        evt->dwEvent += m->hdr->dwBytesRecorded - 3 * sizeof(long);
        /* round up BytesRecorded to multiple of 4 */
        m->hdr->dwBytesRecorded =  (m->hdr->dwBytesRecorded + 3) & ~3;
        m->error = midiStreamOut(m->handle.stream, m->hdr, 
                                 sizeof(MIDIHDR));
        if (m->error) {
            rslt = pmHostError;
        }
    }
    m->hdr = NULL; /* make sure we don't send it again */
    return rslt;
}



Nigel

--
Nigel Brown, nbrown(at)akaitech(dot)com
Akai Digital Technology Group, Cambridge




_______________________________________________
media_api mailing list
[email protected]
http://www.create.ucsb.edu/mailman/listinfo/media_api

Reply via email to