aboutsummaryrefslogtreecommitdiff
path: root/octave/fdmdv_mod.m
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2025-07-25 10:17:14 +0300
committerMarin Ivanov <[email protected]>2026-01-18 20:09:26 +0200
commit0168586485e6310c598713c911b1dec5618d61a1 (patch)
tree6aabc2a12ef8fef70683f5389bea00f948015f77 /octave/fdmdv_mod.m
Initial commitHEADmaster
* codec2 cut-down version 1.2.0 * Remove codebook and generation of sources * remove c2dec c2enc binaries * prepare for emscripten
Diffstat (limited to 'octave/fdmdv_mod.m')
-rw-r--r--octave/fdmdv_mod.m34
1 files changed, 34 insertions, 0 deletions
diff --git a/octave/fdmdv_mod.m b/octave/fdmdv_mod.m
new file mode 100644
index 0000000..3530cfe
--- /dev/null
+++ b/octave/fdmdv_mod.m
@@ -0,0 +1,34 @@
+% fdmdv_mod.m
+%
+% Modulator function for FDMDV modem, uses test frames as input and
+% outputs a raw file of 16 bit shorts at a sample rate of 8 kHz.
+%
+% Copyright David Rowe 2012
+% This program is distributed under the terms of the GNU General Public License
+% Version 2
+%
+
+function tx_fdm = fdmdv_mod(rawfilename, nbits)
+
+ fdmdv; % include modem code
+ f = fdmdv_init;
+ Nc = f.Nc; Nb = f.Nb;
+
+ frames = floor(nbits/(Nc*Nb))
+ tx_fdm = [];
+ gain = 1000; % Scale up to 16 bit shorts
+ prev_tx_symbols = ones(Nc+1,1); prev_tx_symbols(Nc+1) = 2;
+
+ for i=1:frames
+ [tx_bits f] = get_test_bits(f,Nc*Nb);
+ [tx_symbols f] = bits_to_psk(f,prev_tx_symbols, tx_bits);
+ prev_tx_symbols = tx_symbols;
+ [tx_baseband f] = tx_filter(f, tx_symbols);
+ tx_fdm = [tx_fdm real(fdm_upconvert(f, tx_baseband))];
+ end
+
+ tx_fdm *= gain;
+ fout = fopen(rawfilename,"wb");
+ fwrite(fout, tx_fdm, "short");
+ fclose(fout);
+endfunction