fix(cw): draw the original-tone marker at the correct waterfall position

estimatedPitch is already corrected back to the original tone frequency
(the spectrogram computes from shifted audio, and updateSignalMetrics undoes
the shift), so adding toneShiftHz to it again placed the orange marker at the
shifted position - right on top of the green target line, making them
indistinguishable.

The orange marker now goes directly on estimatedPitch. When the original pitch
is outside the visible 400-1200 Hz band, an arrow at the nearest edge points
toward it instead.
This commit is contained in:
mckero committed 2026-08-22 15:36:17 +00:00
1 parent fa73328936
commit 8fbc639a82
1 file changed
+16 -1
@@ -202,7 +202,10 @@ internal fun CwWaterfallView(
}
// Original pitch marker.
val origPitch = estimatedPitch + toneShiftHz // undo the correction
// estimatedPitch is already corrected back to the original tone
// (the spectrogram sees the shifted audio, updateSignalMetrics undoes
// the shift), so we use it directly rather than adding toneShiftHz again.
val origPitch = estimatedPitch
if (origPitch in minHz..maxHz) {
// Inside the visible band: orange dashed line at the original position.
val origX = hzToX(origPitch).coerceIn(0f, size.width)
@@ -214,6 +217,18 @@ internal fun CwWaterfallView(
strokeWidth = 1.5f
)
}
} else {
// Outside the visible band: draw an arrow at the nearest edge.
val edgeX = if (origPitch < minHz) 0f else size.width
val arrowDir = if (origPitch < minHz) -1f else 1f
for (i in 0..2) {
drawLine(
color = Color(0xFFFF9500).copy(alpha = 0.6f),
start = Offset(edgeX + arrowDir * i * 4f, 4f + i * 4f),
end = Offset(edgeX + arrowDir * (i + 1) * 4f, 4f + (i + 1) * 4f),
strokeWidth = 2f
)
}
}
// Draw the original frequency label at the top edge.
val labelX = hzToX(origPitch).coerceIn(labelSize, size.width - labelSize * 4)