@@ -93,11 +93,10 @@ Java_org_operatorfoundation_audiocoder_CJarInterface_WSPREncodeToPCM
9393 * @param j_offset Frequency offset in Hz (added to base 1500 Hz)
9494 * @param lsb_mode LSB mode flag - inverts symbol order if true
9595 *
96- * @return jbyteArray containing 162 frequencies as 64-bit integers (* 100)
97- * Total array size: 162 symbols * 8 bytes = 1,296 bytes
98- * Each frequency is stored as big-endien 64-bit integer with 0.01 Hz precision
96+ * @return jlongArray containing 162 frequencies as 64-bit integers (* 100)
97+ * Each frequency has 0.01 Hz precision
9998 */
100- extern " C" JNIEXPORT jbyteArray
99+ extern " C" JNIEXPORT jlongArray
101100 JNICALL
102101 Java_org_operatorfoundation_audiocoder_CJarInterface_WSPREncodeToFrequencies (JNIEnv *env, jclass cls, jstring j_calls, jstring j_local, jint j_powr, jint j_offset, jboolean lsb_mode) {
103102 // Array to hold the 162 WSPR symbols (0-3 values representing frequency shifts)
@@ -125,9 +124,7 @@ Java_org_operatorfoundation_audiocoder_CJarInterface_WSPREncodeToPCM
125124 env->ReleaseStringUTFChars (j_calls, callsign);
126125 env->ReleaseStringUTFChars (j_local, loca);
127126
128- // Allocate array for frequency data (162 frequencies x 8 bytes each)
129- const int FREQUENCY_ARRAY_SIZE = WSPR_SYMBOL_COUNT * sizeof (int64_t );
130- int64_t *frequencies = (int64_t *) malloc (FREQUENCY_ARRAY_SIZE);
127+ int64_t *frequencies = (int64_t *) malloc (WSPR_SYMBOL_COUNT * sizeof (int64_t ));
131128
132129 if (frequencies == NULL )
133130 {
@@ -166,25 +163,25 @@ Java_org_operatorfoundation_audiocoder_CJarInterface_WSPREncodeToPCM
166163 }
167164 }
168165
169- jbyteArray result = env->NewByteArray (FREQUENCY_ARRAY_SIZE );
166+ jlongArray result = env->NewLongArray (WSPR_SYMBOL_COUNT );
170167 if (result == NULL )
171168 {
172169 __android_log_print (ANDROID_LOG_ERROR,
173170 APPNAME,
174- " Failed to create Java byte array for WSPR encoding." );
171+ " Failed to create Java long array for WSPR encoding." );
175172 free (frequencies);
176173 return NULL ;
177174 }
178175
179- // Copy frequency data to Java byte array
180- env->SetByteArrayRegion (result, 0 , FREQUENCY_ARRAY_SIZE , (jbyte *) frequencies);
176+ // Copy frequency data to Java long array
177+ env->SetLongArrayRegion (result, 0 , WSPR_SYMBOL_COUNT , (jlong *) frequencies);
181178
182179 // Don't forget to clean up after yourself!
183180 free (frequencies);
184181
185182 __android_log_print (ANDROID_LOG_INFO, APPNAME,
186- " WSPR frequency encoding complete: %d frequencies, %d bytes " ,
187- WSPR_SYMBOL_COUNT, FREQUENCY_ARRAY_SIZE );
183+ " WSPR frequency encoding complete: %d frequencies" ,
184+ WSPR_SYMBOL_COUNT);
188185
189186 return result;
190187 }
0 commit comments