<commit_before>import os.path
import sys
__dir__ = os.path.dirname(__file__)
sys.path.append(os.path.join(__dir__, '..'))

from time import sleep
import simplecoremidi

root_note = 60  # This is middle C
channel = 1  # This is MIDI channel 1
note_on_action = 0x90
major_steps = [2, 2, 1, 2, 2, 2, 1, 0]
velocity = 127

"""
for d in simplecoremidi.MIDIDestination.list():
    print("send scale to %s" % d.name)

    note = root_note
    for step in major_steps:
        d.send((note_on_action | channel,
                   note,
                   velocity))
        sleep(0.1)
        d.send((note_on_action | channel,
                   note,
                   0))  # A note-off is just a note-on with velocity 0

        note += step
        sleep(0.2)

"""

def printBytes(bytes):
  print(bytes)

sources = simplecoremidi.MIDISource.list()
for s in sources:
  print(s.name)


while (True):
  for s in sources:
    bytes = s.receive(5)
    if bytes == None:
      print ('%s timed out' % s.name)
    else:
      print (s.name, str(bytes))<commit_msg>updated example to match readme<commit_after>import os.path
import sys
__dir__ = os.path.dirname(__file__)
sys.path.append(os.path.join(__dir__, '..'))

from simplecoremidi import MIDIDestination, MIDISource
from time import sleep

NOTE_ON = 0x90
channel = 1
MIDDLE_C = 60

for d in MIDIDestination.list():
    print("send message to %s" % d.name)
    d.send((NOTE_ON | channel, MIDDLE_C, 127))
    sleep(1)
    d.send((NOTE_ON | channel, MIDDLE_C, 0))

while (True):
  for s in MIDISource.list():
    bytes = s.receive(timeout=2)
    if bytes == None:
      print ('%s timed out' % s.name)
    else:
      print (s.name, map(hex, bytes))
{'fraction_non_alphanumeric': 0.12359550561797752, 'fraction_numerical': 0.02188054405677114, 'mean_word_length': 2.6862745098039214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2339976', 'n_tokens_mistral': 641, 'n_tokens_neox': 592, 'n_words': 169}