From ccfd83c27afdeb5b1da37de9e9f60999f27b2db4 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 13 Jul 2023 09:53:48 +0930 Subject: removed some unused fm & fmmsk code --- src/CMakeLists.txt | 12 ---- src/fm_demod.c | 115 -------------------------------------- src/fmfsk_demod.c | 150 -------------------------------------------------- src/fmfsk_mod.c | 104 ---------------------------------- src/fsk_mod_ext_vco.c | 143 ----------------------------------------------- 5 files changed, 524 deletions(-) delete mode 100644 src/fm_demod.c delete mode 100644 src/fmfsk_demod.c delete mode 100644 src/fmfsk_mod.c delete mode 100644 src/fsk_mod_ext_vco.c (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c7cabc..25081a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -321,9 +321,6 @@ target_link_libraries(freedv_mixed_rx codec2) add_executable(fsk_mod fsk_mod.c) target_link_libraries(fsk_mod codec2) -add_executable(fsk_mod_ext_vco fsk_mod_ext_vco.c) -target_link_libraries(fsk_mod_ext_vco m) - add_executable(fsk_demod fsk_demod.c modem_probe.c octave.c) target_link_libraries(fsk_demod codec2) @@ -339,9 +336,6 @@ target_link_libraries(framer) add_executable(deframer deframer.c) target_link_libraries(deframer) -add_executable(fm_demod fm_demod.c fm.c) -target_link_libraries(fm_demod m) - add_executable(cohpsk_mod cohpsk_mod.c) target_link_libraries(cohpsk_mod codec2) @@ -357,12 +351,6 @@ target_link_libraries(ofdm_mod codec2) add_executable(ofdm_demod ofdm_demod.c octave.c) target_link_libraries(ofdm_demod codec2) -add_executable(fmfsk_mod fmfsk_mod.c) -target_link_libraries(fmfsk_mod codec2) - -add_executable(fmfsk_demod fmfsk_demod.c modem_probe.c octave.c) -target_link_libraries(fmfsk_demod codec2) - add_executable(vhf_deframe_c2 vhf_deframe_c2.c) target_link_libraries(vhf_deframe_c2 codec2) diff --git a/src/fm_demod.c b/src/fm_demod.c deleted file mode 100644 index bf667d1..0000000 --- a/src/fm_demod.c +++ /dev/null @@ -1,115 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fm_demod.c - AUTHOR......: David Rowe - DATE CREATED: Feb 24 2015 - - Given an input raw file (44.4 kHz, 16 bit shorts) with a FM signal centered - 11.1 kHz, outputs a file of demodulated audio samples. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2015 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. This program is - distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include - -#include "codec2_fm.h" -#include "octave.h" - -#define N 160 - -#define TEST_MOD_COMP - -int main(int argc, char *argv[]) -{ - FILE *fin, *fout; - struct FM *fm; - short buf[N*2]; - float rx[N]; -#if defined(TEST_MODE) && !defined(TEST_MODE_COMP) - float rx_out[N]; -#endif - COMP out_comp[N]; - int i; - - if (argc < 2) { - printf("usage: %s InputFMRawFile OutputSpeechRawFile\n", argv[0]); - printf("e.g %s fm.raw fm_demodulated.raw\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - fm = fm_create(N); - fm->Fs = 48000.0; - fm->fm_max = 3000.0; - fm->fd = 5000.0; - fm->fc = 0; - - while(fread(buf, sizeof(short), N, fin) == N) { - for(i=0; i. -*/ - -#include -#include -#include -#include "fmfsk.h" -#include "modem_stats.h" -#define MODEMPROBE_ENABLE -#include "modem_probe.h" -#include "codec2_fdmdv.h" - -int main(int argc,char *argv[]){ - struct FMFSK *fmfsk; - int Fs,Rb; - struct MODEM_STATS stats; - float loop_time; - int enable_stats = 0; - int stats_ctr = 0; - int stats_loop = 0; - FILE *fin,*fout; - uint8_t *bitbuf; - int16_t *rawbuf; - float *modbuf; - int i,j,t; - - if(argc<4){ - fprintf(stderr,"usage: %s SampleFreq BitRate InputModemRawFile OutputOneBitPerCharFile [S]\n",argv[0]); - exit(1); - } - - /* Extract parameters */ - Fs = atoi(argv[1]); - Rb = atoi(argv[2]); - - /* Open files */ - if(strcmp(argv[3],"-")==0){ - fin = stdin; - }else{ - fin = fopen(argv[3],"r"); - } - - if(strcmp(argv[4],"-")==0){ - fout = stdout; - }else{ - fout = fopen(argv[4],"w"); - } - - /* set up FSK */ - fmfsk = fmfsk_create(Fs,Rb); - - if(argc>5){ - if(strcmp(argv[5],"S")==0){ - enable_stats = 1; - loop_time = ((float)fmfsk_nin(fmfsk))/((float)Fs); - stats_loop = (int)(.125/loop_time); - stats_ctr = 0; - } - } - - if(fin==NULL || fout==NULL || fmfsk==NULL){ - fprintf(stderr,"Couldn't open test vector files\n"); - exit(1); - } - - /* allocate buffers for processing */ - bitbuf = (uint8_t*)malloc(sizeof(uint8_t)*fmfsk->nbit); - rawbuf = (int16_t*)malloc(sizeof(int16_t)*(fmfsk->N+fmfsk->Ts*2)); - modbuf = (float*)malloc(sizeof(float)*(fmfsk->N+fmfsk->Ts*2)); - - /* Demodulate! */ - while( fread(rawbuf,sizeof(int16_t),fmfsk_nin(fmfsk),fin) == fmfsk_nin(fmfsk) ){ - for(i=0;inbit;i++){ - t = (int)bitbuf[i]; - modem_probe_samp_i("t_d_bitout",&t,1); - } - - fwrite(bitbuf,sizeof(uint8_t),fmfsk->nbit,fout); - - if(enable_stats && stats_ctr <= 0){ - fmfsk_get_demod_stats(fmfsk,&stats); - fprintf(stderr,"{\"EbNodB\": %2.2f,\t\"ppm\": %d,",stats.snr_est,(int)stats.clock_offset); - fprintf(stderr,"\t\"f1_est\":%.1f,\t\"f2_est\":%.1f",0.0,0.0); - fprintf(stderr,",\t\"eye_diagram\":["); - for(i=0;i. -*/ - -#include -#include -#include -#include "fmfsk.h" -#include "codec2_fdmdv.h" - -int main(int argc,char *argv[]){ - struct FMFSK *fmfsk; - int Fs,Rb; - int i; - FILE *fin,*fout; - uint8_t *bitbuf; - int16_t *rawbuf; - float *modbuf; - - if(argc<4){ - fprintf(stderr,"usage: %s SampleFreq BitRate InputOneBitPerCharFile OutputModRawFile\n",argv[0]); - exit(1); - } - - /* Extract parameters */ - Fs = atoi(argv[1]); - Rb = atoi(argv[2]); - - if(strcmp(argv[3],"-")==0){ - fin = stdin; - }else{ - fin = fopen(argv[3],"r"); - } - - if(strcmp(argv[4],"-")==0){ - fout = stdout; - }else{ - fout = fopen(argv[4],"w"); - } - - - /* set up FMFSK */ - fmfsk = fmfsk_create(Fs,Rb); - - if(fin==NULL || fout==NULL || fmfsk==NULL){ - fprintf(stderr,"Couldn't open test vector files\n"); - exit(1); - } - - /* allocate buffers for processing */ - bitbuf = (uint8_t*)malloc(sizeof(uint8_t)*fmfsk->nbit); - rawbuf = (int16_t*)malloc(sizeof(int16_t)*fmfsk->N); - modbuf = (float*)malloc(sizeof(float)*fmfsk->N); - - /* Modulate! */ - while( fread(bitbuf,sizeof(uint8_t),fmfsk->nbit,fin) == fmfsk->nbit ){ - fmfsk_mod(fmfsk,modbuf,bitbuf); - for(i=0; iN; i++){ - rawbuf[i] = (int16_t)(modbuf[i]*(float)FDMDV_SCALE); - } - fwrite(rawbuf,sizeof(int16_t),fmfsk->N,fout); - - if(fout == stdin){ - fflush(fout); - } - } - - free(modbuf); - free(rawbuf); - free(bitbuf); - - fmfsk_destroy(fmfsk); - - fclose(fin); - fclose(fout); - - exit(0); -} diff --git a/src/fsk_mod_ext_vco.c b/src/fsk_mod_ext_vco.c deleted file mode 100644 index b4cfd6a..0000000 --- a/src/fsk_mod_ext_vco.c +++ /dev/null @@ -1,143 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fsk_mod_ext_vco.c - AUTHOR......: David Rowe - DATE CREATED: Feb 2018 - - Converts a stream of bits to mFSK raw file of "levels" suitable for - driving an external VCO, e.g. legacy FM transmitter in data mode. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2018 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. This program is - distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include - -#define OVERSAMPLE 100 - -int main(int argc,char *argv[]){ - int os, m, log2m, i, bit_i, sym, legacy_mode, rpitx_mode; - float d; - double shiftHz, symbolRateHz; - uint32_t time_sample; - FILE *fin,*fout; - - if(argc<5){ - fprintf(stderr, "usage: %s InputOneBitPerCharFile OutputVcoRawFile MbitsPerFSKsymbol\n",argv[0]); - fprintf(stderr, "[--legacy OutputSamplesPerSymbol deviationPerlevel]\n"); - fprintf(stderr, "[--rpitx ShiftHz SymbolRateHz\n]"); - exit(1); - } - - /* Extract parameters */ - - if (strcmp(argv[1],"-")==0){ - fin = stdin; - } else { - fin = fopen(argv[1],"r"); - } - - if (strcmp(argv[2],"-")==0){ - fout = stdout; - } else { - fout = fopen(argv[2],"w"); - } - - m = atoi(argv[3]); log2m = log2(m); - printf("log2m: %d\n", log2m); - - legacy_mode = rpitx_mode = os = 0; - if (!strcmp(argv[4],"--legacy")) { - os = atoi(argv[5]); - d = atof(argv[6]); - legacy_mode = 1; - } - if (!strcmp(argv[4],"--rpitx")) { - shiftHz = atof(argv[5]); - symbolRateHz = atof(argv[6]); - rpitx_mode = 1; - time_sample = 1E9/symbolRateHz; - fprintf(stderr, "time_sample: %d\n", time_sample); - } - - assert(legacy_mode || rpitx_mode); - fprintf(stderr, "legacy_mode: %d rpitx_mode: %d\n", legacy_mode, rpitx_mode); - - uint8_t tx_bits[log2m]; - int16_t rawbuf[os]; - - /* Modulate m bits to levels to drive external VCO */ - - while( fread(tx_bits, sizeof(uint8_t), log2m, fin) == log2m ){ - - /* generate the symbol number from the bit stream, - e.g. 0,1 for 2FSK, 0,1,2,3 for 4FSK */ - - sym = bit_i = 0; - for( i=m; i>>=1; ){ - //fprintf(stderr, "tx_bits[%d] = %d\n", i, tx_bits[bit_i]); - uint8_t bit = tx_bits[bit_i]; - bit = (bit==1)?1:0; - sym = (sym<<1)|bit; - bit_i++; - } - //fprintf(stderr, "sym = %d\n", sym); - - if (legacy_mode) { - /* map 'sym' to VCO drive signal symmetrically about 0, - separate tones by constant "d" */ - /* 2 FSK -d/2, +d/2 */ - /* 4 FSK -3*d/2, -d/2, +d/2, 3*d/2 */ - - /* note: drive is inverted, a higher tone drives VCO voltage lower */ - - float symf = sym; - float level = d*(((float)m-1)*0.5 - symf); - assert(level <= 32767.0); - assert(level >= -32768.0); - short level_short = (short)level; - //fprintf(stderr, "level = %f level_short = %d\n\n", level, level_short); - for(i=0; i