omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Got MIDI working!!!!!

    Pythonista
    1
    1
    425
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • eriknie
      eriknie last edited by

      I wrote an Pythonista application to show lyrics and chord for live performance. It also plays backingtracks and is able to sort setlists. Works great. But I missed the option to use it with MIDI program changes to also setup my synths to the matching programs.
      Finally I found a way to get this working: Pythonista --> UDP --> MidiFire --> MIDI-out
      Could also be used the other way to receive midi data
      Use MidiFire with OSC Exchange to MIDI synth. Setup UDP to port 8051, wrap data in sysex to no.

      From Pythonista use the simple code that i found elsewhere, easy to tweak into program changes or other midi commands.
      I hope this helps others

      #https://adamsiembida.com/how-to-send-a-udp-packet-in-python/
      import socket
      
      # addressing information of target
      #fill in your ip and port
      IPADDR = '127.0.0.1'
      PORTNUM = 8051
      
      # enter the data content of the UDP packet as hex
      msg1 = bytearray([0x90, 0x40, 0x60])
      msg2 = bytes.fromhex('903e70')
      #or using variable for midi note message
      midi_message = '903c50'
      midi_packet = bytes.fromhex(midi_message)
      
      # initialize a socket, think of it as a cable
      # SOCK_DGRAM specifies that this is UDP
      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
      
      try:
        # connect the socket, think of it as connecting the cable to the address location
        s.connect((IPADDR, PORTNUM))
      
        # send the command
        s.send(midi_packet)
        s.send(msg1)
        s.send(msg2)
        # close the socket
      except:
        pass
      
      # close the socket
      s.close()
      
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB Forums | Contributors