Freedv labels, loopback settings

aprs
sh123 2022-08-11 13:11:36 +03:00
rodzic b0c331a8bb
commit b293f648ac
3 zmienionych plików z 40 dodań i 10 usunięć

Wyświetl plik

@ -3,7 +3,11 @@ package com.radio.codec2talkie.tools;
import android.content.SharedPreferences;
import android.graphics.Color;
import androidx.preference.PreferenceManager;
import com.radio.codec2talkie.app.AppWorker;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.ustadmobile.codec2.Codec2;
public class AudioTools {
@ -43,7 +47,34 @@ public class AudioTools {
return modeSpeed[1];
}
public static String getFreedvModeAsText(SharedPreferences sharedPreferences) {
if (sharedPreferences.getString(PreferenceKeys.PORTS_TYPE, "loopback").equals("sound_modem")) {
String modemType = sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_TYPE, "1200");
if (modemType.startsWith("F")) {
int mode = Integer.parseInt(modemType.substring(1));
switch (mode) {
case Codec2.FREEDV_MODE_700C: return "700C";
case Codec2.FREEDV_MODE_700D: return "700D";
case Codec2.FREEDV_MODE_700E: return "700E";
case Codec2.FREEDV_MODE_1600: return "1600";
case Codec2.FREEDV_MODE_800XA: return "800XA";
case Codec2.FREEDV_MODE_2020: return "2020";
case Codec2.FREEDV_MODE_2020B: return "2020B";
case Codec2.FREEDV_MODE_2400A: return "2400A";
case Codec2.FREEDV_MODE_2400B: return "2400B";
default: return null;
}
}
}
return null;
}
public static String getSpeedStatusText(String codec2ModeName, SharedPreferences sharedPreferences) {
// use freedv mode text instead if it is active
String freedvModeLabel = getFreedvModeAsText(sharedPreferences);
if (freedvModeLabel != null) return "DV: " + freedvModeLabel;
// codec2 speed
String speedModeInfo = "C2: " + AudioTools.extractCodec2Speed(codec2ModeName);

Wyświetl plik

@ -30,7 +30,7 @@ public class SoundModem implements Transport, Runnable {
private static final int RECORD_DELAY_MS = 10;
private static final int SAMPLE_RATE = 8000;
private final String _name;
private String _name;
private AudioTrack _systemAudioPlayer;
private AudioRecord _systemAudioRecorder;
@ -47,7 +47,7 @@ public class SoundModem implements Transport, Runnable {
private boolean _isLoopback = false;
public SoundModem(Context context) {
_name = "SndModem";
_name = "SoundModem";
_isPttOn = false;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
@ -55,6 +55,7 @@ public class SoundModem implements Transport, Runnable {
boolean disableRx = sharedPreferences.getBoolean(PreferenceKeys.PORTS_SOUND_MODEM_DISABLE_RX, false);
_pttOffDelayMs = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_PTT_OFF_DELAY_MS, "1000"));
_isLoopback = sharedPreferences.getBoolean(PreferenceKeys.PORTS_SOUND_MODEM_LOOPBACK, false);
if (_isLoopback) _name += "_";
constructSystemAudioDevices(disableRx);

Wyświetl plik

@ -35,7 +35,7 @@ public class SoundModemFsk implements Transport, Runnable {
public static final int SAMPLE_RATE = 19200;
//public static final int SAMPLE_RATE = 48000;
private final String _name;
private String _name;
private AudioTrack _systemAudioPlayer;
private AudioRecord _systemAudioRecorder;
@ -64,6 +64,7 @@ public class SoundModemFsk implements Transport, Runnable {
public SoundModemFsk(Context context) {
_context = context;
_isPttOn = false;
_sharedPreferences = PreferenceManager.getDefaultSharedPreferences(_context);
boolean disableRx = _sharedPreferences.getBoolean(PreferenceKeys.PORTS_SOUND_MODEM_DISABLE_RX, false);
@ -72,7 +73,9 @@ public class SoundModemFsk implements Transport, Runnable {
_pttOffDelayMs = Integer.parseInt(_sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_PTT_OFF_DELAY_MS, "1000"));
_isLoopback = _sharedPreferences.getBoolean(PreferenceKeys.PORTS_SOUND_MODEM_LOOPBACK, false);
_name = "SndModemFsk" + bitRate;
_name = "AFSK" + bitRate;
if (_isLoopback) _name += "_";
if (bitRate == 300) {
// <230 spacing for 300 bps does not work with codec2 fsk for receive
_fskModem = Codec2.fskCreate(SAMPLE_RATE, 300, 1600, 200, gain);
@ -89,10 +92,7 @@ public class SoundModemFsk implements Transport, Runnable {
constructSystemAudioDevices(disableRx);
if (_isLoopback)
_sampleBuffer = ByteBuffer.allocate(100000);
else
_sampleBuffer = ByteBuffer.allocate(0);
_sampleBuffer = ByteBuffer.allocate(_isLoopback ? 1024 * 100 : 0);
_rigCtl = RigCtlFactory.create(context);
try {
@ -101,8 +101,6 @@ public class SoundModemFsk implements Transport, Runnable {
e.printStackTrace();
}
_isPttOn = false;
if (!disableRx)
new Thread(this).start();
}