u""" 
    Converts voltage difference into decibels : 20*log10(peak/refval)
    
    :param peak: amplitude
    :type peak: float or np.array
    :param refval: This can be either a another sound peak(or RMS val), to get the dB difference, or the microphone mphone_sensitivity
    :type refval: float
    :param mphonecaldb: If using the microphone sensitivity for refval, provide the dB SPL the microphone was calibrated at. Otherwise, leave as 0
    :type mphonecaldb: int
    :returns: float -- decibels difference (comparision), or dB SPL (using microphone sensitivity)

def calc_db(peak, refval, mphonecaldb=0):
    u""" 
    Converts voltage difference into decibels : 20*log10(peak/refval)
    
    :param peak: amplitude
    :type peak: float or np.array
    :param refval: This can be either a another sound peak(or RMS val), to get the dB difference, or the microphone mphone_sensitivity
    :type refval: float
    :param mphonecaldb: If using the microphone sensitivity for refval, provide the dB SPL the microphone was calibrated at. Otherwise, leave as 0
    :type mphonecaldb: int
    :returns: float -- decibels difference (comparision), or dB SPL (using microphone sensitivity)
    """
    if refval == 0:
        return np.nan
    if hasattr(peak, '__iter__'):
        peak[peak == 0] = np.nan
    pbdB = mphonecaldb + (20. * np.log10(peak / refval))
    return pbdB