a �DOg��@s.ddgZddlmZedd�Zdej_dej_dej_d ej_d ej _d d�Z d d�Z gZ d d�Z e �e �dd�Ze �e�dd�Ze �e�dd�Ze �e�dd�Ze �e�dd�Ze �e�dd�Ze �e�dd�Ze �e�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zed)k�r*e�d*S)+�what�whathdr�)� namedtuple� SndHeadersz.filetype framerate nchannels nframes sampwidthz�The value for type indicates the data type and will be one of the strings 'aifc', 'aiff', 'au','hcom', 'sndr', 'sndt', 'voc', 'wav', '8svx', 'sb', 'ub', or 'ul'.zYThe sampling_rate will be either the actual value or 0 if unknown or difficult to decode.z^The number of channels or 0 if it cannot be determined or if the value is difficult to decode.z?The value for frames will be either the number of frames or -1.zAEither the sample size in bits or 'A' for A-LAW or 'U' for u-LAW.cCs t|�}|S)N)r)�filename�res�r�/usr/lib64/python3.9/sndhdr.pyr4scCslt|d��N}|�d�}tD],}|||�}|rt|�Wd�SqWd�dS1s^0YdS)N�rbi)�open�read�testsr)r�f�hZtfrrrr r:s   c Cs�ddl}|�d�sdS|dd�dkr,d}n|dd�dkrBd}ndS|�d�z|�|d �}Wnt|jfyzYdS0||��|��|��d|� �fS) Nr�FORM�� sAIFC�aifcsAIFFZaiff�r) r� startswith�seekr �EOFError�Error� getframerate� getnchannels� getnframes� getsampwidth)rrr�fmt�arrr � test_aifcKs   �rc Cs�|�d�rt}n|dd�dvr&t}ndSd}||dd��}||dd��}||dd��}||dd��}||dd ��}d } |d kr�d } n$|d kr�d} n|d kr�d} d } nd} | |} | r�|| } nd} |||| | fS)Ns.snd�)sds.sdns.Zaurr�����U���?�����)r� get_long_be� get_long_le) rr�func�filetypeZhdr_size� data_size�encoding�rate� nchannelsZ sample_sizeZ sample_bits� frame_sizeZnframerrr �test_au`s2  r3cCsT|dd�dks |dd�dkr$dSt|dd��}|rBd |}nd }d |d d dfS)N�A�EsFSSD��sHCOM��i"VrZhcomr$r)r)r*)rrZdivisorr0rrr � test_hcom�s  r:cCst|�d�sdSt|dd��}d}d|kr6dkrfnn,||dkrfd||d}|rftd |�}d |dd d fS) NsCreative Voice Filer"�ri�r$�r g��.AZvocr)r)r� get_short_le�int)rrZsbseekr0Zratecoderrr �test_voc�s $ r?c Cs�ddl}|�d�r2|dd�dks2|dd�dkr6dS|�d�z|�|d�}Wnt|jfyjYdS0d |��|��|��d|� �fS) NrsRIFFrrsWAVEr!sfmt rZwav) �waverrr rrrrrr)rrr@�wrrr �test_wav�s* �rBcCs"|�d�r|dd�dkrdSdS)Nrrrs8SVX)Z8svxrr$rr)r)rrrrr � test_8svx�srCcCs<|�d�r8t|dd��}t|dd��}d|d|dfSdS)NsSOUNDrrr"r;Zsndtr$)rr+r=)rrZnsamplesr0rrr � test_sndt�s rDcCsD|�d�r@t|dd��}d|kr.dkr@nnd|ddd fSdS) Nsr&r i�i�aZsndrr$r)r)rr=)rrr0rrr � test_sndr�s rEcCs,|dd>|dd>B|dd>B|dBS)Nrr#r$r!r&rr'r��brrr r*�sr*cCs,|dd>|dd>B|dd>B|dBS)Nr'r#r&r!r$rrrrFrrr r+�sr+cCs|dd>|dBS)Nrrr$rrFrrr � get_short_be�srHcCs|dd>|dBS)Nr$rrrrFrrr r=�sr=cCs�ddl}d}|jdd�r8|jddkr8|jdd�=d}z8|jdd�r`t|jdd�|d�ntdg|d�Wn(ty�|j�d�|�d�Yn0dS)Nrr$z-rr&�.z [Interrupted] )�sys�argv�testall�KeyboardInterrupt�stderr�write�exit)rJ� recursiverrr �test�s   rRc Cs�ddl}ddl}|D]�}|j�|�r~t|ddd�|s<|rttd�ddl}|�|j�|�|�d��}t||d�q�td�qt|ddd�|j � �ztt |��Wqt y�td �Yq0qdS) Nrz/:� )�endzrecursing down:�*z*** directory (use -r) ***�:z*** not found ***) rJ�os�path�isdir�print�glob�join�escaperL�stdout�flushr�OSError)�listrQZtoplevelrJrWrr[�namesrrr rL�s"    rL�__main__N)�__all__� collectionsrrr-�__doc__Z framerater1ZnframesZ sampwidthrrr r�appendr3r:r?rBrCrDrEr*r+rHr=rRrL�__name__rrrr �!sH �