
    ̺i
                     L    S r SSKJr  SSKJr  SSKJr   " S S5      rS rS	 r	g
)zo
MIDI Parser

There is no need to use this module directly. All you need is
available in the top level module.
    )deque   )Message)	Tokenizerc                   J    \ rS rSrSrSS jrS rS rS rS r	S	 r
\
rS
 rSrg)Parser   z
MIDI byte stream parser

Parses a stream of MIDI bytes and produces messages.

Data can be put into the parser in the form of
integers, byte arrays or byte strings.
Nc                 r    [        5       U l        [        5       U l        U(       a  U R	                  U5        g g N)r   messagesr   _tokfeedselfdatas     J/var/www/piano.thomer.com/venv/lib/python3.13/site-packages/mido/parser.py__init__Parser.__init__   s)     K	IIdO     c                     U R                    H2  nU R                  R                  [        R                  " U5      5        M4     g r   )r   r   appendr   
from_bytes)r   
midi_bytess     r   _decodeParser._decode"   s-    ))JMM  !3!3J!?@ $r   c                 Z    U R                   R                  U5        U R                  5         g)zFeed MIDI data to the parser.

Accepts any object that produces a sequence of integers in
range 0..255, such as:

    [0, 1, 2]
    (0, 1, 2)
    [for i in range(256)]
    (for i in range(256)]
    bytearray()
N)r   r   r   r   s     r   r   Parser.feed&   s     			tr   c                 Z    U R                   R                  U5        U R                  5         g)zRFeed one MIDI byte into the parser.

The byte must be an integer in range 0..255.
N)r   	feed_byter   )r   bytes     r   r   Parser.feed_byte5   s    
 			D!r   c                     U  H  nUs  $    g)zGet the first parsed message.

Returns None if there is no message yet. If you don't want to
deal with None, you can use pending() to see how many messages
you can get before you get None, or just iterate over the
parser.
N )r   msgs     r   get_messageParser.get_message=   s     CJ  r   c                 ,    [        U R                  5      $ )z&Return the number of pending messages.)lenr   r   s    r   pendingParser.pendingJ   s    4==!!r   c              #      #    [        U R                  5      S:  a8  U R                  R                  5       v   [        U R                  5      S:  a  M7  gg7f)z,Yield messages that have been parsed so far.r   N)r(   r   popleftr)   s    r   __iter__Parser.__iter__P   s<     $-- 1$--'')) $-- 1$s   AAA)r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r%   r*   __len__r.   __static_attributes__r#   r   r   r   r      s2    A" G*r   r   c                 *    [        [        U 5      5      $ )a!  Parse MIDI data and return a list of all messages found.

This is typically used to parse a little bit of data with a few
messages in it. It's best to use a Parser object for larger
amounts of data. Also, tt's often easier to use parse() if you
know there is only one message in the data.
)listr   r   s    r   	parse_allr:   V   s     tr   c                 4    [        U 5      R                  5       $ )zParse MIDI data and return the first message found.

Data after the first message is ignored. Use parse_all()
to parse more than one message.
)r   r%   r9   s    r   parser<   a   s     $<##%%r   N)
r4   collectionsr   r   r   	tokenizerr   r   r:   r<   r#   r   r   <module>r?      s,   
    B* B*J&r   