mò
­fIc           @   sŽ  d  Z  d k Z d k Z d k Z d k Z d d g Z h  Z e i ƒ  Z e i	 d d ƒ e e d <e i ƒ  Z e i	 d d ƒ e e d <e i ƒ  Z e i	 d	 d ƒ e e d
 <e i ƒ  Z e i	 d d ƒ e e d <e i ƒ  Z e i	 d d ƒ e e d <e i ƒ  Z e i	 d d ƒ e e d <e i ƒ  Z e i	 d d ƒ e e d <e i ƒ  Z
 e
 i	 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.
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   t  Z RS(   N(   t   __name__t
   __module__(    (    (    t#   /mit/python/lib/python2.4/toaiff.pyR    :   s   c      	   C   s   g  } d  } z t |  | ƒ } Wd  xW | D]N } | | j o; y t i | ƒ Wn t i j
 o n X| i	 | ƒ q* q* WX| S(   N(
   t   tempst   Nonet   rett   _toaifft   filenamet   tempt   ost   unlinkR    t   remove(   R   R   R   R   (    (    R   R   =   s      c         C   s  |  d d j oZ t i ƒ  \ } } t i | ƒ | i | ƒ t	 i
 |  | ƒ } | o t |  d ‚ qq n |  } y( t i | ƒ } | o | d } n WnÃ t j
 o· } t | ƒ t f  ƒ j o[ t | ƒ d j oH t | d ƒ t d ƒ j o+ t | d ƒ t d ƒ j o | d } n t | ƒ t d ƒ j o t | ƒ } n t |  d | ‚ n X| d	 j o | Sn | d  j p | t j o t d
 |  | f ‚ n t i ƒ  \ } } t i | ƒ | i | ƒ t | i
 | | ƒ } | o 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(   R   t   tempfilet   mkstempt   fdt   fnameR   t   closeR   t   appendR	   t   copyt   stsR    t   sndhdrt   whathdrt   ftypet   IOErrort   msgt   typet   lent   reprR   t   tableR   (   R   R   R   R"   R   R   R   R$   (    (    R   R   L   s:    f(   t   __doc__R   R   t   pipesR    t   __all__R(   t   Templatet   tR   R	   t	   ExceptionR    R   R   (   R+   R	   R   R*   R   R-   R    R(   R    R   R   (    (    R   t   ?	   s@   				






	