Ñò
äoKc           @   sÏ   d  d k  l Z d  d k l Z d  d k l Z l Z l Z d d d „  ƒ  YZ e	 d j oo d Z
 e e
 ƒ Z e i e e i ƒ ƒ GHd Z
 e e
 d	 ƒ Z e e ƒ Z e i e e i ƒ ƒ GHe i ƒ  n d
 S(   iÿÿÿÿ(   t
   StringType(   t   unpack(   t   readBewt   readVart   varLent   RawInstreamFilec           B   sk   e  Z d  Z d d „ Z d d „ Z d d „ Z d „  Z d d „ Z d d	 „ Z d d d
 „ Z	 d „  Z
 RS(   sÝ   
    
    It parses and reads data from an input file. It takes care of big 
    endianess, and keeps track of the cursor position. The midi parser 
    only reads from this object. Never directly from the file.
    
    t    c         C   sl   | oO t  | t ƒ o, t | d ƒ } | i ƒ  |  _ | i ƒ  q_ | i ƒ  |  _ n
 d |  _ d |  _ d S(   s    
        If 'file' is a string we assume it is a path and read from 
        that file.
        If it is a file descriptor we read from the file, but we don't 
        close it.
        Midi files are usually pretty small, so it should be safe to 
        copy them into memory.
        t   rbR   i    N(   t
   isinstanceR    t   opent   readt   datat   closet   cursor(   t   selft   infile(    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt   __init__   s    		c         C   s   | |  _  d S(   s   Sets the data from a string.N(   R   (   R   R   (    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt   setData.   s    i    c         C   s   | |  _  d S(   s(   Sets the absolute position if the cursorN(   R   (   R   t   position(    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt	   setCursor4   s    c         C   s   |  i  S(   s   Returns the value of the cursor(   R   (   R   (    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt	   getCursor9   s    c         C   s   |  i  | 7_  d S(   s+   Moves the cursor to a new relative positionN(   R   (   R   t   relative_position(    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt
   moveCursor>   s    i   c         C   s9   |  i  } |  i | | | !} | o |  i | ƒ n | S(   s8   Reads the next text slice from the raw data, with length(   R   R   R   (   R   t   lengtht   move_cursort   ct   slc(    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt	   nextSliceD   s
    	c         C   s   t  |  i | | ƒ ƒ S(   su   
        Reads n bytes of date from the current cursor position.
        Moves cursor if move_cursor is true
        (   R   R   (   R   t   n_bytesR   (    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyR   M   s    c         C   s5   d } t  |  i | d ƒ ƒ } |  i t | ƒ ƒ | S(   s}   
        Reads a variable length value from the current cursor position.
        Moves cursor if move_cursor is true
        i   i    (   R   R   R   R   (   R   t
   MAX_VARLENt   var(    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt
   readVarLenU   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   (    (    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyR      s   		t   __main__s   test/midifiles/minimal.mids!   test/midifiles/cubase-minimal.midR   N(    (   t   typesR    t   structR   t   DataTypeConvertersR   R   R   R   R    t	   test_filet   fisR   t   lenR   R	   t   cubase_minimalt   fis2R   (    (    (    sW   C:\Documents and Settings\Administrator\workspace\MINWii\src\mxmMidi\RawInstreamFile.pyt   <module>   s   W