def get_channel(self, previous_value, new_value):
""" Prepares signal value depending on the previous one and algorithm. """
if self.stereo_algorithm == STEREO_ALGORITHM_NEW:
channel_value = new_value
elif self.stereo_algorithm == STEREO_ALGORITHM_LOGARITHM:
if previous_value == 0.0:
channel_value = 0.0
else:
channel_value = 20 * math.log10(new_value/previous_value)
if channel_value < -20:
channel_value = -20
if channel_value > 3:
channel_value = 3
channel_value = (channel_value + 20) * (100/23)
elif self.stereo_algorithm == STEREO_ALGORITHM_AVERAGE:
channel_value = statistics.mean([previous_value, new_value])
return channel_value
评论列表
文章目录