U
    a¨+d‹  ã                   @   sJ   d dl Z d dlZd dlZd dlmZ e ¡  ej 	d¡ ed	dd„ƒZ
dS )
é    N)Úrequires_durationZMoviePyé"V  é   é   c                 C   sD  t j ¡  t j |d| | jd¡ t|| j ƒ}t t	t
d||ƒƒ|g ¡}d| t |d |d ¡ }| j||dd}	t j |	¡}
|dk	r¤|dk	r¤| ¡  | ¡  |
 ¡ }t
dt|ƒd ƒD ]€}d| t || ||d  ¡ }| j||dd}	t j |	¡}
| ¡ r4t d	¡ |dk	rþ| ¡ sþ| ¡  ~ dS qþ| |
¡ q¾dS )
a}  
    Plays the sound clip with pygame.
    
    Parameters
    -----------
    
    fps
       Frame rate of the sound. 44100 gives top quality, but may cause
       problems if your computer is not fast enough and your clip is
       complicated. If the sound jumps during the preview, lower it
       (11025 is still fine, 5000 is tolerable).
        
    buffersize
      The sound is not generated all at once, but rather made by bunches
      of frames (chunks). ``buffersize`` is the size of such a chunk.
      Try varying it if you meet audio problems (but you shouldn't
      have to).
    
    nbytes:
      Number of bytes to encode the sound: 1 for 8bit sound, 2 for
      16bit, 4 for 32bit sound. 2 bytes is fine.
    
    audioFlag, videoFlag:
      Instances of class threading events that are used to synchronize
      video and audio during ``VideoClip.preview()``.
    
    iøÿÿÿi   r   g      ð?é   T)ÚnbytesÚquantizeNgú~j¼t“h?)ÚpgZmixerÚquitÚinitZ	nchannelsÚintÚdurationÚnpÚarrayÚlistÚrangeZarangeZto_soundarrayÚsndarrayZ
make_soundÚsetÚwaitZplayÚlenZ	get_queueÚtimeÚsleepÚis_setÚstopÚqueue)ZclipZfpsZ
buffersizer   Z	audioFlagZ	videoFlagZ	totalsizeZposposÚttr   ÚchunkZchannelÚi© r   ú</tmp/pip-unpacked-wheel-0yp4gafk/moviepy/audio/io/preview.pyÚpreview   s.    
 

r    )r   r   r   NN)r   Znumpyr   Zpygamer	   Zmoviepy.decoratorsr   r   ZdisplayZset_captionr    r   r   r   r   Ú<module>   s     ÿ