import math


def signal_relative_power(frequencies, scale):
    """Calculates the relative power in dB for the signal, centered around [-1, 1]
    Source: https://stackoverflow.com/questions/2445756/how-can-i-calculate-audio-db-level
    Parameters
    :param frequencies: list[float]
        List containing the frequency energies to be used in the calculation
    :param scale: list[int]
        List containing the high and low range for the signal, i.e. signed 8-bit scale is 128
    :return: list[float]
        List containing the relative powers of the frequencies passed in the same order
    """
    relative_power = []
    for frequency in frequencies:
        norm_freq = frequency / scale
        relative_power.append(20 * math.log10(max(norm_freq) + 1e-7))
    return relative_power