kopia lustrzana https://github.com/sh123/codec2_talkie
Fix freedv demodulation and add squelch
rodzic
96e5b534a9
commit
f6827275ad
|
@ -82,7 +82,7 @@ public class Freedv implements Protocol {
|
|||
//Log.i(TAG, "read " + bytesRead);
|
||||
long cntRead = Codec2.freedvRx(_freedv, _speechRxBuffer, buf);
|
||||
if (cntRead > 0) {
|
||||
Log.i(TAG, "receive " + cntRead);
|
||||
//Log.i(TAG, "receive " + cntRead);
|
||||
_parentProtocolCallback.onReceivePcmAudio(null, null, -1, Arrays.copyOf(_speechRxBuffer, (int) cntRead));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ public class SoundModem implements Transport, Runnable {
|
|||
|
||||
private static final String TAG = SoundModem.class.getSimpleName();
|
||||
|
||||
private static final int RECORD_DELAY_MS = 10;
|
||||
private static final int SAMPLE_RATE = 8000;
|
||||
private static final int SAMPLE_RATE = 8000; // TODO, need to get from freedv
|
||||
|
||||
private String _name;
|
||||
|
||||
|
@ -45,7 +44,7 @@ public class SoundModem implements Transport, Runnable {
|
|||
|
||||
private final ShortBuffer _recordAudioBuffer;
|
||||
|
||||
private boolean _isLoopback = false;
|
||||
private boolean _isLoopback;
|
||||
|
||||
public SoundModem(Context context) {
|
||||
_name = "SoundModem";
|
||||
|
@ -151,7 +150,7 @@ public class SoundModem implements Transport, Runnable {
|
|||
try {
|
||||
_recordAudioBuffer.put(sample);
|
||||
} catch (BufferOverflowException e) {
|
||||
e.printStackTrace();
|
||||
// client is transmitting and cannot consume the buffer, just discard
|
||||
_recordAudioBuffer.clear();
|
||||
}
|
||||
}
|
||||
|
@ -181,11 +180,6 @@ public class SoundModem implements Transport, Runnable {
|
|||
int readSize = 32;
|
||||
short [] sampleBuf = new short[readSize];
|
||||
while (_isRunning) {
|
||||
try {
|
||||
Thread.sleep(RECORD_DELAY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int readCnt = _systemAudioRecorder.read(sampleBuf, 0, readSize);
|
||||
if (readCnt != readSize) {
|
||||
Log.w(TAG, "" + readCnt + " != " + readSize);
|
||||
|
|
|
@ -108,6 +108,7 @@ namespace Java_com_ustadmobile_codec2_Codec2 {
|
|||
conFreedv->modemSamples = static_cast<short *>(malloc(
|
||||
freedv_get_n_max_modem_samples(conFreedv->freeDv) * sizeof(short)));
|
||||
freedv_set_squelch_en(conFreedv->freeDv, 1);
|
||||
freedv_set_snr_squelch_thresh(conFreedv->freeDv, -5.0);
|
||||
return reinterpret_cast<jlong>(conFreedv);
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue