import mido

inport = mido.open_input('MIDI In')
outport = mido.open_output('MIDI Out')

for msg in inport:
  # filter out clock messages
  if msg.type != "clock":
    if msg.type == "control_change":
      # I want to convert CC81 from channel 7 to Sysex
      if msg.channel == 6 and msg.control == 81:
        sysx = mido.Message('sysex')
        # Roland SYSEX 
        sysx.data = [ 0x41, 0x10, 0x00, 0x00, 0x00, 0x6F, 0x12 ]
        # Parameter chosen
        sysx.data += [ 0x10, 0x00, 0x18, 0x14, 0x08, 0x00 ]
        # convert CC value to Roland Sysex
        sysx.data += [ int(msg.value / 16) , int(msg.value & 15) ]
        # checksum that is not checked :)
        sysx.data += [ 55 ]
        # send the Sysex data
        outport.send(sysx)
        # debug
        # print(sysx.hex())
      else:
        outport.send(msg)
        # print(msg)
    else:
      outport.send(msg)