aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrowe67 <[email protected]>2023-07-13 09:53:48 +0930
committerDavid Rowe <[email protected]>2023-07-13 09:53:48 +0930
commitccfd83c27afdeb5b1da37de9e9f60999f27b2db4 (patch)
treeb7c736695c6d3e6fda4ffc84ab7a52e9f6424b2d /src
parent3cd3a9f82068bea3a37e4efe0ee3752ecb044cce (diff)
removed some unused fm & fmmsk code
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt12
-rw-r--r--src/fm_demod.c115
-rw-r--r--src/fmfsk_demod.c150
-rw-r--r--src/fmfsk_mod.c104
-rw-r--r--src/fsk_mod_ext_vco.c143
5 files changed, 0 insertions, 524 deletions
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 <http://www.gnu.org/licenses/>.
-*/
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <errno.h>
-
-#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<N; i++) {
- rx[i] = ((float)buf[i])/16384;
- }
-#ifdef TEST_MOD
- fm_mod(fm, rx, rx_out);
-#else
-#ifdef TEST_MOD_COMP
- fm_mod_comp(fm, rx, out_comp);
-#else
- fm_demod(fm, rx_out, rx);
-#endif
-#endif
-
-
-#ifdef TEST_MOD_COMP
- for(i=0; i<N; i++) {
- buf[i*2 ] = 16384*out_comp[i].real;
- buf[1+(i*2)] = 16384*out_comp[i].imag;
- }
- fwrite(buf, sizeof(short), N*2, fout);
-#else
- for(i=0; i<N; i++) {
- buf[i] = 16384*rx_out[i];
- }
- fwrite(buf, sizeof(short), N, fout);
-#endif
- }
-
- fm_destroy(fm);
- fclose(fin);
- fclose(fout);
-
- return 0;
-}
diff --git a/src/fmfsk_demod.c b/src/fmfsk_demod.c
deleted file mode 100644
index 5b12fc1..0000000
--- a/src/fmfsk_demod.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*---------------------------------------------------------------------------*\
-
- FILE........: fsk_demod.c
- AUTHOR......: Brady O'Brien
- DATE CREATED: 8 January 2016
-
- C test driver for fsk_demod in fsk.c. Reads in a stream of 32 bit cpu endian
- floats and writes out the detected bits
-
-
-\*---------------------------------------------------------------------------*/
-
-/*
- Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#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;i<fmfsk_nin(fmfsk);i++){
- modbuf[i] = ((float)rawbuf[i])/FDMDV_SCALE;
- }
-
- modem_probe_samp_f("t_d_sampin",modbuf,fmfsk_nin(fmfsk));
- fmfsk_demod(fmfsk,bitbuf,modbuf);
-
- for(i=0;i<fmfsk->nbit;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<stats.neyetr;i++){
- fprintf(stderr,"[");
- for(j=0;j<stats.neyesamp;j++){
- fprintf(stderr,"%f",stats.rx_eye[i][j]);
- if(j<stats.neyesamp-1) fprintf(stderr,",");
- }
- fprintf(stderr,"]");
- if(i<stats.neyetr-1) fprintf(stderr,",");
- }
-
- fprintf(stderr,"]}\n");
- stats_ctr = stats_loop;
- }
- stats_ctr--;
-
- if (fout == stdin) {
- fflush(fout);
- }
- }
-
- modem_probe_close();
-
- free(modbuf);
- free(rawbuf);
- free(bitbuf);
-
- fclose(fin);
- fclose(fout);
- fmfsk_destroy(fmfsk);
-
- exit(0);
-}
-
diff --git a/src/fmfsk_mod.c b/src/fmfsk_mod.c
deleted file mode 100644
index f2826eb..0000000
--- a/src/fmfsk_mod.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*---------------------------------------------------------------------------*\
-
- FILE........: fmfsk_mod.c
- AUTHOR......: Brady O'Brien
- DATE CREATED: 7 February 2016
-
- C test driver for fmfsk_mod in fmfsk.c. Reads in a set of bits to modulate
- from a file, passed as a parameter, and writes modulated output to
- another file
-
-
-\*---------------------------------------------------------------------------*/
-
-/*
- Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#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; i<fmfsk->N; 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-#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<os; i++) {
- rawbuf[i] = level_short;
- }
- fwrite(rawbuf, sizeof(int16_t), os, fout);
- }
-
- if (rpitx_mode) {
- short frequencyHz;
- frequencyHz = shiftHz*(sym+1);
- fwrite(&frequencyHz, sizeof(short), 1, fout);
- }
-
- if(fout == stdout){
- fflush(fout);
- }
- }
-
- fclose(fin);
- fclose(fout);
-
- exit(0);
-}
-
-