o
    i’×iv  ã                   @   s$   d dl Z d dlZdd„ Zdd„ ZdS )é    Nc                 C   sN   t  t  | ¡¡}t  d|d ¡| }||  }t  t  |¡¡dkr%t d¡ |S )aE   Peak normalize a signal.
    
    Normalize an input signal to a user specifed peak amplitude.   

    Params
    -------
    data : ndarray
        Input multichannel audio data.
    target : float
        Desired peak amplitude in dB.

    Returns
    -------
    output : ndarray
        Peak normalized output data.
    ç      $@ç      4@ç      ð?ú#Possible clipped samples in output.)ÚnpÚmaxÚabsÚpowerÚwarningsÚwarn)ÚdataÚtargetÚcurrent_peakÚgainÚoutput© r   úR/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/pyloudnorm/normalize.pyÚpeak   s   
r   c                 C   sB   || }t  d|d ¡}||  }t  t  |¡¡dkrt d¡ |S )a¬   Loudness normalize a signal.
    
    Normalize an input signal to a user loudness in dB LKFS.   

    Params
    -------
    data : ndarray
        Input multichannel audio data.
    input_loudness : float
        Loudness of the input in dB LUFS. 
    target_loudness : float
        Target loudness of the output in dB LUFS.
        
    Returns
    -------
    output : ndarray
        Loudness normalized output data.
    r   r   r   r   )r   r	   r   r   r
   r   )r   Úinput_loudnessÚtarget_loudnessÚdelta_loudnessr   r   r   r   r   Úloudness#   s   
r   )r
   Únumpyr   r   r   r   r   r   r   Ú<module>   s    