@@ -26,7 +26,7 @@ class WSPRProcessor
2626 private const val WSPR_CYCLE_DURATION_SECONDS = 120f // WSPR transmits every 2 minutes
2727
2828 // Buffer Timing Constants
29- private const val MINIMUM_DECODE_SECONDS = 120f // Minimum for decode attempt
29+ private const val REQUIRED_DECODE_SECONDS = 114f // Minimum for decode attempt
3030 private const val RECOMMENDED_BUFFER_SECONDS = 180f // Recommended buffer for reliable decode (3 minutes for overlap)
3131
3232 // Decode Window Strategy Constants
@@ -35,8 +35,7 @@ class WSPRProcessor
3535
3636 // Buffer Size Calculations
3737 private const val MAXIMUM_BUFFER_SAMPLES = (SAMPLE_RATE_HZ * RECOMMENDED_BUFFER_SECONDS ).toInt()
38- private const val MINIMUM_DECODE_SAMPLES = (SAMPLE_RATE_HZ * MINIMUM_DECODE_SECONDS ).toInt()
39- private const val OPTIMAL_DECODE_SAMPLES = MINIMUM_DECODE_SAMPLES // Native decoder limit
38+ private const val REQUIRED_DECODE_SAMPLES = (SAMPLE_RATE_HZ * REQUIRED_DECODE_SECONDS ).toInt() // Native decoder limit
4039 }
4140
4241 val audioBuffer = mutableListOf<Short >()
@@ -69,16 +68,8 @@ class WSPRProcessor
6968 /* *
7069 * Checks if buffer has enough data for a WSPR decode attempt.
7170 */
72- fun isReadyForDecode (): Boolean = audioBuffer.size >= MINIMUM_DECODE_SAMPLES
71+ fun isReadyForDecode (): Boolean = audioBuffer.size >= REQUIRED_DECODE_SAMPLES
7372
74- /* *
75- * Gets the optimal number of samples for WSPR decoding
76- * Uses the minimum decode duration to avoid buffer overflow (CJarInterface.WSPRDecodeFromPcm expects 120 seconds)
77- */
78- fun getOptimalDecodeSamples (): Int
79- {
80- return (SAMPLE_RATE_HZ * MINIMUM_DECODE_SECONDS ).toInt()
81- }
8273
8374 /* *
8475 * Decodes WSPR from buffered audio data using the specified strategy.
@@ -117,7 +108,7 @@ class WSPRProcessor
117108
118109 // Public constants for external use
119110 fun getRecommendedBufferSeconds (): Float = RECOMMENDED_BUFFER_SECONDS
120- fun getMinimumBufferSeconds (): Float = MINIMUM_DECODE_SECONDS
111+ fun getMinimumBufferSeconds (): Float = REQUIRED_DECODE_SECONDS
121112 fun getWSPRTransmissionSeconds (): Float = WSPR_TRANSMISSION_DURATION_SECONDS
122113 fun getBufferOverlapSeconds (): Float = RECOMMENDED_BUFFER_SECONDS - WSPR_TRANSMISSION_DURATION_SECONDS
123114
@@ -139,19 +130,19 @@ class WSPRProcessor
139130 private fun generateSlidingWindows (): List <DecodeWindow >
140131 {
141132 // Single window if buffer fits within decoder limits
142- if (audioBuffer.size <= OPTIMAL_DECODE_SAMPLES )
133+ if (audioBuffer.size <= REQUIRED_DECODE_SAMPLES )
143134 {
144135 return listOf (DecodeWindow (0 , audioBuffer.size, " Full buffer" ))
145136 }
146137
147138 val windows = mutableListOf<DecodeWindow >()
148139 val stepSamples = (SAMPLE_RATE_HZ * SLIDING_WINDOW_STEP_SECONDS ).toInt()
149- val maxWindows = minOf(MAX_DECODE_WINDOWS , (audioBuffer.size - OPTIMAL_DECODE_SAMPLES ) / stepSamples + 1 )
140+ val maxWindows = minOf(MAX_DECODE_WINDOWS , (audioBuffer.size - REQUIRED_DECODE_SAMPLES ) / stepSamples + 1 )
150141
151142 for (windowIndex in 0 until maxWindows)
152143 {
153144 val startIndex = windowIndex * stepSamples
154- val endIndex = startIndex + OPTIMAL_DECODE_SAMPLES
145+ val endIndex = startIndex + REQUIRED_DECODE_SAMPLES
155146
156147 if (endIndex <= audioBuffer.size)
157148 {
@@ -180,7 +171,7 @@ class WSPRProcessor
180171 for (cycle in 0 until maxCycles)
181172 {
182173 val startIndex = cycle * cycleSamples
183- val endIndex = minOf(startIndex + OPTIMAL_DECODE_SAMPLES , audioBuffer.size)
174+ val endIndex = minOf(startIndex + REQUIRED_DECODE_SAMPLES , audioBuffer.size)
184175
185176 // Ensure we have enough data to decode
186177 val windowDurationSeconds = (endIndex - startIndex.toFloat()) / SAMPLE_RATE_HZ
0 commit comments