Set number of burst for data

aprs
sh123 2022-08-23 17:09:36 +03:00
rodzic 95d844759a
commit 313ecc5e7b
4 zmienionych plików z 13 dodań i 8 usunięć

Wyświetl plik

@ -53,12 +53,12 @@ public class Freedv implements Protocol {
Log.i(TAG, "Using freedv mode " + AudioTools.getFreedvModeAsText(sharedPreferences)); Log.i(TAG, "Using freedv mode " + AudioTools.getFreedvModeAsText(sharedPreferences));
_freedv = Codec2.freedvCreate(mode, isSquelchEnabled, squelchSnr); _freedv = Codec2.freedvCreate(mode, isSquelchEnabled, squelchSnr, 0); // unset for speech
_modemTxBuffer = new short[Codec2.freedvGetNomModemSamples(_freedv)]; _modemTxBuffer = new short[Codec2.freedvGetNomModemSamples(_freedv)];
_speechRxBuffer = new short[Codec2.freedvGetMaxSpeechSamples(_freedv)]; _speechRxBuffer = new short[Codec2.freedvGetMaxSpeechSamples(_freedv)];
_speechSamples = ShortBuffer.allocate(1024*10); _speechSamples = ShortBuffer.allocate(1024*10);
_freedvData = Codec2.freedvCreate(dataMode, isSquelchEnabled, squelchSnr); _freedvData = Codec2.freedvCreate(dataMode, isSquelchEnabled, squelchSnr, 1);
_dataBuffer = new byte[Codec2.freedvGetBitsPerModemFrame(_freedvData) / 8]; _dataBuffer = new byte[Codec2.freedvGetBitsPerModemFrame(_freedvData) / 8];
_dataSamplesBuffer = new short[Codec2.freedvGetNTxSamples(_freedvData)]; _dataSamplesBuffer = new short[Codec2.freedvGetNTxSamples(_freedvData)];
_dataSamples = ShortBuffer.allocate(1024*10); _dataSamples = ShortBuffer.allocate(1024*10);

Wyświetl plik

@ -123,5 +123,4 @@
app:dependency="ports_sound_modem_freedv_enable_squelch" app:dependency="ports_sound_modem_freedv_enable_squelch"
app:defaultValue="0.0"> app:defaultValue="0.0">
</ListPreference> </ListPreference>
</PreferenceScreen> </PreferenceScreen>

Wyświetl plik

@ -99,7 +99,7 @@ namespace Java_com_ustadmobile_codec2_Codec2 {
return reinterpret_cast<jlong>(conFsk); return reinterpret_cast<jlong>(conFsk);
} }
static jlong freedvCreate(JNIEnv *env, jclass clazz, int mode, jboolean isSquelchEnabled, jfloat squelchSnr) { static jlong freedvCreate(JNIEnv *env, jclass clazz, int mode, jboolean isSquelchEnabled, jfloat squelchSnr, jlong framesPerBurst) {
struct ContextFreedv *conFreedv; struct ContextFreedv *conFreedv;
conFreedv = (struct ContextFreedv *) malloc(sizeof(struct ContextFreedv)); conFreedv = (struct ContextFreedv *) malloc(sizeof(struct ContextFreedv));
conFreedv->freeDv = freedv_open(mode); conFreedv->freeDv = freedv_open(mode);
@ -114,8 +114,14 @@ namespace Java_com_ustadmobile_codec2_Codec2 {
conFreedv->rawDataSamples = static_cast<short *>(malloc( conFreedv->rawDataSamples = static_cast<short *>(malloc(
freedv_get_n_tx_modem_samples(conFreedv->freeDv) * sizeof(short))); freedv_get_n_tx_modem_samples(conFreedv->freeDv) * sizeof(short)));
// squelch // squelch
freedv_set_squelch_en(conFreedv->freeDv, isSquelchEnabled); if (isSquelchEnabled) {
freedv_set_snr_squelch_thresh(conFreedv->freeDv, squelchSnr); freedv_set_squelch_en(conFreedv->freeDv, isSquelchEnabled);
freedv_set_snr_squelch_thresh(conFreedv->freeDv, squelchSnr);
}
// frames per single burst, 0 - not specified
if (framesPerBurst > 0) {
freedv_set_frames_per_burst(conFreedv->freeDv, framesPerBurst);
}
return reinterpret_cast<jlong>(conFreedv); return reinterpret_cast<jlong>(conFreedv);
} }
@ -362,7 +368,7 @@ namespace Java_com_ustadmobile_codec2_Codec2 {
{"fskSamplesPerSymbol", "(J)I", (void *) fskSamplesPerSymbol}, {"fskSamplesPerSymbol", "(J)I", (void *) fskSamplesPerSymbol},
{"fskNin", "(J)I", (void *) fskNin}, {"fskNin", "(J)I", (void *) fskNin},
// freedv // freedv
{"freedvCreate", "(IZF)J", (void *)freedvCreate}, {"freedvCreate", "(IZFJ)J", (void *)freedvCreate},
{"freedvDestroy", "(J)I", (void *)freedvDestroy}, {"freedvDestroy", "(J)I", (void *)freedvDestroy},
{"freedvGetMaxSpeechSamples", "(J)I", (void *)freedvGetMaxSpeechSamples}, {"freedvGetMaxSpeechSamples", "(J)I", (void *)freedvGetMaxSpeechSamples},
{"freedvGetMaxModemSamples", "(J)I", (void *)freedvGetMaxModemSamples}, {"freedvGetMaxModemSamples", "(J)I", (void *)freedvGetMaxModemSamples},

Wyświetl plik

@ -63,7 +63,7 @@ public class Codec2 {
public native static long fskDemodulate(long conFsk, short[] inputSamples, byte[] outputBits); public native static long fskDemodulate(long conFsk, short[] inputSamples, byte[] outputBits);
// freedv // freedv
public native static long freedvCreate(int mode, boolean isSquelchEnabled, float squelchSnr); public native static long freedvCreate(int mode, boolean isSquelchEnabled, float squelchSnr, long framesPerBurst);
public native static int freedvDestroy(long conFreedv); public native static int freedvDestroy(long conFreedv);
public native static int freedvGetMaxSpeechSamples(long conFreedv); public native static int freedvGetMaxSpeechSamples(long conFreedv);