Skip to content

Commit

Permalink
Added python script to test real-time MIDI message handling - issue #52
Browse files Browse the repository at this point in the history
  • Loading branch information
ravelox committed May 4, 2020
1 parent 9c3b93a commit 06e7a0f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions python/realtimemsg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/python

import sys
import socket
import struct
import time

local_port = 5006

if len(sys.argv) == 1:
family = socket.AF_INET
connect_tuple = ( 'localhost', local_port )
else:
details = socket.getaddrinfo( sys.argv[1], local_port, socket.AF_UNSPEC, socket.SOCK_DGRAM)
family = details[0][0]
if family == socket.AF_INET6:
connect_tuple = ( sys.argv[1], local_port, 0, 0)
else:
connect_tuple = ( sys.argv[1], local_port)

s = socket.socket( family, socket.SOCK_DGRAM )
s.connect( connect_tuple )

# Note ON with interleaved Timing Clock
bytes = struct.pack( "BBBB",0x90, 0xF8, 0x30, 0x70 )
s.send( bytes )

s.close()

0 comments on commit 06e7a0f

Please sign in to comment.