Changed methode of mean power calculation. #10
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I changed the method to calculate mean power in the converter. We already have the average mean level so we can calculate average power from it. This corrects also the mean power value because what is calculated by the old method is slightly off, probably due to loose in precision when casting.
Example from live IQ data:
sum_level = 91873866
out_mean_level = 0.010695526
Level to dB is: 20log(out_mean_level) = 20log(0.010695526) = -39.416 dB
Old method (summing up mag^2):
sum_power = 85686914156
out_mean_power = 0.00015221812
Power to dB is: 10log(out_mean_power) = 10log(0.00015221812) = -38.175 dB
Converting this power back to level results in 0.0123377 so it's not equal to square level (or magnitude).
New method:
output_mean_power = out_mean_level^2 = 0.000114394
Power to dB is: 10log(out_mean_power) = 10log(0.000114394) = -39.416 dB
Second benefit of this change is a performance gain. I saw +0.15-0.3 Msamples/s in the benchmarks, except for the UC8 NODC that showed up to +2.8Msamples/s, on my Pi2 setup.