let's have at least one 1 second mode

This commit is contained in:
Ahmet Inan 2025-07-13 10:26:59 +02:00
commit 7946e8e3bb
6 changed files with 25 additions and 37 deletions

20
README.md vendored
View file

@ -3,10 +3,10 @@
Quick start:
Create file ```uncoded.dat``` with ```8192``` bits of random data:
Create file ```uncoded.dat``` with ```2048``` bits of random data:
```
dd if=/dev/urandom of=uncoded.dat bs=1 count=1024
dd if=/dev/urandom of=uncoded.dat bs=1 count=256
```
Encode file ```uncoded.dat``` to ```encoded.wav``` [WAV](https://en.wikipedia.org/wiki/WAV) audio file with 8000 Hz sample rate, 16 bits and only 1 (real) channel:
@ -44,16 +44,16 @@ diff -s uncoded.dat decoded.dat
All modes need a bandwidth of 2000 Hz and use a 1/2-rate forward error correction code
These use a differential modulation scheme:
* Mode 0: DBPSK, 3.06 seconds and 256 bytes
* Mode 1: DQPSK, 3.06 seconds and 512 bytes
* Mode 2: D8PSK, 4.08 seconds and 1024 bytes
* Mode 0: DBPSK, 3 seconds and 256 bytes
* Mode 1: DQPSK, 3 seconds and 512 bytes
* Mode 2: D8PSK, 4 seconds and 1024 bytes
And these a coherent modulation scheme:
* Mode 3: BPSK, 3.06 seconds and 256 bytes
* Mode 4: QPSK, 3.06 seconds and 512 bytes
* Mode 5: QAM16, 3.06 seconds and 1024 bytes
* Mode 6: QAM64, 4.08 seconds and 2048 bytes
* Mode 7: QAM256, 5.78 seconds and 4096 bytes
* Mode 3: BPSK, 3 seconds and 256 bytes
* Mode 4: QPSK, 3 seconds and 512 bytes
* Mode 5: QAM16, 1 second and 256 bytes
* Mode 6: QAM16, 3 seconds and 1024 bytes
* Mode 7: QAM64, 4 seconds and 2048 bytes
### Simulating

View file

@ -13,10 +13,10 @@ Copyright 2025 Ahmet Inan <inan@aicodix.de>
struct Common
{
static const int mod_max = 8;
static const int code_max = 16;
static const int code_max = 15;
static const int bits_max = 1 << code_max;
static const int data_max = 4096;
static const int symbols_max = 32;
static const int data_max = 2048;
static const int symbols_max = 22;
static const int mls0_poly = 0x331;
static const int mls0_seed = 214;
static const int mls1_poly = 0x43;
@ -95,6 +95,14 @@ struct Common
frozen_bits = frozen_8192_4128;
break;
case 5:
mod_bits = 4;
symbol_count = 4;
differential = false;
code_order = 12;
data_bits = 2048;
frozen_bits = frozen_4096_2080;
break;
case 6:
mod_bits = 4;
symbol_count = 16;
differential = false;
@ -102,7 +110,7 @@ struct Common
data_bits = 8192;
frozen_bits = frozen_16384_8224;
break;
case 6:
case 7:
mod_bits = 6;
symbol_count = 22;
differential = false;
@ -110,14 +118,6 @@ struct Common
data_bits = 16384;
frozen_bits = frozen_32768_16416;
break;
case 7:
mod_bits = 8;
symbol_count = 32;
differential = false;
code_order = 16;
data_bits = 32768;
frozen_bits = frozen_65536_32800;
break;
default:
return;
}

View file

@ -160,11 +160,6 @@ struct Decoder : Common
dest[0] = src[0];
for (int i = 1; i < 32768; ++i)
dest[seq()] = src[i];
} else if (code_order == 16) {
CODE::XorShiftMask<int, 16, 1, 1, 14, 1> seq;
dest[0] = src[0];
for (int i = 1; i < 65536; ++i)
dest[seq()] = src[i];
}
}
const cmplx *next_sample()
@ -338,7 +333,7 @@ struct Decoder : Common
int bits = mod_bits;
if (oper_mode == 2 && l % 32 == 30)
bits = 2;
if (oper_mode == 6 && l % 64 == 60)
if (oper_mode == 7 && l % 64 == 60)
bits = 4;
demap_hard(perm+l, demod[i], bits);
hard = map_bits(perm+l, bits);
@ -356,7 +351,7 @@ struct Decoder : Common
int bits = mod_bits;
if (oper_mode == 2 && k % 32 == 30)
bits = 2;
if (oper_mode == 6 && k % 64 == 60)
if (oper_mode == 7 && k % 64 == 60)
bits = 4;
demap_soft(perm+k, demod[i], precision, bits);
k += bits;

View file

@ -229,11 +229,6 @@ struct Encoder : public Common
dest[0] = src[0];
for (int i = 1; i < 32768; ++i)
dest[i] = src[seq()];
} else if (code_order == 16) {
CODE::XorShiftMask<int, 16, 1, 1, 14, 1> seq;
dest[0] = src[0];
for (int i = 1; i < 65536; ++i)
dest[i] = src[seq()];
}
}
void guard_interval_weights()
@ -289,7 +284,7 @@ struct Encoder : public Common
int bits = mod_bits;
if (oper_mode == 2 && k % 32 == 30)
bits = 2;
if (oper_mode == 6 && k % 64 == 60)
if (oper_mode == 7 && k % 64 == 60)
bits = 4;
tone[i] = map_bits(perm+k, bits);
k += bits;

View file

@ -27,7 +27,6 @@ void code(int N, int K, double P)
int main()
{
code<16>(65536, 32768+32, 0.42);
code<15>(32768, 16384+32, 0.40);
code<14>(16384, 8192+32, 0.39);
code<13>(8192, 4096+32, 0.38);

File diff suppressed because one or more lines are too long