o
    wÖi  ã                   @   sl   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 dd„ Z
dd	„ Zd
d„ Zg Zddd„Zddd„ZdS )z-Multi-library, cross-platform audio decoding.é   )Úffdec)ÚDecodeErrorÚNoBackendError)Úversion)Ú	AudioFilec               	   C   st   zddl } W n
 ty   Y dS w z|  dd¡ W n ttfy%   Y dS w z	ddlm} W dS  ty9   Y dS w )zSDetermine whether Gstreamer and the Python GObject bindings are
    installed.
    é    NFÚGstz1.0)r   T)ÚgiÚImportErrorÚrequire_versionÚ
ValueErrorÚAttributeErrorÚgi.repositoryr   )r	   r   © r   úO/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/audioread/__init__.pyÚ_gst_available   s    ÿÿýÿr   c                  C   s   ddl } | j d¡}|duS )zUDetermines whether CoreAudio is available (i.e., we're running on
    Mac OS X).
    r   NÚAudioToolbox)Úctypes.utilÚutilÚfind_library)ÚctypesÚlibr   r   r   Ú_ca_available-   s   r   c                  C   s$   zddl } W dS  ty   Y dS w )z4Determines whether the pymad bindings are available.r   NFT)Úmadr
   )r   r   r   r   Ú_mad_available6   s   
ýÿr   Fc                 C   sž   t r| st S ddlm} |jg}tƒ rddlm} | |j¡ tƒ r.ddlm	} | |j
¡ tƒ r=ddlm} | |j¡ t ¡ rG| tj¡ |t dd…< t S )a   Returns a list of backends that are available on this system.

    The list of backends is cached after the first call.
    If the parameter `flush_cache` is set to `True`, then the cache
    will be flushed and the backend list will be reconstructed.
    r   )Úrawread)Úmacca)Úgstdec)ÚmaddecN)ÚBACKENDSÚ r   ÚRawAudioFiler   r   ÚappendÚExtAudioFiler   r   ÚGstAudioFiler   r   ÚMadAudioFiler   Ú	availableÚFFmpegAudioFile)Úflush_cacher   Úresultr   r   r   r   r   r   Úavailable_backendsD   s"   r*   Nc              	   C   s>   |du rt ƒ }|D ]}z|| ƒW   S  ty   Y q	w tƒ ‚)a$  Open an audio file using a library that is available on this
    system.

    The optional `backends` parameter can be a list of audio file
    classes to try opening the file with. If it is not provided,
    `audio_open` tries all available backends. If you call this function
    many times, you can avoid the cost of checking for available
    backends every time by calling `available_backends` once and passing
    the result to each `audio_open` call.

    If all backends fail to read the file, a NoBackendError exception is
    raised.
    N)r*   r   r   )ÚpathÚbackendsÚBackendClassr   r   r   Ú
audio_openl   s   ÿr.   )F)N)Ú__doc__r    r   Ú
exceptionsr   r   r   Ú__version__Úbaser   r   r   r   r   r*   r.   r   r   r   r   Ú<module>   s   	
(