o
    i,                     @   s  U d dl mZ d dlmZmZmZmZmZ d dlZd dl	Z
d dlmZmZ d dlmZ d dlmZ d dlmZ 	 ddd	d	d
d
dddddddZdd e D Zdd e D Zeeejf ed< edeZeddd%dejded dee fddZedddejde
jfddZ		d&dejdee d eeej  dejfd!d"Z edZ!e D ]\Z"Z#ee"dZ$ee"d#Z%ee"Ze!j&e#e$e%ed$e'ee"_(qdS )'    )	lru_cache)DictIteratorLiteralOptionalSetN)Codeccodecs_available)UnknownCodecError)typing)get_templatef8f4i2i4i8u1)dbldblpfltfltps16s16ps32s32ps64s64pu8u8pc                 C   s&   i | ]\}}| d st||qS )p)endswithnpdtype).0namer"    r%   F/home/ubuntu/.local/lib/python3.10/site-packages/audiolab/av/format.py
<dictcomp>+   s   & r'   c                 C   s   i | ]}|t |qS r%   )avAudioFormat)r#   r$   r%   r%   r&   r'   ,   s    audio_formatsr)   )maxsizerformatmode)r,   wreturnc              	   C   s   t  }t| tjr| j} tD ]1}z&t||}|j}|jdks"|d u r$W q| t dd |D v r5|	|j W q t
y?   Y qw |S )Naudioc                 s   s    | ]}|j V  qd S N)r$   r#   r-   r%   r%   r&   	<genexpr>;   s    zget_codecs.<locals>.<genexpr>)set
isinstancer(   r)   r$   r	   r   r*   typeaddr
   )r-   r.   codecscodecformatsr%   r%   r&   
get_codecs0   s    
r<   c                 C   s    t | tjr	| j} tt|  S r2   )r6   r(   r)   r$   r!   r"   format_dtypes)r-   r%   r%   r&   	get_dtypeB   s   r>   r"   	is_planaravailable_formatsc                 C   s   t | tr	| tvst | trt| } t | tjrIt|  } |d ur*| |r&dnd } n|d us0J dd |D }| |vrI| drE| dn| d } t	|  j
S )Nr    c                 S   s"   g | ]}t |tjr|jn|qS r%   )r6   r   r)   r$   r3   r%   r%   r&   
<listcomp>V   s    zget_format.<locals>.<listcomp>)r6   strr=   r7   r!   r"   dtype_formatsr    rstripr)   value)r"   r?   r@   r%   r%   r&   
get_formatI   s   

rG   r/   )r-   decodecsencodecsr"   )r,   )NN))	functoolsr   r   r   r   r   r   r   r(   numpyr!   r   r	   av.codec.codecr
   audiolab.avaudiolab.av.utilsr   r=   itemsrD   keysr*   rC   r)   __annotations__AudioFormatEnumr<   r"   r>   DtypeboolrG   templater$   r-   rH   rI   rendergetattr__doc__r%   r%   r%   r&   <module>   sb   $$


