ó
è¾bc           @   s½  d  Z  d d l m Z e d d d ƒ[ d d l Z d d l Z d d l Z d d l Z d d g Z i  Z e j	 ƒ  Z
 e
 j d	 d
 ƒ e
 e d <e j	 ƒ  Z
 e
 j d d
 ƒ e
 e d <e j	 ƒ  Z
 e
 j d d
 ƒ e
 e d <e j	 ƒ  Z
 e
 j d d
 ƒ e
 e d <e j	 ƒ  Z
 e
 j d d
 ƒ e
 e d <e j	 ƒ  Z
 e
 j d d
 ƒ e
 e d <e j	 ƒ  Z
 e
 j d d
 ƒ e
 e d <e j	 ƒ  Z e j d d
 ƒ d e f d „  ƒ  YZ d „  Z d „  Z d S(   sª  Convert "arbitrary" sound files to AIFF (Apple and SGI's audio format).

Input may be compressed.
Uncompressed file type may be AIFF, WAV, VOC, 8SVX, NeXT/Sun, and others.
An exception is raised if the file is not of a recognized type.
Returned filename is either the input filename or a temporary filename;
in the latter case the caller must ensure that it is removed.
Other temporary files used are removed by the function.
iÿÿÿÿ(   t   warnpy3ks0   the toaiff module has been removed in Python 3.0t
   stackleveli   Nt   errort   toaiffs   sox -t au - -t aiff -r 8000 -s   --t   aus    sox -t hcom - -t aiff -r 22050 -t   hcoms   sox -t voc - -t aiff -r 11025 -t   vocs   sox -t wav - -t aiff -t   wavs    sox -t 8svx - -t aiff -r 16000 -t   8svxs    sox -t sndt - -t aiff -r 16000 -t   sndts    sox -t sndr - -t aiff -r 16000 -t   sndrt
   uncompressc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /usr/lib/python2.7/toaiff.pyR   =   s   c      	   C   s}   g  } d  } z t |  | ƒ } Wd  xS | D]J } | | k r* y t j | ƒ Wn t j k
 rc n X| j | ƒ q* q* WX| S(   N(   t   Nonet   _toaifft   ost   unlinkR   t   remove(   t   filenamet   tempst   rett   temp(    (    s   /usr/lib/python2.7/toaiff.pyR   @   s    c         C   sê  |  d d k rg t  j ƒ  \ } } t j | ƒ | j | ƒ t j |  | ƒ } | rm t |  d ‚ qm n |  } y& t j	 | ƒ } | r’ | d } n  Wnº t
 k
 rO} t | ƒ t d ƒ k rt | ƒ d k rt | d ƒ t d ƒ k rt | d ƒ t d ƒ k r| d } n  t | ƒ t d ƒ k r;t | ƒ } n  t |  d | ‚ n X| d	 k r`| S| d  k sx| t k rŽt d
 |  | f ‚ n  t  j ƒ  \ } } t j | ƒ | j | ƒ t | j | | ƒ } | ræt |  d ‚ n  | S(   Niþÿÿÿs   .Zs   : uncompress failedi    i   i   t    s   : t   aiffs"   %s: unsupported audio file type %rs   : conversion to aiff failed(    (   t   tempfilet   mkstempR   t   closet   appendR   t   copyR   t   sndhdrt   whathdrt   IOErrort   typet   lent   reprR   t   table(   R   R   t   fdt   fnamet   stst   ftypet   msgR   (    (    s   /usr/lib/python2.7/toaiff.pyR   O   s<    *8(   t   __doc__t   warningsR    R   R   t   pipesR   t   __all__R$   t   Templatet   tR   R   t	   ExceptionR   R   R   (    (    (    s   /usr/lib/python2.7/toaiff.pyt   <module>	   sF   






	