kopia lustrzana https://github.com/sh123/codec2_talkie
OPUS init
rodzic
f5ce9e7bbd
commit
e88a94e9be
|
@ -71,6 +71,7 @@ public class ProtocolFactory {
|
|||
boolean aprsEnabled = SettingsWrapper.isAprsEnabled(sharedPreferences);
|
||||
boolean aprsIsEnabled = SettingsWrapper.isAprsIsEnabled(sharedPreferences);
|
||||
boolean freedvEnabled = SettingsWrapper.isFreeDvSoundModemModulation(sharedPreferences);
|
||||
boolean codec2Enabled = SettingsWrapper.isCodec2Enabled(sharedPreferences);
|
||||
|
||||
// "root" protocol
|
||||
Protocol proto;
|
||||
|
@ -103,12 +104,16 @@ public class ProtocolFactory {
|
|||
proto = new Ax25(proto);
|
||||
}
|
||||
if (!freedvEnabled) {
|
||||
if (recordingEnabled) {
|
||||
proto = new Recorder(proto, sharedPreferences);
|
||||
}
|
||||
if (codec2Enabled) {
|
||||
if (recordingEnabled) {
|
||||
proto = new Recorder(proto, sharedPreferences);
|
||||
}
|
||||
|
||||
proto = new AudioCodec2FrameAggregator(proto, sharedPreferences);
|
||||
proto = new AudioCodec2(proto, sharedPreferences);
|
||||
proto = new AudioCodec2FrameAggregator(proto, sharedPreferences);
|
||||
proto = new AudioCodec2(proto, sharedPreferences);
|
||||
} else {
|
||||
proto = new AudioOpus(proto);
|
||||
}
|
||||
}
|
||||
|
||||
if (aprsEnabled) {
|
||||
|
|
|
@ -38,6 +38,7 @@ public final class PreferenceKeys {
|
|||
|
||||
public static String OPUS_BIT_RATE = "opus_bit_rate";
|
||||
public static String OPUS_FRAME_SIZE = "opus_frame_size";
|
||||
public static String OPUS_COMPLEXITY = "opus_complexity";
|
||||
|
||||
public static String KISS_ENABLED = "kiss_enable";
|
||||
public static String KISS_BUFFERED_ENABLED = "kiss_buffered_enable";
|
||||
|
|
|
@ -40,6 +40,10 @@ public class SettingsWrapper {
|
|||
sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_TYPE, "1200").startsWith("F");
|
||||
}
|
||||
|
||||
public static boolean isCodec2Enabled(SharedPreferences sharedPreferences) {
|
||||
return sharedPreferences.getString(PreferenceKeys.CODEC_TYPE, "Codec2").equals("Codec2");
|
||||
}
|
||||
|
||||
public static int getFreeDvSoundModemModulation(SharedPreferences sharedPreferences) {
|
||||
String modemType = sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_TYPE, "1200");
|
||||
if (modemType.startsWith("F")) {
|
||||
|
|
|
@ -88,7 +88,13 @@ public class AudioTools {
|
|||
if (freedvModeLabel != null) return freedvModeLabel;
|
||||
|
||||
// codec2 speed
|
||||
String speedModeInfo = "C2: " + AudioTools.extractCodec2Speed(codec2ModeName);
|
||||
String speedModeInfo;
|
||||
if (SettingsWrapper.isCodec2Enabled()) {
|
||||
speedModeInfo = "C2: " + AudioTools.extractCodec2Speed(codec2ModeName);
|
||||
} else {
|
||||
int speed = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.OPUS_BIT_RATE, "3200"));
|
||||
speedModeInfo = "OPUS: " + speed;
|
||||
}
|
||||
|
||||
// radio speed
|
||||
int radioSpeedBps = RadioTools.getRadioSpeed(sharedPreferences);
|
||||
|
|
|
@ -30,10 +30,29 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="opus_frame_size">
|
||||
<item>2.5</item>
|
||||
<item>5</item>
|
||||
<item>10</item>
|
||||
<item>20</item>
|
||||
<item>40</item>
|
||||
<item>60</item>
|
||||
<item>80</item>
|
||||
<item>180</item>
|
||||
<item>100</item>
|
||||
<item>120</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="opus_complexity_value">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="lora_bandwidths">
|
||||
|
|
|
@ -25,9 +25,10 @@
|
|||
<string name="codec2_recorder_summary">Record incoming and outgoing transmissions for future playback</string>
|
||||
|
||||
<string name="opus_category_title">OPUS Settings</string>
|
||||
<string name="opus_frame_size_title">Frame size</string>
|
||||
<string name="opus_frame_size_title">PCM frame duration [ms]</string>
|
||||
<string name="opus_bit_rate_title">Bit rate</string>
|
||||
<string name="opus_bit_rate_summary">Bit rate from 500 up to 512000bps</string>
|
||||
<string name="opus_complexity_title">Complexity</string>
|
||||
|
||||
<string name="main_status_loopback_test">Loopback</string>
|
||||
<string name="main_status_stop">STOPPED</string>
|
||||
|
@ -179,7 +180,7 @@
|
|||
<string name="kiss_toast_modem_reboot">Modem reboot requested</string>
|
||||
|
||||
<string name="codec2_tx_frame_max_size_title">Maximum super frame size (bytes)</string>
|
||||
<string name="codec2_tx_frame_max_size_summary">Multiple Codec2 samples are aggregated into super frame not larger than this value</string>
|
||||
<string name="codec2_tx_frame_max_size_summary">Multiple audio codec encoded samples are aggregated into super frame not larger than this value</string>
|
||||
|
||||
<string name="usb_settings_title">USB settings</string>
|
||||
<string name="usb_data_bits_title">Serial data bits</string>
|
||||
|
|
|
@ -134,6 +134,13 @@
|
|||
app:fragment="com.radio.codec2talkie.settings.SettingsActivity$SettingsCodecFragment">
|
||||
</Preference>
|
||||
|
||||
<EditTextPreference
|
||||
app:key="codec2_tx_frame_max_size"
|
||||
app:title="@string/codec2_tx_frame_max_size_title"
|
||||
app:summary="@string/codec2_tx_frame_max_size_summary"
|
||||
app:defaultValue="48">
|
||||
</EditTextPreference>
|
||||
|
||||
<SwitchPreference
|
||||
app:key="codec2_recording_enabled"
|
||||
app:title="@string/codec2_recorder_title"
|
||||
|
|
|
@ -15,13 +15,6 @@
|
|||
app:summary="%s">
|
||||
</ListPreference>
|
||||
|
||||
<EditTextPreference
|
||||
app:key="codec2_tx_frame_max_size"
|
||||
app:title="@string/codec2_tx_frame_max_size_title"
|
||||
app:summary="@string/codec2_tx_frame_max_size_summary"
|
||||
app:defaultValue="48">
|
||||
</EditTextPreference>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
@ -44,6 +37,15 @@
|
|||
app:summary="%s">
|
||||
</ListPreference>
|
||||
|
||||
<ListPreference
|
||||
app:key="opus_complexity"
|
||||
app:title="@string/opus_complexity_title"
|
||||
app:entries="@array/opus_complexity_value"
|
||||
app:entryValues="@array/opus_complexity_value"
|
||||
app:defaultValue="5"
|
||||
app:summary="%s">
|
||||
</ListPreference>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -57,19 +57,19 @@ namespace Java_com_radio_opus_Opus {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static jint decode(JNIEnv *env, jclass clazz, jlong n, jcharArray in, jshortArray out, jint frames)
|
||||
static jint decode(JNIEnv *env, jclass clazz, jlong n, jbyteArray in, jshortArray out, jint frames)
|
||||
{
|
||||
Context *con = getContext(n);
|
||||
OpusDecoder *decoder = con->decoder;
|
||||
|
||||
jint inputArraySize = env->GetArrayLength(in);
|
||||
|
||||
jchar* encodedData = env->GetCharArrayElements(in, 0);
|
||||
jbyte* encodedData = env->GetByteArrayElements(in, 0);
|
||||
jshort* decodedData = env->GetShortArrayElements(out, 0);
|
||||
|
||||
int samples = opus_decode(decoder, (const unsigned char *)encodedData, inputArraySize, decodedData, frames, 0);
|
||||
|
||||
env->ReleaseCharArrayElements(in, encodedData, JNI_ABORT);
|
||||
env->ReleaseByteArrayElements(in, encodedData, JNI_ABORT);
|
||||
env->ReleaseShortArrayElements(out, decodedData, 0);
|
||||
|
||||
return samples;
|
||||
|
@ -96,7 +96,7 @@ namespace Java_com_radio_opus_Opus {
|
|||
static JNINativeMethod method_table[] = {
|
||||
{"create", "(IIIII)J", (void *) create },
|
||||
{"destroy", "(J)I", (void *) destroy },
|
||||
{"decode", "(J[C[SI)I", (void *) decode },
|
||||
{"decode", "(J[B[SI)I", (void *) decode },
|
||||
{"encode", "(J[SI[C)I", (void *) encode }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -26,9 +26,19 @@ public class Opus {
|
|||
public static final int OPUS_FRAMESIZE_100_MS = 5008; /**< Use 100 ms frames */
|
||||
public static final int OPUS_FRAMESIZE_120_MS = 5009; /**< Use 120 ms frames */
|
||||
|
||||
// errors
|
||||
public static final int OPUS_OK = 0;
|
||||
public static final int OPUS_BAD_ARG = -1;
|
||||
public static final int OPUS_BUFFER_TOO_SMALL = -2;
|
||||
public static final int OPUS_INTERNAL_ERROR = -3;
|
||||
public static final int OPUS_INVALID_PACKET = -4;
|
||||
public static final int OPUS_UNIMPLEMENTED = -5;
|
||||
public static final int OPUS_INVALID_STATE = -6;
|
||||
public static final int OPUS_ALLOC_FAIL = -7;
|
||||
|
||||
public native static long create(int sampleRate, int numChannels, int application, int bitrate, int complexity);
|
||||
public native static int destroy(long con);
|
||||
|
||||
public native static int decode(long con, char[] in, short[] out, int frames);
|
||||
public native static int decode(long con, byte[] in, short[] out, int frames);
|
||||
public native static int encode(long con, short[] in, int frames, char[] out);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue