# MidiMessage failing to send

**URL:** <https://forum.juce.com/t/midimessage-failing-to-send/3927>\
**Category:** MacOSX and iOS\
**Created:** [May 15, 2009, 9:37pm UTC](https://forum.juce.com/t/midimessage-failing-to-send/3927 "2009-05-15T21:37:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![travisco\_nabisco](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@travisco\_nabisco](https://forum.juce.com/u/travisco_nabisco)\
**Post date:** [May 15, 2009, 9:37pm UTC](https://forum.juce.com/t/midimessage-failing-to-send/3927/1 "2009-05-15T21:37:19Z")

</div>

I am currently working on porting an app I have built with Juce to the Mac.

Everything seems to work correctly up until I try to send Midi Messages to a USB device. In one case it sends the first sysex message, but in another area of the code it never sends the message correctly. My code for the working and not working sections is below. Any help would be greatly appreciated.

Working:  
midiInput-\>start();  
if(midiOutput) midiOutput-\>sendMessageNow(MidiMessage(gDSPPrepareFlash, sizeof(gDSPPrepareFlash)));

where gDSPPrepareFlash is a in memory array of type char.

Not working:  
msg[0] = 0xF9;  
midiInput-\>start();  
if(midiOutput) midiOutput-\>sendMessageNow(MidiMessage(msg, 1));

Any ideas why seemingling identical code would behave so differently?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 16, 2009, 12:12pm UTC](https://forum.juce.com/t/midimessage-failing-to-send/3927/2 "2009-05-16T12:12:26Z")

</div>

When you say it works sometimes, could there be a threading issue - e.g. it works from one thread but not another?

---

<div class="post-metadata">

**Author:** ![travisco\_nabisco](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@travisco\_nabisco](https://forum.juce.com/u/travisco_nabisco)\
**Post date:** [May 19, 2009, 3:53pm UTC](https://forum.juce.com/t/midimessage-failing-to-send/3927/3 "2009-05-19T15:53:14Z")

</div>

It looks like it is a threading issue. I did some shuffling of where threads are started and killed and got one of the instances to complete a full transaction correctly.

It looks like it will just take some fine tuning to get the other instance running as expected.

Thanks.
