2
0

tget_spec.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. % tget-spec.m
  2. %
  3. % Used in conjunction with src/fdmdv_demod to test the
  4. % fdmdv_get_rx_spectrum() function.
  5. %
  6. % codec2-dev/src$ ./fdmdv_demod fdmdv_mod.raw tmp.c2 dump.txt
  7. % octave:3> tget_spec("../src/dump.txt")
  8. %
  9. % Copyright David Rowe 2012
  10. % This program is distributed under the terms of the GNU General Public License
  11. % Version 2
  12. %
  13. function tfft_log(dumpfilename)
  14. load(dumpfilename);
  15. [rows cols] = size(rx_spec_log_c);
  16. Fs = 8000; low_freq = 0; high_freq = 2500;
  17. res = (Fs/2)/cols;
  18. st_bin = low_freq/res + 1;
  19. en_bin = high_freq/res;
  20. xaxis = (st_bin:en_bin)*res;
  21. f_start = 2; f_end = 100;
  22. beta = 0.1;
  23. av = zeros(f_end, en_bin-st_bin+1);
  24. for r=f_start:f_end
  25. x = (1-beta)*av(r-1,:) + beta*rx_spec_log_c(r,st_bin:en_bin);
  26. av(r,:) = x;
  27. end
  28. % spectrogram (waterfall)
  29. figure(1)
  30. clf;
  31. imagesc(av,[-40 0]);
  32. % animated spectrum display
  33. figure(2)
  34. clf;
  35. for r=f_start:f_end
  36. plot(xaxis, av(r,:))
  37. axis([ low_freq high_freq -40 0])
  38. sleep(0.1)
  39. end
  40. endfunction