Skip to content

Commit c1d167e

Browse files
committed
Debug Timing and Decoding
1 parent 41b0d69 commit c1d167e

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,27 +205,41 @@ class WSPRProcessor
205205
{
206206
val allMessages = mutableListOf<WSPRMessage>()
207207

208+
Timber.d("=== Starting decode with ${windows.size} windows ===")
209+
Timber.d("Buffer has ${audioBuffer.size} samples (${getBufferDurationSeconds()}s)")
210+
Timber.d("Required: ${REQUIRED_DECODE_SAMPLES} samples (${REQUIRED_DECODE_SECONDS}s)")
211+
208212
for (window in windows)
209213
{
210214
try
211215
{
212216
val windowSamples = audioBuffer.subList(window.startIndex, window.endIndex).toShortArray()
213217
val audioBytes = convertShortsToBytes(windowSamples)
214218

219+
Timber.d("Calling native decoder:")
220+
Timber.d(" Window: ${window.description}")
221+
Timber.d(" Samples: ${windowSamples.size} (${windowSamples.size / WSPR_REQUIRED_SAMPLE_RATE}s)")
222+
Timber.d(" Bytes: ${audioBytes.size}")
223+
Timber.d(" Frequency: ${dialFrequencyMHz} MHz")
224+
Timber.d(" LSB: $useLowerSideband")
225+
215226
val messages = CJarInterface.WSPRDecodeFromPcm(audioBytes, dialFrequencyMHz, useLowerSideband)
216227

228+
Timber.d("Native decoder returned: ${messages?.size ?: "null"} messages")
229+
217230
messages?.let {
218231
allMessages.addAll(it.toList())
219-
Timber.d("Decoded ${it.size} messages from ${window.description}")
232+
Timber.d("Decoded ${it.size} messages from ${window.description}")
220233
}
221234
}
222235
catch (exception: Exception)
223236
{
224-
// Log decode failure but continue with other windows
225-
Timber.w(exception, "Failed to decode ${window.description}")
237+
Timber.e(exception, "Failed to decode ${window.description}")
226238
}
227239
}
228240

241+
Timber.d("=== Decode complete: ${allMessages.size} total messages ===")
242+
229243
return if (allMessages.isNotEmpty())
230244
{
231245
removeDuplicateMessages(allMessages).toTypedArray()

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,17 @@ class WSPRStation(
302302
// Phase 2: Collect audio for the required duration
303303
_stationState.value = WSPRStationState.CollectingAudio
304304
val audioCollectionStartTime = System.currentTimeMillis()
305+
var totalSamplesCollected = 0
305306

306307
while (System.currentTimeMillis() - audioCollectionStartTime < AUDIO_COLLECTION_DURATION_MILLISECONDS)
307308
{
308309
val audioChunk = audioSource.readAudioChunk(AUDIO_CHUNK_DURATION_MILLISECONDS)
309310
signalProcessor.addSamples(audioChunk)
310-
311-
// Brief pause to prevent excessive CPU usage
312-
delay(AUDIO_COLLECTION_PAUSE_MILLISECONDS)
311+
totalSamplesCollected += audioChunk.size
313312
}
314313

314+
Timber.d("Audio collection complete: ${totalSamplesCollected} samples in ${System.currentTimeMillis() - audioCollectionStartTime}ms")
315+
315316
// Phase 3: Process collected audio through WSPR decoder
316317
_stationState.value = WSPRStationState.ProcessingAudio
317318

0 commit comments

Comments
 (0)