tazumi Posted May 18, 2004 Report Share Posted May 18, 2004 Hi,i don´t know if anybody in here already did some Midi programing in C? (serge?) ;)we´ve got a problem with receiving sysex-messages. to receive a sysex message you have to call the method "midiInAddBuffer" to provice a buffer where the sysex-data can be stored in. you have to call it for every package of the message. this works great so far - but the problem is if i close the Indevice now and try to open it again it crashes. if i call "midiInAddBuffer" only once at the beginning, i can reveive only the first package for sure, but now i can close and open the device without any problems.has anyone an idea what we do wrong?thankstazumi Quote Link to comment Share on other sites More sharing options...
pilo Posted May 18, 2004 Report Share Posted May 18, 2004 which API are you using?Copy/paste the source code here ;) Quote Link to comment Share on other sites More sharing options...
tazumi Posted May 18, 2004 Author Report Share Posted May 18, 2004 We're using the standard Windows midi api. I do not have the source code here, so I will try to explain what I do in the code.I open a midi device with the midiInOpen function. I also defined a callback function, where I can receive the messages. After opening the device I start the receiving with midiInStart and add a buffer with midiInAddBuffer.Before adding the buffer I prepare it with midiInPrepareHeader. It all works fine. Now I can receive SysEx messages (and other midi messages).But only the first block. To receive more than one block I make another call of midiInAddBuffer in the callback function (after I received a block). Now I can receive all the other blocks, too.But the device doesn't close (midiInClose) right now and I cannot open it anymore. Do I have to do something else, before calling the second time midiInAddBuffer. I will post the source code as soon as possible. Quote Link to comment Share on other sites More sharing options...
Guest jtbalogh Posted May 21, 2004 Report Share Posted May 21, 2004 Everything you did looks okay. Now use the complimentary midiInUnprepareHeader() too. Always unprepare before using each sysex and before closing.Initialize:- open with midiInOpen() using callback function- prepare with midiInPrepareHeader() for next sysex- buffer with midiInAddBuffer() for next sysex- start with midiInStart()In callback function:- unprepare with midiInUnprepareHeader() old sysex- analyze or use the sysex data retrieved- prepare with midiInPrepareHeader() for next sysex- buffer with midiInAddBuffer() for next sysex- exitWhen closing application:- stop with midiInStop()- reset with midiInReset()- unprepare with midiInUnprepareHeader() old sysex- close with midiInClose()Something like this helped me in windows c programming. This was extracted from my more complicated code so forgive any errors in the suggestions. Quote Link to comment Share on other sites More sharing options...
Guest jtbalogh Posted May 29, 2004 Report Share Posted May 29, 2004 Did this help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.