# Path: fretwork/midi/DataTypeConverters.py
# def readBew(value):
#     """
#     Reads string as big endian word, (asserts len(value) in [1,2,4])
# 
#     .. doctest::
# 
#         >>> readBew('aáâã')
#         0
#         >>> readBew('aá')
#         0
#     """
#     try:
#         return unpack('>%s' % {1:'B', 2:'H', 4:'L'}[len(value)], value)[0]
#     except KeyError:
#         return 0
# 
# Path: fretwork/midi/DataTypeConverters.py
# def toBytes(value):
#     "Turns a string into a list of byte values"
#     return unpack('%sB' % len(value), value)


from .DataTypeConverters import readBew
from .DataTypeConverters import toBytes
from .constants import *
    from MidiToText import MidiToText
            channel = readBew(data)
            stream.midi_ch_prefix(channel)

        # MIDI_PORT  = 0x21 (21 01 port (legacy stuff))
        elif meta_type == MIDI_PORT:
            port = readBew(data)
            stream.midi_port(port)

        # END_OFF_TRACK = 0x2F (2F 00)
        elif meta_type == END_OF_TRACK:
            stream.end_of_track()

        # TEMPO = 0x51 (51 03 tt tt tt (tempo in us/quarternote))
        elif meta_type == TEMPO:
            b1, b2, b3 = toBytes(data)
            # uses 3 bytes to represent time between quarter
            # notes in microseconds
            stream.tempo((b1<<16) + (b2<<8) + b3)

        # SMTP_OFFSET = 0x54 (54 05 hh mm ss ff xx)
        elif meta_type == SMTP_OFFSET:
            try:
                hour, minute, second, frame, framePart = toBytes(data)
                stream.smtp_offset(hour, minute, second, frame, framePart)
            except ValueError:
                pass

        # TIME_SIGNATURE = 0x58 (58 04 nn dd cc bb)
        elif meta_type == TIME_SIGNATURE:
            try:

# Path: fretwork/midi/DataTypeConverters.py
# def readBew(value):
#     """
#     Reads string as big endian word, (asserts len(value) in [1,2,4])
# 
#     .. doctest::
# 
#         >>> readBew('aáâã')
#         0
#         >>> readBew('aá')
#         0
#     """
#     try:
#         return unpack('>%s' % {1:'B', 2:'H', 4:'L'}[len(value)], value)[0]
#     except KeyError:
#         return 0
# 
# Path: fretwork/midi/DataTypeConverters.py
# def toBytes(value):
#     "Turns a string into a list of byte values"
#     return unpack('%sB' % len(value), value)


# Path: fretwork/midi/EventDispatcher.py
from .DataTypeConverters import readBew
from .DataTypeConverters import toBytes
from .constants import *
    from MidiToText import MidiToText

            channel = readBew(data)
            stream.midi_ch_prefix(channel)

        # MIDI_PORT  = 0x21 (21 01 port (legacy stuff))
        elif meta_type == MIDI_PORT:
            port = readBew(data)
            stream.midi_port(port)

        # END_OFF_TRACK = 0x2F (2F 00)
        elif meta_type == END_OF_TRACK:
            stream.end_of_track()

        # TEMPO = 0x51 (51 03 tt tt tt (tempo in us/quarternote))
        elif meta_type == TEMPO:
            b1, b2, b3 = toBytes(data)
            # uses 3 bytes to represent time between quarter
            # notes in microseconds
            stream.tempo((b1<<16) + (b2<<8) + b3)

        # SMTP_OFFSET = 0x54 (54 05 hh mm ss ff xx)
        elif meta_type == SMTP_OFFSET:
            try:
                hour, minute, second, frame, framePart = toBytes(data)
                stream.smtp_offset(hour, minute, second, frame, framePart)
            except ValueError:
                pass

        # TIME_SIGNATURE = 0x58 (58 04 nn dd cc bb)
        elif meta_type == TIME_SIGNATURE:
            try:

                nn, dd, cc, bb = toBytes(data)