Skip to content

Commit 172fa91

Browse files
committed
chancged coohpsk_ch --raw_dir argument to be --fading_dir for consistency
1 parent 891973b commit 172fa91

File tree

10 files changed

+29
-29
lines changed

10 files changed

+29
-29
lines changed

README_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Clipping works by introducing controlled distortion, which affects the SNR estim
336336

337337
This command line demonstrates the effect:
338338
```
339-
/src/freedv_data_raw_tx datac3 /dev/zero - --testframes 10 --bursts 10 --clip 1 | ./src/cohpsk_ch - - -100 --raw_dir ../raw --Fs 8000 | ./src/freedv_data_raw_rx datac3 - /dev/null --testframes --framesperburst 1 -v
339+
./src/freedv_data_raw_tx datac3 /dev/zero - --testframes 10 --bursts 10 --clip 1 | ./src/cohpsk_ch - - -100 --fading_dir unittest --Fs 8000 | ./src/freedv_data_raw_rx datac3 - /dev/null --testframes --framesperburst 1 -v
340340
```
341341
Try adjusting `--clip` and third argument of `cohpsk_ch` (noise level) for different modes. Note the SNR estimates returned from `freedv_data_raw_rx` compared to the SNR from the channel simulator `cohpsh_ch`. You will notice clipping also increases the RMS power and reduces the PER for a given noise level.
342342

README_freedv.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ $ ./freedv_tx 2020 ~/LPCNet/wav/all.wav - | ./cohpsk_ch - - -22 --Fs 8000 | ./fr
185185

186186
AWGN:
187187
```
188-
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -16 --raw_dir ../raw/ --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
188+
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -16 --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
189189
```
190190
MultiPath Poor (MPP):
191191
```
192-
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -24 --fast --raw_dir ../raw/ --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
192+
$ ./src/freedv_tx 700D ../raw/ve9qrp.raw - --clip 0 --testframes | ./src/cohpsk_ch - - -24 --mpp --fading_dir unittest --Fs 8000 | ./src/freedv_rx 700D - /dev/null --testframes
193193
```
194194

195195
Adjust `--clip [0|1]` and 3rd argument of `cohpsk_ch` to obtain a PER of just less than 0.1, and note the SNR and PAPR reported by `cohpsk_ch`. The use of the `ve9qrp` samples makes the test run for a few minutes, in order to get reasonable multipath channel results.

src/cohpsk_ch.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
/* see instructions below for how to generate thsese files */
5050

51-
#define DEFAULT_RAW_DIR "../../raw"
51+
#define DEFAULT_FADING_DIR ""
5252
#define MPG_FADING_FILE_NAME "slow_fading_samples.float"
5353
#define MPP_FADING_FILE_NAME "fast_fading_samples.float"
5454
#define MPD_FADING_FILE_NAME "faster_fading_samples.float"
@@ -80,7 +80,7 @@ COMP noise(void) {
8080
int main(int argc, char *argv[])
8181
{
8282
FILE *fin, *ffading, *fout;
83-
char *raw_dir;
83+
char *fading_dir;
8484
float NodB, foff_hz;
8585
int fading_en, nhfdelay;
8686

@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
119119
Fs = COHPSK_FS; foff_hz = 0.0; fading_en = 0; ctest = 0;
120120
clip =32767; gain = 1.0;
121121
ssbfilt_en = 1; complex_out = 0;
122-
raw_dir = strdup(DEFAULT_RAW_DIR); user_multipath_delay = -1.0;
122+
fading_dir = strdup(DEFAULT_FADING_DIR); user_multipath_delay = -1.0;
123123

124124
for(int i=4; i<argc; i++) {
125125
if (!strcmp(argv[i],"--Fs")) { Fs = atoi(argv[i+1]); i++; }
@@ -133,8 +133,8 @@ int main(int argc, char *argv[])
133133
else if (!strcmp(argv[i], "--complexout")) complex_out = 1;
134134
else if (!strcmp(argv[i], "--ctest")) ctest = 1;
135135
else if (!strcmp(argv[i], "--multipath_delay")) { user_multipath_delay = atof(argv[i+1]); i++; }
136-
else if (!strcmp(argv[i], "--raw_dir")) {
137-
FREE(raw_dir); raw_dir = strdup(argv[i+1]); i++;
136+
else if (!strcmp(argv[i], "--fading_dir")) {
137+
FREE(fading_dir); fading_dir = strdup(argv[i+1]); i++;
138138
} else {
139139
fprintf(stderr, "Unknown argument: %s\n", argv[i]);
140140
exit(1);
@@ -143,7 +143,7 @@ int main(int argc, char *argv[])
143143
}
144144
else {
145145
fprintf(stderr, "usage: %s InputRealModemRawFile OutputRealModemRawFile No(dB/Hz) [--Fs SampleRateHz]"
146-
" [-f FoffHz] [--mpg] [--mpp] [--mpd] [--clip 0to1] [--ssbfilt 0|1] [--raw_dir Path]"
146+
" [-f FoffHz] [--mpg] [--mpp] [--mpd] [--clip 0to1] [--ssbfilt 0|1] [--fading_dir Path]"
147147
" [--complexout] [--mulipath_delay ms]\n", argv[0]);
148148
exit(1);
149149
}
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
152152

153153
/* N = var = NoFs */
154154

155-
// arbitrary nise scaling, to maintain backwards compatability with many tests. TODO make the No
155+
// arbitrary noise scaling, to maintain backwards compatability with many tests. TODO make the No
156156
// units more sensible, and fix all the tests that depend on this scaling
157157
No = pow(10.0, NodB/10.0)*1000*1000;
158158
variance = Fs*No;
@@ -169,35 +169,35 @@ int main(int argc, char *argv[])
169169
char fname[256];
170170

171171
if (fading_en == 1) {
172-
sprintf(fname, "%s/%s", raw_dir, MPG_FADING_FILE_NAME);
172+
sprintf(fname, "%s/%s", fading_dir, MPG_FADING_FILE_NAME);
173173
ffading = fopen(fname, "rb");
174174
if (ffading == NULL) {
175175
cant_load_fading_file:
176176
fprintf(stderr, "-----------------------------------------------------\n");
177177
fprintf(stderr, "cohpsk_ch ERROR: Can't find fading file: %s\n", fname);
178-
fprintf(stderr, "\nAdjust path --raw_dir or use GNU Octave to generate:\n\n");
178+
fprintf(stderr, "\nAdjust path --fading_dir or use GNU Octave to generate:\n\n");
179179
gen_fading_file:
180180
fprintf(stderr, "$ octave --no-gui\n");
181181
fprintf(stderr, "octave:24> pkg load signal\n");
182182
fprintf(stderr, "octave:24> time_secs=60\n");
183-
fprintf(stderr, "octave:25> cohpsk_ch_fading(\"../raw/faster_fading_samples.float\", 8000, 2.0, 8000*time_secs)\n");
184-
fprintf(stderr, "octave:26> cohpsk_ch_fading(\"../raw/fast_fading_samples.float\", 8000, 1.0, 8000*time_secs)\n");
185-
fprintf(stderr, "octave:27> cohpsk_ch_fading(\"../raw/slow_fading_samples.float\", 8000, 0.1, 8000*time_secs)\n");
183+
fprintf(stderr, "octave:25> cohpsk_ch_fading(\"faster_fading_samples.float\", 8000, 2.0, 8000*time_secs)\n");
184+
fprintf(stderr, "octave:26> cohpsk_ch_fading(\"fast_fading_samples.float\", 8000, 1.0, 8000*time_secs)\n");
185+
fprintf(stderr, "octave:27> cohpsk_ch_fading(\"slow_fading_samples.float\", 8000, 0.1, 8000*time_secs)\n");
186186
fprintf(stderr, "-----------------------------------------------------\n");
187187
exit(1);
188188
}
189189
nhfdelay = floor(MPG_DELAY_MS*Fs/1000);
190190
}
191191

192192
if (fading_en == 2) {
193-
sprintf(fname, "%s/%s", raw_dir, MPP_FADING_FILE_NAME);
193+
sprintf(fname, "%s/%s", fading_dir, MPP_FADING_FILE_NAME);
194194
ffading = fopen(fname, "rb");
195195
if (ffading == NULL) goto cant_load_fading_file;
196196
nhfdelay = floor(MPP_DELAY_MS*Fs/1000);
197197
}
198198

199199
if (fading_en == 3) {
200-
sprintf(fname, "%s/%s", raw_dir, MPD_FADING_FILE_NAME);
200+
sprintf(fname, "%s/%s", fading_dir, MPD_FADING_FILE_NAME);
201201
ffading = fopen(fname, "rb");
202202
if (ffading == NULL) goto cant_load_fading_file;
203203
nhfdelay = floor(MPD_DELAY_MS*Fs/1000);

unittest/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ ExternalProject_Add(cml
107107
)
108108

109109
# Create fading files (used for channel simulation) as part of unit test setup
110-
add_custom_target(fade_files ALL
110+
add_custom_target(fading_files ALL
111111
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fast_fading_samples.float
112112
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/faster_fading_samples.float
113113
)
114114
add_custom_command(
115115
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fast_fading_samples.float
116116
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/faster_fading_samples.float
117-
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ./fade_files.sh ${CMAKE_CURRENT_BINARY_DIR}
117+
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ./fading_files.sh ${CMAKE_CURRENT_BINARY_DIR}
118118
)

unittest/ofdm_check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [[ $p1 -eq 1 && $p2 -eq 1 ]]; then echo "OK"; else echo "BAD"; PASS=0; fi
3131
echo
3232
echo "Simple test, plain, AWGN"
3333
OFDM_MOD --in /dev/zero --testframes 100 |
34-
cohpsk_ch - - -20 -Fs 8000 -f -5 --raw_dir ../../raw |
34+
cohpsk_ch - - -20 -Fs 8000 -f -5 |
3535
OFDM_DEMOD --out /dev/null --testframes --verbose 1 2>tmp
3636
cat tmp
3737
n=$(grep '^BER\.*:' tmp | cut -d ' ' -f 2)
@@ -54,7 +54,7 @@ if [[ $p1 -eq 1 && $p2 -eq 1 ]]; then echo "OK"; else echo "BAD"; PASS=0; fi
5454
echo
5555
echo "Simple test, LDPC, AWGN"
5656
OFDM_MOD --in /dev/zero --ldpc --testframes 100 |
57-
cohpsk_ch - - -20 -Fs 8000 -f -5 --raw_dir ../../raw |
57+
cohpsk_ch - - -20 -Fs 8000 -f -5 --fading_dir ../../build_linux/unittest |
5858
OFDM_DEMOD --out /dev/null --ldpc --testframes --verbose 1 2>tmp
5959
cat tmp
6060
n=$(grep '^BER\.*:' tmp | cut -d ' ' -f 2)

unittest/ofdm_fade.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Tests 700D OFDM modem fading channel performance, using a simulated channel
55

66
results=$(mktemp)
7-
fade_dir=$1
7+
fading_dir=$1
88
# BER should be around 4% for this test (it's better for larger interleavers but no one uses interleaving in practice)
9-
ofdm_mod --in /dev/zero --ldpc 1 --testframes 60 --txbpf | cohpsk_ch - - -24 --Fs 8000 -f -10 --mpp --raw_dir $fade_dir | ofdm_demod --out /dev/null --testframes --verbose 2 --ldpc 1 2> $results
9+
ofdm_mod --in /dev/zero --ldpc 1 --testframes 60 --txbpf | cohpsk_ch - - -24 --Fs 8000 -f -10 --mpp --fading_dir $fading_dir | ofdm_demod --out /dev/null --testframes --verbose 2 --ldpc 1 2> $results
1010
cat $results
1111
cber=$(cat $results | sed -n "s/^Coded BER.* \([0-9..]*\) Tbits.*/\1/p")
1212
python3 -c "import sys; sys.exit(0) if $cber<=0.05 else sys.exit(1)"

unittest/ofdm_fade_dpsk.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# David Sep 2019
44
# Tests 2020 OFDM modem fading channel performance in DPSK mode, using a simulated faster (2Hz) high SNR fading channel
55

6-
RAW=$1
6+
fading_dir=$1
77
results=$(mktemp)
88

99
# Coded BER should be < 1% for this test
1010
ofdm_mod --in /dev/zero --testframes 300 --mode 2020 --ldpc --verbose 1 -p 312 --dpsk | \
11-
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpd --raw_dir $RAW --multipath_delay 2 | \
11+
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpd --fading_dir $fading_dir --multipath_delay 2 | \
1212
ofdm_demod --out /dev/null --testframes --mode 2020 --verbose 1 --ldpc -p 312 --dpsk 2> $results
1313
cat $results
1414
cber=$(cat $results | sed -n "s/^Coded BER.* \([0-9..]*\) Tbits.*/\1/p")

unittest/ofdm_phase_est_bw.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# $ PATH=$PATH:../build_linux/src ./ofdm_phase_est_bw.sh
1515

1616
results=$(mktemp)
17-
fade_dir=$1
17+
fading_dir=$1
1818
# BER should be < 5% for this test
1919
ofdm_mod --in /dev/zero --testframes 300 --mode 2020 --ldpc -p 312 --verbose 0 | \
20-
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpp --raw_dir $fade_dir | \
20+
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpp --fading_dir $fading_dir | \
2121
ofdm_demod --out /dev/null --testframes --mode 2020 --verbose 2 --ldpc -p 312 --bandwidth 1 2> $results
2222
cat $results
2323
cber=$(cat $results | sed -n "s/^Coded BER.* \([0-9..]*\) Tbits.*/\1/p")

unittest/reliable_text_fade.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ snr=$2
88
min_text_packets=$3
99
clip=$4
1010
build_folder=$5
11-
fade_dir=${build_folder}/../unittest
11+
fading_dir=${build_folder}/../unittest
1212
rx=$build_folder/freedv_rx
1313
tx=$build_folder/freedv_tx
1414

@@ -18,7 +18,7 @@ else
1818
clip_args=
1919
fi
2020

21-
$tx $mode ../raw/ve9qrp.raw - --reliabletext AB1CDEF $clip_args | $build_folder/cohpsk_ch - - $snr --mpp --Fs 8000 -f -5 --raw_dir $fade_dir > $results/reliable_fade.raw
21+
$tx $mode ../raw/ve9qrp.raw - --reliabletext AB1CDEF $clip_args | $build_folder/cohpsk_ch - - $snr --mpp --Fs 8000 -f -5 --fading_dir $fading_dir > $results/reliable_fade.raw
2222
$rx $mode $results/reliable_fade.raw /dev/null --txtrx $results/reliable_fade.txt --reliabletext
2323
if [ `cat $results/reliable_fade.txt | wc -l` -ge $min_text_packets ]; then
2424
exit 0

0 commit comments

Comments
 (0)