
~YKc           @   s;  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z e i i d d  Z e Z	 e Z
 d e j oA y- d  d k Z	 e	 i d  e i e	 i  Wn e Z	 n Xn d e j o@ y d  d k Z
 e
 Wn% y d  d k Z
 e
 Wn n Xn Xn e a e a e
 o) e a d   Z d   Z e i e  n e a e a e i   Z d	 a d
   Z d   Z d e f d     YZ d e  i i  f d     YZ! d	 a" d e f d     YZ# g  Z$ h  Z% e e e& e d  Z' d   Z( d   Z) d   Z* d   Z+ d   Z e a, d   Z- d   Z. e i/ Z0 e i/ d Z1 d   Z2 d S(   iNt   RENPY_DISABLE_SOUNDt    t   pssi   t   mixc           C   s5   t  o* t o" t i   a t i   a t a n d  S(   N(   t   mix_okt   mixer_enabledR   t   get_wavet   old_wavet   get_midit   old_midit   True(    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   enable_mixerC   s    c           C   s^   t  p t o d  Sn t d  j	 o t i t  n t d  j	 o t i t  n t a d  S(   N(	   R   R   R   t   NoneR   t   set_waveR	   t   set_midit   False(    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   disable_mixerO   s    i    c           C   s   t  d 7a  t t  f S(   sE   
    Gets a globally unique serial number for each music change.
    i   (   t   serialt   unique(    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt
   get_serialh   s    
c         C   s   t  i i |   } | S(   s<   
    Returns a file-like object for the given filename.
    (   t   renpyt   loadert   load(   t   fnt   rv(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR   r   s    t
   QueueEntryc           B   s   e  Z d  Z d   Z RS(   s   
    A queue entry object.
    c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   filenamet   fadeint   tight(   t   selfR   R   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   __init__   s    		(   t   __name__t
   __module__t   __doc__R   (    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR   {   s   t   MusicContextc           B   s&   e  Z d  Z d Z d   Z d   Z RS(   s   
    This stores information about the music in a game. This object
    participates in rollback, so when the user goes back in time, all
    the values get reverted as well.
    i    c         C   s_   t  t |   i   d  |  _ d |  _ d  |  _ d |  _ d |  _ t	 |  _
 g  |  _ t	 |  _ d  S(   Ni    g      ?(   t   superR"   R   R   t   pan_timet   pant   secondary_volume_timet   secondary_volumet   last_changedR   t
   last_tightt   last_filenamest
   force_stop(   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR      s    							c         C   s    t    } | i i |  i  | S(   s9   
        Returns a shallow copy of this context.
        (   R"   t   __dict__t   update(   R   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   copy   s    	(   R   R    R!   t   __version__R   R.   (    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR"      s   	t   Channelc           B   s   e  Z d  Z d   Z d   Z e e  Z d   Z e e  Z d   Z	 e
 d  Z d   Z d   Z e e
 d d d	  Z d
   Z d   Z d   Z d   Z d   Z RS(   sD   
    This stores information about the currently-playing music.
    c         C   s   | |  _  d  |  _ d  |  _ d |  _ d |  _ g  |  _ g  |  _ t |  _	 t |  _
 t |  _ d |  _ d  |  _ d  |  _ d  |  _ | |  _ | |  _ d |  _ | d  j o t |  _ t |  _ n | |  _ t |  _ d  S(   Ng      ?i    (   t   nameR   t   _numbert   mixert   chan_volumet   actual_volumet   queuet   loopR   t   playingt	   wait_stopt   synchro_startR(   t   callbackR$   R&   t   stop_on_muteR   t
   keep_queueR
   t   default_loopt   default_loop_set(   R   R1   R>   R<   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR      s,    																			c         C   s5   |  i  } | d j o t } |  _  t d 7a n | S(   sk   
        Returns the number of this channel, allocating a number if that
        proves necessary.
        i   N(   R2   R   t   next_channel_number(   R   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt
   get_number	  s
    	c         C   sM   t  i i   i } | i |  i  } | d j o t   } | |  i <n | S(   s   
        Returns the MusicContext corresponding to this channel, taken from
        the context object. Allocates a MusicContext if none exists.
        N(   R   t   gamet   contextt   musict   getR1   R   R"   (   R   t   mcdR   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   get_context  s
    c   	      C   s  |  i  i p t i i i |  i o |  i } |  i o- | o& t	 i
 |  i  t |  _ t |  _ n | o9 |  i o |  i t |  i  |  _ n
 g  |  _ d Sn t } xt ot	 i |  i  } | d j o t |  _ t |  _ n |  i p Pn | d j o Pn |  i o | o Pn t	 i |  i  d j o Pn |  i i d  } | i i   } x( d D]  } | i |  o
 d } qfqfW| p q n y t | i  } | d j o8 t	 i |  i | | i d |  i d	 | i d
 | i n, t	 i |  i | | i d	 | i d
 | i t |  _ WnM x+ | i |  i j o |  i i | i  q-Wt i i o   qtd Sn XPq W|  i oH |  i o= x@ |  i D]+ } t  | d | i  } |  i i! |  qWn t } | o |  i" o |  i"   n d S(   s}   
        This is the periodic call that causes this channel to load new stuff
        into its queues, if necessary.
        Ni    i   s   .mods   .xms   .mids   .midit   pausedR   R   (   s   .mods   .xms   .mids   .midi(#   RC   R+   R   RB   t   preferencest   muteR3   R<   R8   R   t   stopt   numberR   R9   R7   R6   t   lenR
   t   queue_depthR:   t   popR   t   lowert   endswithR   R   t   playR   R   t   removet   configt   debug_soundR   t   appendR;   (	   R   R+   t   do_callbackt   deptht   topqt   lfnt   it   topft   newq(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   periodic*  sj    -	
	
	
 8+
 c         C   sV   |  i  |  i  |  _  g  |  _ t p d Sn |  i d j o t i |  i |  n d S(   s   
        Clears the queued music.

        If the first item in the queue has not been started, then it is
        left in the queue unless all is given.
        Ni    (   R6   R=   R7   t   pcm_okR   t   dequeueRL   (   R   t
   even_tight(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR`     s    	c         C   s   d |  _  t o |  i |  i i j o/ |  i i |  _ t i |  i |  i i d  n |  i |  i i j o/ |  i i |  _ t i	 |  i |  i i
 d  q n |  i o |  i o |  i   n d S(   s7   
        Called (mostly) once per interaction.
        i    N(   R=   R_   R$   RC   R   t   set_panRL   R%   R&   t   set_secondary_volumeR'   R6   R;   (   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   interact  s    			c         C   sd   d |  _  |  i   t p d Sn | d j o t i |  i  n t i |  i t | d   d S(   s   
        Causes the playing music to be faded out for the given number
        of seconds. Also clears any queued music.
        i    Ni  (   R=   R`   R_   R   RK   RL   t   fadeoutt   int(   R   t   secs(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyRe     s    	
i    c         C   s   x! | D] } t  t i i i | <q Wt p d  Sn | d  j o |  i } n |  i d 7_ x@ | D]8 } t	 | t
 | d  |  } |  i i |  d } qc W| o t |  |  _ n
 g  |  _ | |  _ | |  _ d  S(   Ni   i  i    (   R
   R   RB   t
   persistentt   _seen_audioR_   R   R   R=   R   Rf   R6   RV   t   listR7   R9   R:   (   R   t	   filenamesR7   R:   R   R   R   t   qe(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   enqueue  s$      
		c         C   s   t  p d  Sn t i |  i  S(   N(   R_   R   R   t   playing_nameRL   (   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   get_playing  s    c         C   s   | |  _  d  S(   N(   R4   (   R   t   volume(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt
   set_volume  s    c         C   s   t  p d Sn t i |  i  S(   Ni(   R_   R   t   get_posRL   (   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyRr     s    c         C   s[   t    } | |  i _ | |  i _ t o/ |  i i |  _ t i |  i |  i i |  n d  S(   N(   R   RC   R$   R%   R_   R   Rb   RL   (   R   R%   t   delayt   now(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyRb     s    	c         C   s[   t    } | |  i _ | |  i _ t o/ |  i i |  _ t i |  i |  i i |  n d  S(   N(   R   RC   R&   R'   R_   R   Rc   RL   (   R   Rp   Rs   Rt   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyRc     s    	N(   R   R    R!   R   RA   t   propertyRL   RG   RC   R^   R   R`   Rd   Re   R
   R   Rm   Ro   Rq   Rr   Rb   Rc   (    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR0      s    	L			f							c         C   sV   t  i i p t d   n t |  | | |  } | | _ t i |  | t |  <d  S(   Ns-   Can't register channel outside of init phase.(	   R   RB   t
   init_phaset	   ExceptionR0   R3   t   all_channelsRV   t   channels(   R1   R3   R7   R<   R   t   c(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   register_channel  s    	c         C   s7   t  i i p t d   n t |   } | t | <d  S(   Ns*   Can't alias channel outside of init phase.(   R   RB   Rv   Rw   t   get_channelRy   (   R1   t   newnameRz   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   alias_channel  s    c         C   s4   t  i |   } | d  j o t d |    n | S(   Ns   Audio channel %r is unknown.(   Ry   RE   R   Rw   (   R1   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR|   #  s    c         C   s   | t  |   i _ d  S(   N(   R|   RC   R+   (   R1   t   value(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   set_force_stop+  s    c       	   C   s~  t  i i p t a t a d  Sn t d  j o t o d }  d t i	 j o t
 t i	 d  }  n y, t i t  i i d |  t  i i  t a Wq t  i i o   n t a q Xn g  } x2 t D]* } | i | j o | i | i  q q Wd } t o9 d t i	 j o) t i   d  j	 o t i   } t a n x@ | D]8 } t  i i i i | |  t  i i i i | t  q>Wd  S(   Ni   t   RENPY_SOUND_BUFSIZEi   g      ?t   RENPY_NOMIXER(   R   RT   t   soundR   R_   R   R   R   t   ost   environRf   t   initt   sound_sample_rateRU   R
   Rx   R3   RV   R   R   RB   RI   t   volumest
   setdefaultRJ   (   t   bufsizet   mixersRz   t   default_volumet   m(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR   .  s8    "
 *
 c          C   s   t  p d  Sn x[ t D]S }  |  i   |  i d  g  |  _ g  |  _ t |  _ t |  _ t |  _	 t |  _
 q Wt i   d  a  d  a d  S(   Ni    (   R_   Rx   R`   Re   R6   R7   R   R8   t   playing_midiR9   R:   R   t   quitR   R   (   Rz   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR   X  s     
					
c          C   s[  t  p t Sn y*x t D] }  |  i   q Wt i   t } xL t D]D }  |  i o |  i o t } Pn |  i o |  i o
 t } qD qD W| o( t i   x t D] }  t |  _ q Wn d } t	 i
 i i } t ot } xH t D]@ }  |  i | |  i } t | |  } | d j o
 t } q q W| d j o d Sn | p t   d a n, t   | t j o t i |  | a n x t D]T }  |  i | |  i } | | :} |  i | j o  t i |  i |  | |  _ qqWnV xR t D]J }  |  i | |  i } | |  i j o  t i |  i |  | |  _ qqWWn t	 i i o   qWn Xd S(   s	  
    The periodic sound callback. This is called at around 20hz, and is
    responsible for adjusting the volume of the playing music if
    necessary, and also for calling the periodic functions of midi and
    the various channels, which then may play music.
    g      i    N(   R_   R   Rx   R^   R   R:   R9   R
   t   unpause_allR   RB   RI   R   R   Ry   R4   R3   t   maxR   t
   pcm_volumeR   R   R   R5   Rq   RL   RT   RU   (   Rz   t   need_sst
   max_volumeR   t   anything_playingt   vol(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyR^   t  sn    
 
 
  

 
 c          C   s  t  p d Sn y x t D] }  |  i   |  i } |  i | i j o q n | i } | i } |  i o6 | p |  i   | j o |  i	 t
 i i  q n | o# |  i | d t d t d | n | i |  _ q WWn t
 i i o   q n Xt   d S(   s/   
    Called at least once per interaction.
    NR7   R:   R   (   R_   Rx   Rd   RC   R(   R*   R)   R>   Ro   Re   R   RT   t
   fade_musicRm   R
   RU   R^   (   Rz   t   ctxRk   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyRd     s*     
			
#i   c         C   s   t  p t Sn |  i t j og t i i i p t i i i o t	 i i
   } n t i i i } t i t i i i |   t Sn |  i t j o, t i i i d  o t i   n t Sn t S(   s   
    Handles an event generated by pss (really, the ffdecode
    module). Returns true if we've handled it, or false if we should
    be pushing it to another module for further handling.
    t   movie(   R_   R   t   typet   ALLOC_EVENTR   t   displayt   videot
   fullscreent   surfacet   pygamet   get_surfaceR   t   alloc_eventt   scalet   realR
   t   REFRESH_EVENTt   audioRD   Ro   t   refresh_event(   t   evt   surf(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pyt   event  s    !(3   R   t   timeR   R   t   atexitR   RE   t   disableR   R   R   t
   pysdlsoundt   check_versiont   registerR   t   winmixert   linmixerR   R	   R   R   R   R   R_   R   R   R   R   R   t   objectR   t   pythont   RevertableObjectR"   R@   R0   Rx   Ry   R
   R{   R~   R|   R   R   R   R^   Rd   t	   USEREVENTR   R   R   (    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\audio.pys   <module>   sl   			
		0 V					*		]	*	