From 8fbc639a82154efc75a30a64712580236ee3a374 Mon Sep 17 00:00:00 2001 From: QIU Date: Sat, 22 Aug 2026 15:36:17 +0000 Subject: [PATCH] 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. --- .../rtbishop/look4sat/feature/cw/CwWaterfall.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/feature/cw/src/main/java/com/rtbishop/look4sat/feature/cw/CwWaterfall.kt b/feature/cw/src/main/java/com/rtbishop/look4sat/feature/cw/CwWaterfall.kt index 5252c7cf..6656e5c4 100644 --- a/feature/cw/src/main/java/com/rtbishop/look4sat/feature/cw/CwWaterfall.kt +++ b/feature/cw/src/main/java/com/rtbishop/look4sat/feature/cw/CwWaterfall.kt @@ -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)