
    ̺ix                     8    S SK r S SKrSSKJr  Sr " S S5      rg)    N   )portszmido.backends.rtmidic                       \ rS rSrSrSS jr\S 5       r\S 5       rS r	S r
S	 rSS
 jrSS jr  SS jrS rS rS rS rS rSrg)Backend   z
Wrapper for backend module.

A backend module implements classes for input and output ports for
a specific MIDI library. The Backend object wraps around the
object and provides convenient 'open_*()' and 'get_*_names()'
functions.
Nc                 ~   U=(       d$    [         R                  R                  S[        5      U l        X l        X@l        S U l        U(       a  X l        ORU R                  (       a:  SU R                  ;   a*  U R                  R                  SS5      u  U l        U l        OS U l        U(       a  U R                  5         g g )NMIDO_BACKEND/   )
osenvirongetDEFAULT_BACKENDnameapiuse_environ_modulesplitload)selfr   r   r   r   s        T/var/www/piano.thomer.com/venv/lib/python3.13/site-packages/mido/backends/backend.py__init__Backend.__init__   s    KBJJNN>?K	& HYY3$))+"&))//#q"9DItxDHIIK     c                 :    U R                  5         U R                  $ )zA reference module implementing the backend.

This will always be a valid reference to a module. Accessing
this property will load the module. Use .loaded to check if
the module is loaded.
)r   r   r   s    r   moduleBackend.module'   s     			||r   c                     U R                   SL$ )z$Return True if the module is loaded.N)r   r   s    r   loadedBackend.loaded2   s     ||4''r   c                 r    U R                   (       d&  [        R                  " U R                  5      U l        gg)zLoad the module.

Does nothing if the module is already loaded.

This function will be called if you access the 'module'
property.N)r    	importlibimport_moduler   r   r   s    r   r   Backend.load7   s&     {{$22499=DL r   c                 d    U R                   (       a  [        R                  R                  U5      $ g )N)r   r   r   r   )r   r   s     r   _envBackend._envA   s!    ::>>$''r   c                 R    U R                   (       a  SU;  a  U R                   US'   U$ )Nr   )r   r   kwargss     r   _add_apiBackend._add_apiG   s"    88V+ HHF5Mr   c                     UR                  [        X#S95        Uc  U R                  S5      nU R                  R                  " U40 U R                  U5      D6$ )a  Open an input port.

If the environment variable MIDO_DEFAULT_INPUT is set,
it will override the default port.

virtual=False
  Passing True opens a new port that other applications can
  connect to. Raises IOError if not supported by the backend.

callback=None
  A callback function to be called when a new message arrives.
  The function should take one argument (the message).
  Raises IOError if not supported by the backend.
)virtualcallbackMIDO_DEFAULT_INPUT)updatedictr'   r   Inputr,   )r   r   r/   r0   r+   s        r   
open_inputBackend.open_inputL   sL     	d7>?<9912D{{  ?v)>??r   c                     UR                  [        X#S95        Uc  U R                  S5      nU R                  R                  " U40 U R                  U5      D6$ )a  Open an output port.

If the environment variable MIDO_DEFAULT_OUTPUT is set,
it will override the default port.

virtual=False
  Passing True opens a new port that other applications can
  connect to. Raises IOError if not supported by the backend.

autoreset=False
  Automatically send all_notes_off and reset_all_controllers
  on all channels. This is the same as calling `port.reset()`.
)r/   	autoresetMIDO_DEFAULT_OUTPUT)r2   r3   r'   r   Outputr,   )r   r   r/   r8   r+   s        r   open_outputBackend.open_outputb   sL     	d7@A<9923D{{!!$@$--*?@@r   c                    UR                  [        X#US95        Uc  U R                  S5      =(       d    Sn[        U R                  S5      (       a,  U R                  R
                  " U40 U R                  U5      D6$ U(       a  U=pgO"U R                  S5      nU R                  S5      nU R                  U5      n[        R
                  " U R                  R                  " U40 UD6U R                  R                  " U40 UD65      $ )aK  Open a port for input and output.

If the environment variable MIDO_DEFAULT_IOPORT is set,
it will override the default port.

virtual=False
  Passing True opens a new port that other applications can
  connect to. Raises IOError if not supported by the backend.

callback=None
  A callback function to be called when a new message arrives.
  The function should take one argument (the message).
  Raises IOError if not supported by the backend.

autoreset=False
  Automatically send all_notes_off and reset_all_controllers
  on all channels. This is the same as calling `port.reset()`.
)r/   r0   r8   NMIDO_DEFAULT_IOPORTIOPortr1   r9   )
r2   r3   r'   hasattrr   r?   r,   r   r4   r:   )r   r   r/   r0   r8   r+   
input_nameoutput_names           r   open_ioportBackend.open_ioportw   s    ( 	d7%.0 	1 <9923;tD4;;));;%%dDdmmF.CDD +//
[!YY';<
"ii(=>]]6*F<< 1 1* G G $ 2 2; I& IK Kr   c                     [        U R                  S5      (       a+  U R                  R                  " S0 U R                  U5      D6$ / $ )Nget_devices )r@   r   rF   r,   r*   s     r   _get_devicesBackend._get_devices   s9    4;;..;;**CT]]6-BCCIr   c                     U R                   " S0 U R                  U5      D6nU Vs/ s H  o3S   (       d  M  US   PM     nnU$ s  snf )z&Return a list of all input port names.is_inputr   rG   rH   r,   r   r+   devicesdevicenamess        r   get_input_namesBackend.get_input_names   sH    ##<dmmF&;<.5LgF
9KgL M
   A	Ac                     U R                   " S0 U R                  U5      D6nU Vs/ s H  o3S   (       d  M  US   PM     nnU$ s  snf )z'Return a list of all output port names.	is_outputr   rG   rL   rM   s        r   get_output_namesBackend.get_output_names   sH    ##<dmmF&;<.5MgF9LgM NrS   c                    U R                   " S0 U R                  U5      D6nU Vs/ s H  o3S   (       d  M  US   PM     nnU Vs1 s H  o3S   (       d  M  US   iM     nnU Vs/ s H  ofU;   d  M
  UPM     sn$ s  snf s  snf s  snf )z$Return a list of all I/O port names.rK   r   rU   rG   rL   )r   r+   rN   rO   inputsoutputsr   s          r   get_ioport_namesBackend.get_ioport_names   s    ##<dmmF&;</6MwV:L.&.wM)0I)0v;4GNF6N 	 I!';7?;; NI;s"   A<	A<B	B&	B3Bc                     U R                   (       a  SnOSnU R                  (       a  U R                   SU R                   3nOU R                  nSU SU S3$ )Nr    z
not loadedr
   z	<backend z (z)>)r    r   r   )r   statusr   s      r   __repr__Backend.__repr__   sP    ;;F!F88ii[$((,D99D4&6("--r   )r   r   r   r   )NNFT)NFN)NFF)NFNF)__name__
__module____qualname____firstlineno____doc__r   propertyr   r    r   r'   r,   r5   r;   rC   rH   rQ   rV   r[   r_   __static_attributes__rG   r   r   r   r      sw    "   ( (>
@,A* .3-2-K^<.r   r   )r#   r    r   r   r   rG   r   r   <module>ri      s!   
  	 (~. ~.r   