Shop OBEX P1 Docs P2 Docs Learn Events
MIDI Output (Via USB or MIDI) — Parallax Forums

MIDI Output (Via USB or MIDI)

RubrChickenRubrChicken Posts: 39
edited 2010-12-03 08:21 in Propeller 1
Good evening propeller forums!

I was working with some (free trial wink.gif ) 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

  • phishguyphishguy Posts: 36
    edited 2009-12-06 14:41
    MIDI is a serial protocol of 8 bits, 1 start bit, 1 stop bit, and no parity at 31250 baud. It is also an optoisolated interface. Therefore, with an optoisolator, and a couple of resistors, you should be able to make a midi out and in. Then you can just use the Full Duplex Serial object for sending and receiving MIDI sequences.

    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
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-12-06 16:44
    Do you mean something like I was in my piano style midi player?
    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.
  • AribaAriba Posts: 2,682
    edited 2009-12-06 17:28
    Attached is a Schematic of the most simple MIDI Out curcuit.
    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
    263 x 131 - 1K
  • WurlitzerWurlitzer Posts: 237
    edited 2009-12-07 14:04
    If you do not want to use the Full Duplex Serial object, this is the PASM code I have been using to send MIDI data to both a PC and my MIDI equipped pipe chamber.

    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,250
    
    
    

    Post Edited (Wurlitzer) : 12/7/2009 2:17:20 PM GMT
  • garylakegarylake Posts: 41
    edited 2010-12-03 08:21
    Hi, this sound good but how to use it? What spin code would I uase and what parameters do you set up for the SendMidi, what data do I need? I want to send a midi note (say 60 middle C), velocity, and channel.
Sign In or Register to comment.