fdmdv_mod.m 849 B

1234567891011121314151617181920212223242526272829303132
  1. % fdmdv_mod.m
  2. %
  3. % Modulator function for FDMDV modem, uses test frames as input and
  4. % outputs a raw file of 16 bit shorts at a sample rate of 8 kHz.
  5. %
  6. % Copyright David Rowe 2012
  7. % This program is distributed under the terms of the GNU General Public License
  8. % Version 2
  9. %
  10. function tx_fdm = fdmdv_mod(rawfilename, nbits)
  11. fdmdv; % include modem code
  12. frames = floor(nbits/(Nc*Nb))
  13. tx_fdm = [];
  14. gain = 1000; % Scale up to 16 bit shorts
  15. prev_tx_symbols = ones(Nc+1,1);
  16. for i=1:frames
  17. tx_bits = get_test_bits(Nc*Nb);
  18. tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits,'dqpsk');
  19. prev_tx_symbols = tx_symbols;
  20. tx_baseband = tx_filter(tx_symbols);
  21. tx_fdm = [tx_fdm real(fdm_upconvert(tx_baseband))];
  22. end
  23. tx_fdm *= gain;
  24. fout = fopen(rawfilename,"wb");
  25. fwrite(fout, tx_fdm, "short");
  26. fclose(fout);
  27. endfunction