# 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
        "Triggers the start of track event"

        # I do this twice so that users can overwrite the
        # start_of_track event handler without worrying whether the
        # track number is updated correctly.
        self.outstream.set_current_track(current_track)
        self.outstream.start_of_track(current_track)

    def sysex_event(self, data):
        "Dispatcher for sysex events"
        self.outstream.system_exclusive(data)

    def eof(self):
        "End of file!"
        self.outstream.eof()

    def update_time(self, new_time=0, relative=1):
        "Updates relative/absolute time."
        self.outstream.update_time(new_time, relative)

    def reset_time(self):
        "Updates relative/absolute time."
        self.outstream.reset_time()

    # Event dispatchers for similar types of events
    def channel_messages(self, hi_nible, channel, data):

        "Dispatches channel messages"

        stream = self.outstream

# 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

        "Triggers the start of track event"

        # I do this twice so that users can overwrite the
        # start_of_track event handler without worrying whether the
        # track number is updated correctly.
        self.outstream.set_current_track(current_track)
        self.outstream.start_of_track(current_track)

    def sysex_event(self, data):
        "Dispatcher for sysex events"
        self.outstream.system_exclusive(data)

    def eof(self):
        "End of file!"
        self.outstream.eof()

    def update_time(self, new_time=0, relative=1):
        "Updates relative/absolute time."
        self.outstream.update_time(new_time, relative)

    def reset_time(self):
        "Updates relative/absolute time."
        self.outstream.reset_time()

    # Event dispatchers for similar types of events
    def channel_messages(self, hi_nible, channel, data):

        "Dispatches channel messages"

        stream = self.outstream

        data = toBytes(data)