Skip to content

Commit e86b9cd

Browse files
committed
Time aligned window to 114 seconds min from 120
1 parent 36e4c73 commit e86b9cd

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPRProcessor.kt

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,27 +176,26 @@ class WSPRProcessor
176176
*/
177177
private fun generateTimeAlignedWindows(): List<DecodeWindow>
178178
{
179+
// Check if we have enough audio for at least one decode
180+
if (audioBuffer.size < REQUIRED_DECODE_SAMPLES)
181+
{
182+
Timber.w("Insufficient audio for time-aligned decode: ${audioBuffer.size} samples < ${REQUIRED_DECODE_SAMPLES} required")
183+
return emptyList()
184+
}
185+
179186
val windows = mutableListOf<DecodeWindow>()
180-
val cycleSamples = (WSPR_REQUIRED_SAMPLE_RATE * WSPR_CYCLE_DURATION_SECONDS).toInt()
181-
val availableCycles = audioBuffer.size / cycleSamples
182-
val maxCycles = minOf(availableCycles, MAX_DECODE_WINDOWS)
183187

184-
for (cycle in 0 until maxCycles)
185-
{
186-
val startIndex = cycle * cycleSamples
187-
val endIndex = minOf(startIndex + REQUIRED_DECODE_SAMPLES, audioBuffer.size)
188+
// Create a single window from the start of the buffer
189+
// This is already time-aligned because collection starts at even_minute + 2s
190+
val endIndex = minOf(REQUIRED_DECODE_SAMPLES, audioBuffer.size)
188191

189-
// Ensure we have enough data to decode
190-
val windowDurationSeconds = (endIndex - startIndex.toFloat()) / WSPR_REQUIRED_SAMPLE_RATE
191-
if (windowDurationSeconds >= WSPR_TRANSMISSION_DURATION_SECONDS)
192-
{
193-
windows.add(DecodeWindow(
194-
startIndex,
195-
endIndex,
196-
description = "Time-aligned cycle ${cycle + 1} (${startIndex / WSPR_REQUIRED_SAMPLE_RATE}s-${endIndex / WSPR_REQUIRED_SAMPLE_RATE}s)"
197-
))
198-
}
199-
}
192+
windows.add(DecodeWindow(
193+
startIndex = 0,
194+
endIndex = endIndex,
195+
description = "Time-aligned window (0s-${endIndex / WSPR_REQUIRED_SAMPLE_RATE}s)"
196+
))
197+
198+
Timber.d("Generated time-aligned window: 0-${endIndex} samples (${endIndex / WSPR_REQUIRED_SAMPLE_RATE}s)")
200199

201200
return windows
202201
}

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/models/WSPRStationConfiguration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ data class WSPRStationConfiguration(
3434
return WSPRStationConfiguration(
3535
operatingFrequencyMHz = WSPRBandplan.getDefaultFrequency(),
3636
useLowerSidebandMode = false,
37-
useTimeAlignedDecoding = false,
37+
useTimeAlignedDecoding = true,
3838
stationCallsign = null,
3939
stationGridSquare = null
4040
)

0 commit comments

Comments
 (0)