Skip to content

Commit 0c16edc

Browse files
committed
Additional modes prep: moved files to wspr/ and common/
Pr
1 parent d7030b1 commit 0c16edc

25 files changed

Lines changed: 117 additions & 128 deletions

AudioCoder/src/androidTest/java/org/operatorfoundation/audiocoder/WSPREncoderTest.kt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import org.junit.runner.RunWith
66
import org.junit.Assert.assertArrayEquals
77
import org.junit.Assert.assertEquals
88
import org.junit.Assert.assertTrue
9+
import org.operatorfoundation.audiocoder.wspr.CJarInterface
10+
import org.operatorfoundation.audiocoder.wspr.WSPREncoder
911
import kotlin.test.DefaultAsserter.assertNotNull
1012

1113
@RunWith(AndroidJUnit4::class)
@@ -37,7 +39,7 @@ class WSPREncoderTest
3739

3840
// Kotlin implementation
3941
val kotlinResult = WSPREncoder.encodeToFrequencies(
40-
WSPREncoder.WSPRMessage(callsign, locator, power, offset, lsb)
42+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, offset, lsb)
4143
)
4244

4345
// JNI implementation
@@ -60,7 +62,7 @@ class WSPREncoderTest
6062
val lsb = false
6163

6264
val kotlinResult = WSPREncoder.encodeToFrequencies(
63-
WSPREncoder.WSPRMessage(callsign, locator, power, offset, lsb)
65+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, offset, lsb)
6466
)
6567

6668
val jniResult = CJarInterface.WSPREncodeToFrequencies(
@@ -79,7 +81,7 @@ class WSPREncoderTest
7981
val lsb = true
8082

8183
val kotlinResult = WSPREncoder.encodeToFrequencies(
82-
WSPREncoder.WSPRMessage(callsign, locator, power, offset, lsb)
84+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, offset, lsb)
8385
)
8486

8587
val jniResult = CJarInterface.WSPREncodeToFrequencies(
@@ -106,7 +108,7 @@ class WSPREncoderTest
106108

107109
for (callsign in testCases) {
108110
val kotlinResult = WSPREncoder.encodeToFrequencies(
109-
WSPREncoder.WSPRMessage(callsign, locator, power)
111+
WSPREncoder.WSPREncodeRequest(callsign, locator, power)
110112
)
111113

112114
val jniResult = CJarInterface.WSPREncodeToFrequencies(
@@ -138,7 +140,7 @@ class WSPREncoderTest
138140

139141
for (locator in testCases) {
140142
val kotlinResult = WSPREncoder.encodeToFrequencies(
141-
WSPREncoder.WSPRMessage(callsign, locator, power)
143+
WSPREncoder.WSPREncodeRequest(callsign, locator, power)
142144
)
143145

144146
val jniResult = CJarInterface.WSPREncodeToFrequencies(
@@ -161,7 +163,7 @@ class WSPREncoderTest
161163

162164
for (power in testPowers) {
163165
val kotlinResult = WSPREncoder.encodeToFrequencies(
164-
WSPREncoder.WSPRMessage(callsign, locator, power)
166+
WSPREncoder.WSPREncodeRequest(callsign, locator, power)
165167
)
166168

167169
val jniResult = CJarInterface.WSPREncodeToFrequencies(
@@ -184,7 +186,7 @@ class WSPREncoderTest
184186

185187
for (inputPower in testCases) {
186188
val kotlinResult = WSPREncoder.encodeToFrequencies(
187-
WSPREncoder.WSPRMessage(callsign, locator, inputPower)
189+
WSPREncoder.WSPREncodeRequest(callsign, locator, inputPower)
188190
)
189191

190192
val jniResult = CJarInterface.WSPREncodeToFrequencies(
@@ -201,7 +203,7 @@ class WSPREncoderTest
201203

202204
@Test
203205
fun testFrequencyRangeCorrectness() {
204-
val message = WSPREncoder.WSPRMessage(
206+
val message = WSPREncoder.WSPREncodeRequest(
205207
callsign = "W1ABC",
206208
locator = "FN20",
207209
powerDbm = 30,
@@ -226,11 +228,11 @@ class WSPREncoderTest
226228
val power = 30
227229

228230
val usbResult = WSPREncoder.encodeToFrequencies(
229-
WSPREncoder.WSPRMessage(callsign, locator, power, 0, false)
231+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, 0, false)
230232
)
231233

232234
val lsbResult = WSPREncoder.encodeToFrequencies(
233-
WSPREncoder.WSPRMessage(callsign, locator, power, 0, true)
235+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, 0, true)
234236
)
235237

236238
var differencesFound = 0
@@ -251,11 +253,11 @@ class WSPREncoderTest
251253
val offset = 1000
252254

253255
val noOffsetResult = WSPREncoder.encodeToFrequencies(
254-
WSPREncoder.WSPRMessage(callsign, locator, power, 0, false)
256+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, 0, false)
255257
)
256258

257259
val offsetResult = WSPREncoder.encodeToFrequencies(
258-
WSPREncoder.WSPRMessage(callsign, locator, power, offset, false)
260+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, offset, false)
259261
)
260262

261263
for (i in noOffsetResult.indices) {
@@ -281,7 +283,7 @@ class WSPREncoderTest
281283
for (offset in offsets) {
282284
for (lsb in lsbModes) {
283285
val kotlinResult = WSPREncoder.encodeToFrequencies(
284-
WSPREncoder.WSPRMessage(callsign, locator, power, offset, lsb)
286+
WSPREncoder.WSPREncodeRequest(callsign, locator, power, offset, lsb)
285287
)
286288

287289
val jniResult = CJarInterface.WSPREncodeToFrequencies(

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/AudioResampler.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/common/AudioResampler.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.operatorfoundation.audiocoder
1+
package org.operatorfoundation.audiocoder.common
22

33
import timber.log.Timber
44
import kotlin.math.roundToInt
@@ -41,7 +41,7 @@ class AudioResampler(
4141
require(inputSampleRate > 0) { "Input sample rate must be positive: $inputSampleRate" }
4242
require(outputSampleRate > 0) { "Output sample rate must be positive: $outputSampleRate" }
4343

44-
Timber.d("AudioResampler initialized: ${inputSampleRate}Hz -> ${outputSampleRate}Hz (ratio: %.3f)".format(resampleRatio))
44+
Timber.Forest.d("AudioResampler initialized: ${inputSampleRate}Hz -> ${outputSampleRate}Hz (ratio: %.3f)".format(resampleRatio))
4545
}
4646

4747
/**
@@ -53,7 +53,7 @@ class AudioResampler(
5353
fun resample(inputSamples: ShortArray): ShortArray
5454
{
5555
if (inputSamples.isEmpty()) {
56-
Timber.v("Empty input samples, returning empty array")
56+
Timber.Forest.v("Empty input samples, returning empty array")
5757
return shortArrayOf()
5858
}
5959

@@ -122,7 +122,7 @@ class AudioResampler(
122122
lastSample = 0
123123
totalInputSamples = 0L
124124
totalOutputSamples = 0L
125-
Timber.v("AudioResampler state reset")
125+
Timber.Forest.v("AudioResampler state reset")
126126
}
127127

128128
/**

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/extensions/FormatExtensions.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/common/FormatExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.operatorfoundation.audiocoder.extensions
1+
package org.operatorfoundation.audiocoder.common
22

33
// ========== Extension Functions for Formatting ==========
44

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/CJarInterface.java renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/CJarInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.operatorfoundation.audiocoder;
1+
package org.operatorfoundation.audiocoder.wspr;
22

33
public class CJarInterface {
44
static {

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPRAudioSource.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/WSPRAudioSource.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
package org.operatorfoundation.audiocoder
1+
package org.operatorfoundation.audiocoder.wspr
22

3-
import org.operatorfoundation.audiocoder.models.WSPRAudioSourceStatus
4-
import org.operatorfoundation.audiocoder.WSPRConstants.WSPR_REQUIRED_BIT_DEPTH
5-
import org.operatorfoundation.audiocoder.WSPRConstants.WSPR_REQUIRED_CHANNELS
6-
import org.operatorfoundation.audiocoder.WSPRConstants.WSPR_REQUIRED_SAMPLE_RATE
3+
import org.operatorfoundation.audiocoder.wspr.models.WSPRAudioSourceStatus
74

85
/**
96
* Interface for providing audio data to WSPR station.
@@ -170,9 +167,9 @@ class WSPRAudioSourceException(
170167
{
171168
return WSPRAudioSourceException(
172169
"Audio source format incompatible with WSPR requirements. " +
173-
"Required: ${WSPR_REQUIRED_SAMPLE_RATE}Hz, " +
174-
"${WSPR_REQUIRED_CHANNELS} channel, " +
175-
"${WSPR_REQUIRED_BIT_DEPTH}-bit. " +
170+
"Required: ${WSPRConstants.WSPR_REQUIRED_SAMPLE_RATE}Hz, " +
171+
"${WSPRConstants.WSPR_REQUIRED_CHANNELS} channel, " +
172+
"${WSPRConstants.WSPR_REQUIRED_BIT_DEPTH}-bit. " +
176173
"Actual: ${actualSampleRate}Hz, ${actualChannels} channels, ${actualBitDepth}-bit."
177174
)
178175
}

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPRBandPlan.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/WSPRBandPlan.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package org.operatorfoundation.audiocoder
1+
package org.operatorfoundation.audiocoder.wspr
2+
3+
import kotlin.math.abs
24

35
/**
46
* WSPR Band Plan containing official WSPR frequencies for amateur radio bands.
@@ -99,7 +101,7 @@ object WSPRBandplan
99101
{
100102
val toleranceMHz = toleranceKHz / 1000.0
101103
return ALL_BANDS.find {
102-
kotlin.math.abs(it.dialFrequencyMHz - frequencyMHz) <= toleranceMHz
104+
abs(it.dialFrequencyMHz - frequencyMHz) <= toleranceMHz
103105
}
104106
}
105107

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPRConstants.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/WSPRConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.operatorfoundation.audiocoder
1+
package org.operatorfoundation.audiocoder.wspr
22

33
object WSPRConstants
44
{

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPREncoder.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/WSPREncoder.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.operatorfoundation.audiocoder
1+
package org.operatorfoundation.audiocoder.wspr
22

33
import android.util.Log
44

@@ -10,8 +10,8 @@ import android.util.Log
1010
*
1111
* Based on BD1ES's wspr_enc.c implementation.
1212
*/
13-
object WSPREncoder {
14-
13+
object WSPREncoder
14+
{
1515
private const val TAG = "WSPREncoder"
1616
private const val SYMBOL_COUNT = 162
1717
private const val BASE_FREQUENCY_HZ = 1500.0
@@ -20,7 +20,7 @@ object WSPREncoder {
2020
/**
2121
* WSPR message containing all transmission parameters.
2222
*/
23-
data class WSPRMessage(
23+
data class WSPREncodeRequest(
2424
val callsign: String, // e.g., "W1ABC"
2525
val locator: String, // 4-character grid square, e.g., "FN20"
2626
val powerDbm: Int, // Transmit power in dBm
@@ -34,7 +34,7 @@ object WSPREncoder {
3434
* @param message WSPR message parameters
3535
* @return Array of 162 frequencies in centihertz
3636
*/
37-
fun encodeToFrequencies(message: WSPRMessage): LongArray {
37+
fun encodeToFrequencies(message: WSPREncodeRequest): LongArray {
3838
Log.i(TAG, "Encoding WSPR: ${message.callsign} ${message.locator} ${message.powerDbm}dBm")
3939

4040
require(message.locator.length == 4) {

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPRFileManager.kt renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/WSPRFileManager.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
package org.operatorfoundation.audiocoder
1+
package org.operatorfoundation.audiocoder.wspr
22

33
import android.content.Context
44
import android.content.Intent
55
import android.icu.text.SimpleDateFormat
66
import androidx.core.content.FileProvider
7-
import org.operatorfoundation.audiocoder.WSPRConstants.WSPR_REQUIRED_SAMPLE_RATE
87
import timber.log.Timber
98
import java.io.File
109
import java.io.FileOutputStream
@@ -84,8 +83,8 @@ class WSPRFileManager(private val context: Context)
8483
putInt(16) // PCM format chunk size
8584
putShort(1) // PCM format
8685
putShort(CHANNELS.toShort())
87-
putInt(WSPR_REQUIRED_SAMPLE_RATE)
88-
putInt(WSPR_REQUIRED_SAMPLE_RATE * CHANNELS * BITS_PER_SAMPLE / 8) // Byte rate
86+
putInt(WSPRConstants.WSPR_REQUIRED_SAMPLE_RATE)
87+
putInt(WSPRConstants.WSPR_REQUIRED_SAMPLE_RATE * CHANNELS * BITS_PER_SAMPLE / 8) // Byte rate
8988
putShort((CHANNELS * BITS_PER_SAMPLE / 8).toShort()) // Block align
9089
putShort(BITS_PER_SAMPLE.toShort())
9190

AudioCoder/src/main/java/org/operatorfoundation/audiocoder/WSPRMessage.java renamed to AudioCoder/src/main/java/org/operatorfoundation/audiocoder/wspr/WSPRMessage.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
package org.operatorfoundation.audiocoder;
1+
package org.operatorfoundation.audiocoder.wspr;
22

33
public class WSPRMessage
44
{
55
public String out;
6-
float snr;
7-
float dt;
8-
float drift;
9-
double freq;
10-
String message;
11-
String call;
6+
public float snr;
7+
public float dt;
8+
public float drift;
9+
public double freq;
10+
public String message;
11+
public String call;
1212
int callhash;
13-
String loc;
14-
int power;
13+
public String loc;
14+
public int power;
1515

1616
public WSPRMessage(float snr, double freq, float dt, float drift, String message)
1717
{

0 commit comments

Comments
 (0)