legacy
sh123 2022-07-29 21:27:53 +03:00
rodzic fae6937533
commit 2f20430d41
2 zmienionych plików z 15 dodań i 7 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ public class SoundModem implements Transport {
private static final String TAG = SoundModem.class.getSimpleName();
private static final int AUDIO_SAMPLE_SIZE = 48000;
private static final int AUDIO_SAMPLE_SIZE = 24000;
private final String _name;
@ -79,7 +79,7 @@ public class SoundModem implements Transport {
_systemAudioPlayer = new AudioTrack.Builder()
.setAudioAttributes(new AudioAttributes.Builder()
.setUsage(usage)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
.build())
.setAudioFormat(new AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
@ -103,27 +103,35 @@ public class SoundModem implements Transport {
public static byte[] toHdlcByteBitArray(byte[] data, boolean shouldBitStuff) {
StringBuilder s = new StringBuilder();
StringBuilder s2 = new StringBuilder();
ByteBuffer bitBuffer = ByteBuffer.allocate(512*8);
int cntOnes = 0;
for (int i = 0; i < 8 * data.length; i++) {
int b = data[i / 8];
if ((b & (1 << (i % 8))) > 0) {
int b = ((int)data[i / 8]) & 0xff;
if ((b & (1 << (7 - (i % 8)))) > 0) {
bitBuffer.put((byte)1);
s.append(1);
s.append('1');
if (shouldBitStuff)
cntOnes += 1;
} else {
bitBuffer.put((byte)0);
s.append(0);
cntOnes = 0;
}
if (shouldBitStuff && cntOnes == 5) {
bitBuffer.put((byte)0);
s.append(0);
s.append('0');
cntOnes = 0;
}
if (i % 8 == 3) s.append(':');
if (i % 8 == 7) {
s.append(' ');
s2.append(String.format("%02x ", b));
}
}
Log.i(TAG, s2.toString());
Log.i(TAG, s.toString());
bitBuffer.flip();

Wyświetl plik

@ -60,7 +60,7 @@ namespace Java_com_ustadmobile_codec2_Codec2 {
struct ContextFsk *conFsk;
conFsk = (struct ContextFsk *) malloc(sizeof(struct ContextFsk));
struct FSK *fsk;
fsk = fsk_create(sampleFrequency, symbolRate, MODE_2FSK, toneFreq, toneSpacing);
fsk = fsk_create_hbr(sampleFrequency, symbolRate, MODE_2FSK, sampleFrequency/symbolRate, FSK_DEFAULT_NSYM, toneFreq, toneSpacing);
conFsk->fsk = fsk;
conFsk->Nbits = fsk->Nbits;