MIDI Output (Via USB or MIDI)
Good evening propeller forums!
I was working with some (free trial
) DJ software that had midi control. I wanted to use a few common buttons such as play and sync without the oh-so-cumbersome action of using the mouse, so I thought of a midi controller. I hooked up a midi keyboard, and it worked fine. Then I thought, why not have a dedicated box for this? So... Off the OBEX. I found two MIDI in objects, but no MIDI out objects! Is there a way to send MIDI messages to a computer over the prop's USB connection? If not, I can go out and buy a MIDI plug, and use that. The keyboard has a MIDI in, so I could send signals through that. I know what midi messages I want to send, I want to be able to configure the device easily to any message. I have no problem with the button push thing, but how do I A)Send MIDI messages and B)Have the propeller identify itself as a midi device?
I believe midi data looks something like this:
Thanks!
I was working with some (free trial
) DJ software that had midi control. I wanted to use a few common buttons such as play and sync without the oh-so-cumbersome action of using the mouse, so I thought of a midi controller. I hooked up a midi keyboard, and it worked fine. Then I thought, why not have a dedicated box for this? So... Off the OBEX. I found two MIDI in objects, but no MIDI out objects! Is there a way to send MIDI messages to a computer over the prop's USB connection? If not, I can go out and buy a MIDI plug, and use that. The keyboard has a MIDI in, so I could send signals through that. I know what midi messages I want to send, I want to be able to configure the device easily to any message. I have no problem with the button push thing, but how do I A)Send MIDI messages and B)Have the propeller identify itself as a midi device?I believe midi data looks something like this:
F0 7F 7F 06 01 F7
Thanks!

Comments
See this site for reference. It has a schematic of a Rs232/MIDI converter. You wouldn't need the MAX232 as you would be using IO pin levels.
www.compuphase.com/electronics/midi_rs232.htm
Based on Andy's "MIDI Expander" so you'll need to install the Roland Driver from
tomscarff.110mb.com/USB_MIDI/USB_MIDI.htm
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
The difference to the normal 5V circuit is the missing resistor at +3,3V, so this pin is not
short circuit proof.
As phisguy described, you can use the FullDuplexSerial driver with 31250 Baud, to send MIDI Bytes.
Andy
Prior to calling "SendDataBits" tmp2 must = 8 for 8 databits and "NumBytesToSend" must be set to the number of bytes in the message as they are not all 3 byte messages. NOTE: My data has the Bytes in reverse order from how they must be sent hence the "rol MIDI_PipeMsg, #16" statement which just gets the proper byte in position to send.
There is no need to "Identify" the prop as a MIDI device.
This has been rock solid code while it could be cleaned up a bit I will most likely leave it alone.
EDIT: NOTE: I use a 2N2222 to buffer the output from the Prop and that has worked well over 50' of cable from the console to the pipe chamber. If you don't use such a buffer then you should use MUXC instead of MUXNC to invert the output.
SendMIDI 'Upon entering, DIRA for 2 Midi output pins must be set appropriately ' mov tmp2, #8 '8 data bits mov tmp1, #0 wz ' all this does is set the zero flag muxz outa, midiOutPipe 'send Start Bit for pipe chamber if DIRA is enabled SendDataBits call #BaudDelay 'waits the appropriate time based upon selected baudrate ror MIDI_PipeMsg,#1 wc 'the carry bit reflects the status of the LSbit muxnc outa, midiOutPipe djnz tmp2, #SendDataBits wz 'now send stop bits call #BaudDelay 'waits the appropriate time based upon selected baudrate mov tmp1, #0 wz ' all this does is set the zero flag muxnz outa, midiOutPipe 'send Stop Bit for pipe chamber if DIRA is enabled call #BaudDelay 'waits the appropriate time based upon selected baudrate rol MIDI_PipeMsg, #16 'shift byte just sent then 1 byte more. Next databyte=LSByte djnz NumBytesToSend, #SendMidi'number of bytes must be set prior to call SendMIDI SendMIDI_ret ret '=============================================================================== '=============================================================================== BaudDelay mov bitClk,cnt add bitClk,bitticks waitcnt bitClk,bitticks BaudDelay_ret ret ...blah, blah, other code bitticks long 2560' 2560-8cpu cycles for BaudDelay Call and Return. One bit width = clkfreq / 31,250Post Edited (Wurlitzer) : 12/7/2009 2:17:20 PM GMT