Skip to content

Commit

Permalink
Update THD calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
billthefarmer committed Nov 23, 2023
1 parent 0a89eaa commit ad5c53b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/billthefarmer/scope/SpectrumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ protected void processAudio()
sumf += xa[i] * xa[i];

// Sum the harmonics
else if (Math.IEEEremainder(xf[i], frequency) <
else if (Math.abs(Math.IEEEremainder(xf[i], frequency)) <
Math.round(xf[i] / frequency) * fps)
sumh += xa[i] * xa[i];

Expand All @@ -726,10 +726,11 @@ else if (Math.IEEEremainder(xf[i], frequency) <
if (max > MIN)
{
final String s = String.format(Locale.getDefault(),
"%1.0f%% %1.1fHz %1.1fdB",
"%1.0f%% %1.1fHz %1.1fdB",
thd, frequency, dB);
text.post(() -> text.setText(s));
}

else
{
frequency = 0.0;
Expand Down

0 comments on commit ad5c53b

Please sign in to comment.