³ò
~×YKc           @   s  d  d k  Z  g  Z g  Z d  d k l Z l Z d  d k l Z l Z e e d d d e	 d d e	 d „ Z
 d d e d d d „ Z d d d „ Z e	 d	 „ Z d d
 „ Z d d „ Z d d „ Z d d d „ Z d d „ Z d d „ Z e	 d „ Z d „  Z d S(   iÿÿÿÿN(   t   get_channelt
   get_serial(   t   register_channelt   alias_channelt   musici    c         C   ss  t  i i o t d ƒ ‚ n |  d j o g  }  t } n t |  t ƒ o |  g }  n yú t | ƒ } | i	 }	 | d j o | i
 } n | i ƒ  | d j o t  i i } n | o | i ƒ  |  j o
 d } n | i | ƒ | i |  d | d | d | d | ƒt ƒ  }
 |
 |	 _ |
 | _ | o |  |	 _ | |	 _ n g  |	 _ t |	 _ Wn t  i i o ‚  qon Xd S(   sy  
    This stops the music currently playing on the numbered channel, dequeues
    any queued music, and begins playing the specified file or files. If loop
    is True, the tracks will loop while they are the last thing in
    the queue. If fadeout is None, the fadeout time is taken from
    config.fade_music, otherwise it is a time in seconds to fade for.

    Filenames may be a single file, or a list of files.

    Fadein is the number of seconds to fade the music in for, on the
    first loop only.

    If synchro_start is given, all the channels that have had play
    called on them with synchro_start set to True will be started at
    the same time, in a sample accurate manner.

    The filenames given becomes the last queued files if loop is
    True. If loop is False, then there are no last queued files.

    If tight is True, then fadeouts will span into the next-queued sound.
    
    If if_changed is True, and the music file is currently playing,
    then it will not be stopped/faded out and faded back in again, but
    instead will be kept playing. (This will always queue up an additional
    loop of the music.)
    s#   Can't play music during init phase.i    t   loopt   synchro_startt   fadeint   tightN(   t   renpyt   gamet
   init_phaset	   Exceptiont   Nonet   Falset
   isinstancet
   basestringR    t   contextt   default_loopt   dequeuet   configt
   fade_musict   get_playingt   fadeoutt   enqueueR   t   last_changedt   last_filenamest
   last_tightt   debug_sound(   t	   filenamest   channelR   R   R   R   R   t
   if_changedt   ct   ctxt   t(    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt   play&   s<    
	

%					c   	      C   s-  t  i i o t d ƒ ‚ n |  d j o g  }  t } n t |  t ƒ o |  g }  n y´ t | ƒ } | i	 } | d j o | i
 } n | o | i t ƒ n | i |  d | d | d | ƒt ƒ  } | | _ | | _ | o |  | _ | | _ n g  | _ t | _ Wn t  i i o ‚  q)n Xd S(   sP  
    This queues the given filenames on the specified channel. If
    clear_queue is True, then the queue is cleared, making these files
    the files that are played when the currently playing file
    finishes. If it is False, then these files are placed at the back of
    the queue. In either case, if no music is playing these files
    begin playing immediately.

    Filenames may either be a single filename, or a list of filenames.

    Fadein is the number of seconds to fade the music in for, on the
    first loop only.

    If loop is True, then this music will repeat as long as it is the
    last element of the queue.

    The filenames given becomes the last queued file if loop is
    True. If loop is False, then the last queued file is set to None.

    If tight is True, then fadeouts will span into the next-queued sound.
    s#   Can't play music during init phase.R   R   R   N(   R	   R
   R   R   R   R   R   R   R    R   R   R   t   TrueR   R   R   R   R   R   R   (	   R   R   R   t   clear_queueR   R   R    R!   R"   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt   queueo   s4    
						c         C   s¯   t  i i o t d ƒ ‚ n yp t |  ƒ } | i } | d j o t  i i } n | i	 | ƒ t
 ƒ  } | | _ | | _ g  | _ t | _ Wn t  i i o ‚  q« n Xd S(   s  
    This stops the music that is currently playing, and dequeues all
    queued music. If fadeout is None, the music is faded out for the
    time given in config.fade_music, otherwise it is faded for fadeout
    seconds.
    
    This sets the last queued file to None.
    s#   Can't play music during init phase.N(   R	   R
   R   R   R    R   R   R   R   R   R   R   R   R   R   R   (   R   R   R    R!   R"   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt   stop¬   s     
					c         C   s;   t  |  ƒ } | o | i o d Sn | | _ t | _ d S(   s5   
    Determines if channel will loop by default.
    N(   R    t   default_loop_setR   R$   (   R   t   flagt   defaultR    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt	   set_musicÍ   s
    	c         C   s…   y_ t  i i i | ƒ } | i ƒ  } | p | d j  o d Sn | |  j o d Sn |  | SWn t  i i o ‚  n d Sn Xd S(   sS   
    Returns the number of seconds left until the given time in the
    music.
    i    N(   R	   t   audioR    t   get_posR   R   R   (   t   timeR   R    R"   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt	   get_delayÚ   s    c         C   sI   y# t  i i i |  ƒ } | i ƒ  SWn t  i i o ‚  n d Sn Xd S(   s7   
    Returns true if the given channel is playing.
    N(   R	   R,   R    R   R   R   R   (   R   R    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyR   ò   s    c         C   s   t  d |  ƒ d j	 S(   s   
    Returns True if the channel is currently playing a sound, False if
    it is not, or if the sound system isn't working.
    R   N(   R   R   (   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt
   is_playing   s    c         C   sK   y) t  i i i | ƒ } | i |  | ƒ Wn t  i i o ‚  qG n Xd S(   sp   
    Sets the volume of this channel, as a fraction of the volume of the
    mixer controlling the channel.
    N(   R	   R,   R    t   set_secondary_volumeR   R   (   t   volumet   delayR   R    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt
   set_volume	  s    c         C   sK   y) t  i i i | ƒ } | i |  | ƒ Wn t  i i o ‚  qG n Xd S(   s'   
    Sets the pan of this channel.
    N(   R	   R,   R    t   set_panR   R   (   t   panR3   R   R    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyR5     s    c         C   sD   y" t  i i i | ƒ } |  | _ Wn t  i i o ‚  q@ n Xd S(   s»  
    This sets a callback that is called when the queue is empty. This
    callback is called when the queue first becomes empty, and at
    least once per interaction while the queue is empty.

    The callback is called with no parameters. It can queue sounds by
    calling renpy.music.queue with the appropriate arguments. Please
    note that the callback may be called while a sound is playing, as
    long as a queue slot is empty.
    N(   R	   R,   R    t   callbackR   R   (   R7   R   R    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt   set_queue_empty_callback"  s    c         C   s`   y> t  i i i |  ƒ } | p | i d j o | | _ n Wn t  i i o ‚  q\ n Xd S(   s¬  
    This sets the name of the mixer associated with a given
    channel. By default, there are two mixers, 'sfx' and
    'music'. 'sfx' is on channels 0 to 3, and 'music'
    on 3 to 7. The voice module calls this function to set channel 2 to voice.
    You can create your own mixer, but will need to add a preference if you
    wish to allow the user to set it.

    This function should only be called in an init block.
    N(   R	   R,   R    t   mixerR   R   R   (   R   R9   R*   R    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt	   set_mixer4  s    c         C   s-   y t  i i i |  ƒ t SWn t Sn Xd S(   sA   
    Returns True if the channel exists, or False otherwise.
    N(   R	   R,   R    R$   R   (   R   (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pyt   channel_definedJ  s
    (   R	   t   music_channelst	   music_sett   renpy.audio.audioR    R   R   R   R   R   R#   R$   R&   R'   R+   R/   R   R0   R4   R5   R8   R:   R;   (    (    (    s9   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\audio\music.pys   <module>   s"   I=!	