├── .gitignore ├── COPYRIGHT ├── LICENSE ├── README.md ├── configs ├── WSJT-X-example.ini ├── fldigi_def_example.xml └── gqrx-example-b210.conf ├── docs └── images │ ├── overview.jpg │ ├── overview2.jpg │ └── thor22-rtty45-psk125r-3.jpg ├── fldigi-noise-sdr ├── Makefile └── src │ ├── fldigi-noise-sdr │ ├── AndFlmsg_Fldigi_Interface.cxx │ ├── include │ │ └── AndFlmsg_Fldigi_Interface.h │ └── main.cxx │ ├── fldigi │ ├── contestia │ │ └── contestia.cxx │ ├── cw_rtty │ │ ├── cw.cxx │ │ ├── morse.cxx │ │ └── rtty.cxx │ ├── dominoex │ │ ├── dominoex.cxx │ │ └── dominovar.cxx │ ├── fft │ │ └── fft.cxx │ ├── filters │ │ ├── fftfilt.cxx │ │ ├── filters.cxx │ │ └── viterbi.cxx │ ├── include │ │ ├── ascii.h │ │ ├── complex.h │ │ ├── configuration.h │ │ ├── contestia.h │ │ ├── cw.h │ │ ├── debug.h │ │ ├── dominoex.h │ │ ├── dominovar.h │ │ ├── dsp.h │ │ ├── fft.h │ │ ├── fftfilt.h │ │ ├── filters.h │ │ ├── globals.h │ │ ├── interleave.h │ │ ├── jalocha │ │ │ ├── pj_cmpx.h │ │ │ ├── pj_fft.h │ │ │ ├── pj_fht.h │ │ │ ├── pj_fifo.h │ │ │ ├── pj_gray.h │ │ │ ├── pj_lowpass3.h │ │ │ ├── pj_mfsk.h │ │ │ └── pj_struc.h │ │ ├── lora.h │ │ ├── mfsk.h │ │ ├── mfskvaricode.h │ │ ├── misc.h │ │ ├── modem.h │ │ ├── morse.h │ │ ├── mt63.h │ │ ├── mt63base.h │ │ ├── olivia.h │ │ ├── psk.h │ │ ├── pskcoeff.h │ │ ├── pskrep.h │ │ ├── pskvaricode.h │ │ ├── rsid.h │ │ ├── rtty.h │ │ ├── thor.h │ │ ├── thorvaricode.h │ │ ├── util.h │ │ └── viterbi.h │ ├── libsamplerate │ │ ├── common.h │ │ ├── config.h │ │ ├── fastest_coeffs.h │ │ ├── float_cast.h │ │ ├── high_qual_coeffs.h │ │ ├── mid_qual_coeffs.h │ │ ├── samplerate.c │ │ ├── samplerate.h │ │ ├── src_linear.c │ │ ├── src_sinc.c │ │ └── src_zoh.c │ ├── lora │ │ └── lora.cxx │ ├── mfsk │ │ ├── interleave.cxx │ │ ├── mfsk.cxx │ │ └── mfskvaricode.cxx │ ├── misc │ │ ├── configuration.cxx │ │ ├── misc.cxx │ │ └── util.cxx │ ├── modem.cxx │ ├── mt63 │ │ ├── alias_1k.dat │ │ ├── alias_2k.dat │ │ ├── alias_k5.dat │ │ ├── dsp.cxx │ │ ├── morse.dat │ │ ├── mt63.cxx │ │ ├── mt63base.cxx │ │ ├── mt63intl.dat │ │ └── symbol.dat │ ├── olivia │ │ └── olivia.cxx │ ├── psk │ │ ├── psk.cxx │ │ ├── pskcoeff.cxx │ │ └── pskvaricode.cxx │ ├── rsid │ │ └── rsid.cxx │ └── thor │ │ ├── thor.cxx │ │ └── thorvaricode.cxx │ └── libion │ ├── chipset.cxx │ ├── include │ └── ion │ │ └── ion.h │ ├── ion.c │ └── kernel-headers │ └── linux │ └── ion.h ├── gnss ├── glonass │ ├── glonass-normal │ │ ├── generate-example.sh │ │ ├── gnss-sdr-1.5M.conf │ │ ├── gnss-sdr.conf │ │ ├── receive-1.5M.sh │ │ ├── receive.sh │ │ └── rx.grc │ ├── glonass-sim.py │ └── glonass-slow-10 │ │ ├── generate-slow-10-example.sh │ │ ├── gnss-sdr.conf │ │ ├── receive.sh │ │ └── rx.grc └── gps │ ├── generate-slow-100-example.sh │ ├── gnss-sdr.conf │ ├── gps-sim-slow-100.py │ ├── receive.sh │ └── rx.grc ├── gnuradio └── misc │ └── generic.grc ├── offline-noise-sdr ├── generate │ └── rf-pwm.py └── transmit │ ├── Makefile │ └── src │ ├── libion │ ├── chipset.cxx │ ├── include │ │ └── ion │ │ │ └── ion.h │ ├── ion.c │ └── kernel-headers │ │ └── linux │ │ └── ion.h │ └── noise-sdr │ └── main.cxx ├── scripts ├── data │ ├── buffer.txt │ ├── ft4-turing-2020-08-12-log.csv │ └── rfpwm.txt ├── fig12.py ├── fig15.py └── fig3.py └── vagrant ├── Vagrantfile └── bootstrap.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Traces 35 | vagrant/traces 36 | vagrant/rfpwm 37 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (C) EURECOM 2 | Copyright (C) Giovanni Camurati, Aurélien Francillon 3 | 4 | This screaming_channels repository contains what is necessary 5 | to reproduce the results of the Noise-SDR project. 6 | 7 | Certain files in this project may have specific licenses or copyright 8 | restrictions, as this project uses multiple open-source projects. 9 | Files in this project without any specific license can be assumed 10 | to follow the following general clause: 11 | 12 | screaming_channels is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | Noise-SDR is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with screaming_channels. If not, see . 24 | -------------------------------------------------------------------------------- /configs/gqrx-example-b210.conf: -------------------------------------------------------------------------------- 1 | [General] 2 | configversion=2 3 | crashed=true 4 | 5 | [audio] 6 | gain=-200 7 | pandapter_min_db=0 8 | rec_dir= 9 | udp_host=localhost 10 | udp_port=65535 11 | waterfall_min_db=0 12 | 13 | [fft] 14 | averaging=50 15 | pandapter_min_db=0 16 | split=50 17 | waterfall_min_db=0 18 | 19 | [gui] 20 | fctl_reset_digits=false 21 | geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\0\0\0\0\x3\xb5\0\0\x2W\0\0\0\0\0\0\0\0\0\0\x3\xb5\0\0\x2W\0\0\0\0\0\0\0\0\x6@) 22 | state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\0\0\0\0\0\0\xfc\x2\0\0\0\x2\xfc\0\0\0\0\xff\xff\xff\xff\0\0\x1j\0\b\0\x1a\xfa\0\0\0\x1\x2\0\0\0\x3\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0I\0n\0p\0u\0t\0\x43\0t\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xf0\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0R\0x\0O\0p\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1O\0\a\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0\x46\0\x66\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\a\xff\xff\xfc\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\xff\xff\xff\xfa\0\0\0\0\x2\0\0\0\x2\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0\x41\0u\0\x64\0i\0o\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0R\0\x44\0S\0\0\0\0\0\xff\xff\xff\xff\0\0\0h\0\xff\xff\xff\0\0\0\x3\0\0\0\0\0\0\0\0\xfc\x1\0\0\0\x1\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\0\0\0\0\0\xff\xff\xff\xff\0\0\x1\x42\0\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\x2\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) 23 | 24 | [input] 25 | antenna=TX/RX 26 | device="name=MyB210,product=B210,serial=3189F57,type=b200,uhd" 27 | frequency=400004900 28 | gains=@Variant(\0\0\0\b\0\0\0\x1\0\0\0\x6\0P\0G\0\x41\0\0\0\x2\0\0\x2\xc1) 29 | hwagc=true 30 | sample_rate=80000 31 | 32 | [receiver] 33 | demod=7 34 | filter_high_cut=1900 35 | filter_low_cut=100 36 | offset=4900 37 | 38 | [remote_control] 39 | allowed_hosts=::ffff:127.0.0.1 40 | -------------------------------------------------------------------------------- /docs/images/overview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eurecom-s3/noise-sdr/06e12a0baa35f3e0defc2727516706c97dd77419/docs/images/overview.jpg -------------------------------------------------------------------------------- /docs/images/overview2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eurecom-s3/noise-sdr/06e12a0baa35f3e0defc2727516706c97dd77419/docs/images/overview2.jpg -------------------------------------------------------------------------------- /docs/images/thor22-rtty45-psk125r-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eurecom-s3/noise-sdr/06e12a0baa35f3e0defc2727516706c97dd77419/docs/images/thor22-rtty45-psk125r-3.jpg -------------------------------------------------------------------------------- /fldigi-noise-sdr/Makefile: -------------------------------------------------------------------------------- 1 | # Giovanni Camurati 2 | # NDK android-ndk-r21d for Arm-V7A and Arm-V8A 3 | # Clang 3.6.2 for x86 4 | # minggw-x64 for windows 5 | # toolchain-mips_34kc_gcc-5.3.0_musl-1.1.14 for MIPS 6 | # Makefile inpired from https://spin.atomicobject.com/2016/08/26/makefile-c-projects/ 7 | # and drammer https://github.com/vusec/drammer 8 | 9 | ARCH ?= v8 10 | OP ?= CIVAC 11 | DEBUG ?= false 12 | OS ?= linux 13 | 14 | ifeq ($(strip $(ARCH)),v8) 15 | 16 | TARGET_ARCH=aarch64-linux-android 17 | LEAKY_OP=-DLEAKY_OP_$(OP) 18 | API=21 19 | TOOLCHAIN=${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${TARGET_ARCH}${API}- 20 | SRC_DIRS=./src/fldigi-noise-sdr ./src/fldigi ./src/libion 21 | LDDFLAGS = -lstdc++ --static 22 | CC=${TOOLCHAIN}clang 23 | CXX=${TOOLCHAIN}clang++ 24 | LD=${TOOLCHAIN}llvm-link 25 | INSTALL=adb push $(BUILD_DIR)/$(TARGET_EXEC) /data/local/tmp/ 26 | 27 | else ifeq ($(strip $(ARCH)),v7) 28 | 29 | TARGET_ARCH=armv7a-linux-androideabi 30 | OP=ION 31 | LEAKY_OP=-DLEAKY_OP_$(OP) 32 | API=21 33 | TOOLCHAIN=${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${TARGET_ARCH}${API}- 34 | SRC_DIRS=./src/fldigi-noise-sdr ./src/fldigi ./src/libion 35 | LDDFLAGS = -lstdc++ --static 36 | CC=${TOOLCHAIN}clang 37 | CXX=${TOOLCHAIN}clang++ 38 | LD=${TOOLCHAIN}llvm-link 39 | INSTALL=adb push $(BUILD_DIR)/$(TARGET_EXEC) /data/local/tmp/ 40 | 41 | else ifeq ($(strip $(ARCH)),x86) 42 | 43 | ifeq ($(strip $(OS)),linux) 44 | OP=STREAM 45 | LEAKY_OP=-DLEAKY_OP_$(OP) 46 | TOOLCHAIN= 47 | SRC_DIRS=./src/fldigi-noise-sdr ./src/fldigi 48 | LDDFLAGS = -lstdc++ --static -lpthread 49 | CC=${TOOLCHAIN}clang 50 | CXX=${TOOLCHAIN}clang++ 51 | LD=${TOOLCHAIN}llvm-link 52 | INSTALL= 53 | else ifeq ($(strip $(OS)),windows) 54 | OP=STREAM 55 | LEAKY_OP=-DLEAKY_OP_$(OP) 56 | TOOLCHAIN= 57 | SRC_DIRS=./src/fldigi-noise-sdr ./src/fldigi 58 | LDDFLAGS = -lstdc++ --static -lpthread 59 | CC=x86_64-w64-mingw32-gcc-posix 60 | CXX=x86_64-w64-mingw32-g++-posix 61 | LD=x86_64-w64-mingw32-ld 62 | INSTALL= 63 | endif 64 | 65 | else ifeq ($(strip $(ARCH)),mips) 66 | 67 | TARGET_ARCH=mips-openwrt-linux 68 | #OP=CNT 69 | OP=CNT 70 | LEAKY_OP=-DLEAKY_OP_$(OP) 71 | SMALL=-DSMALL 72 | TOOLCHAIN=${TOOLCHAIN_MIPS}/bin/${TARGET_ARCH}- 73 | SRC_DIRS=./src/fldigi-noise-sdr ./src/fldigi 74 | LDDFLAGS = -lstdc++ -lgcc_pic --static 75 | CC=${TOOLCHAIN}gcc 76 | CXX=${TOOLCHAIN}g++ 77 | LD=${TOOLCHAIN}ld 78 | INSTALL=scp $(BUILD_DIR)/$(TARGET_EXEC) carambola:/home/carambola/ 79 | ARCHFLAGS=-march=mips32r2 80 | 81 | endif 82 | 83 | ifeq ($(strip $(OS)),windows) 84 | TARGET_EXEC=fldigi-noise-sdr-$(ARCH)-$(OP).exe 85 | else 86 | TARGET_EXEC=fldigi-noise-sdr-$(ARCH)-$(OP) 87 | endif 88 | 89 | BUILD_DIR ?= ./build 90 | 91 | SRCS := $(shell find $(SRC_DIRS) -name *.cxx -or -name *.c -or -name *.s) 92 | OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) 93 | DEPS := $(OBJS:.o=.d) 94 | 95 | INC_DIRS := $(shell find $(SRC_DIRS) -type d) 96 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) 97 | 98 | HAVE = -DHAVE_STRCASESTR -DHAVE_SETENV 99 | CFLAGS ?= -O3 -Wall $(ARCHFLAGS) $(HAVE) $(LEAKY_OP) $(SMALL) $(INC_FLAGS) -MMD -MP 100 | CXXFLAGS ?= -std=c++11 $(CFLAGS) 101 | 102 | ifeq ($(strip $(DEBUG)),true) 103 | CFLAGS += -ggdb3 104 | CXXFLAGS += -ggdb3 105 | endif 106 | 107 | # https://stackoverflow.com/questions/51602926/how-to-rebuild-when-the-recipe-has-changed 108 | ALLFLAGS=$(ARCH)$(OS)$(OP)$(API)$(CFLAGS)$(CXXFLAGS)$(ASFLAGS)$(LDDFLAGS) 109 | BUILT_MARKER := $(BUILD_DIR)/$(shell echo $(ALLFLAGS) | md5sum | head -c 32).built 110 | 111 | $(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) 112 | @echo $(INC_DIRS) 113 | $(CXX) $(OBJS) -o $@ $(LDDFLAGS) 114 | 115 | $(BUILT_MARKER): 116 | @echo $(BUILT_MARKER) 117 | @mkdir -p $(BUILD_DIR) 118 | @-rm -f $(BUILD_DIR)/*.built 119 | @touch $(BUILT_MARKER) 120 | 121 | # assembly 122 | $(BUILD_DIR)/%.s.o: %.s $(BUILT_MARKER) 123 | $(MKDIR_P) $(dir $@) 124 | $(AS) $(ASFLAGS) -c $< -o $@ 125 | 126 | # c source 127 | $(BUILD_DIR)/%.c.o: %.c $(BUILT_MARKER) 128 | $(MKDIR_P) $(dir $@) 129 | $(CC) $(CFLAGS) -c $< -o $@ 130 | 131 | # c++ source 132 | $(BUILD_DIR)/%.cxx.o: %.cxx $(BUILT_MARKER) 133 | $(MKDIR_P) $(dir $@) 134 | $(CXX) $(CXXFLAGS) -c $< -o $@ 135 | 136 | .PHONY: clean install 137 | 138 | install: $(BUILD_DIR)/$(TARGET_EXEC) $(BUILT_MARKER) 139 | $(INSTALL) 140 | #adb push $(BUILD_DIR)/$(TARGET_EXEC) /data/local/tmp/ 141 | 142 | clean: 143 | $(RM) -r $(BUILD_DIR) 144 | 145 | -include $(DEPS) 146 | 147 | MKDIR_P ?= mkdir -p 148 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi-noise-sdr/include/AndFlmsg_Fldigi_Interface.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDFLMSG_FLDIGI_INTERFACE_H 2 | #define ANDFLMSG_FLDIGI_INTERFACE_H 3 | 4 | 5 | #include "rsid.h" 6 | 7 | using std::string; 8 | 9 | extern modem *active_modem; 10 | 11 | extern void txModulate(double *buffer, int len); 12 | extern void put_rx_char(int receivedChar); 13 | extern void put_echo_char(unsigned int txedChar); 14 | extern int get_tx_char(); 15 | extern bool getNewAmplReady(); 16 | extern void updateWaterfallBuffer(double *processedFft); 17 | extern string getPreferenceS2(string preferenceString, string defaultValue); 18 | extern int getPreferenceI(string preferenceString, int defaultValue); 19 | extern double getPreferenceD(string preferenceString, double defaultValue); 20 | extern bool getPreferenceB(string preferenceString, bool defaultValue); 21 | extern void change_CModem(int newMode, double newFrequency, double wpm, 22 | double cwrisetime, int rtty_baud, bool rtty_shaped); 23 | extern void androidShowRxViewer(int picW, int picH); 24 | extern void androidSaveLastPicture(); 25 | extern void androidUpdateRxPic(int data, int pos); 26 | 27 | extern int modem_txInit(double frequency); 28 | extern int modem_createModem(int modemCode, double wpm, double cwrisetime, 29 | int rtty_baud, bool rtty_shaped); 30 | extern void modem_destroyModem(); 31 | extern int modem_createRsidModem(double wpm, double cwrisetime, int rtty_baud, 32 | bool rtty_shaped); 33 | extern void modem_destroyRsidModem(); 34 | extern void modem_txRSID(); 35 | extern int modem_txCProcess(signed char *buffer, int length); 36 | extern void RFPWM(bool forever, char *buffile, char *rfpwmfile); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/ascii.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // ascii.h -- ASCII table 3 | // 4 | // Copyright (C) 2006 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // gmfsk Copyright (C) 2001, 2002, 2003 10 | // Tomi Manninen (oh2bns@sral.fi) 11 | // 12 | // This file is part of fldigi. 13 | // 14 | // Fldigi is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // Fldigi is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with fldigi. If not, see . 26 | // ---------------------------------------------------------------------------- 27 | 28 | #ifndef ASCII_H 29 | #define ASCII_H 30 | 31 | extern const char *ascii[]; 32 | extern const char *ascii2[]; 33 | extern const char *ascii3[]; 34 | 35 | #define SOH 0x01 // SOH ascii character 36 | #define EOT 0x04 // EOT ascii character 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/complex.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // complex.h -- Complex arithmetic 3 | // 4 | // Copyright (C) 2006-2008 5 | // Dave Freese, W1HKJ 6 | // Copyright (C) 2008 7 | // Stelios Bounanos, M0GLD 8 | // 9 | // This file is part of fldigi. 10 | // 11 | // Fldigi is free software: you can redistribute it and/or modify 12 | // it under the terms of the GNU General Public License as published by 13 | // the Free Software Foundation, either version 3 of the License, or 14 | // (at your option) any later version. 15 | // 16 | // Fldigi is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU General Public License 22 | // along with fldigi. If not, see . 23 | // ---------------------------------------------------------------------------- 24 | 25 | #ifndef _COMPLEX_H 26 | #define _COMPLEX_H 27 | 28 | #define _USE_MATH_DEFINES 29 | #include 30 | 31 | class cmplx { 32 | public: 33 | double re; 34 | double im; 35 | cmplx(double r = 0.0, double i = 0.0) 36 | : re(r), im(i) { } 37 | 38 | double real() { return re; }; 39 | void real(double R) {re = R;}; 40 | double imag() { return im; }; 41 | void imag(double I) {im = I;}; 42 | 43 | // Z = X * Y 44 | cmplx& operator*=(const cmplx& y) { 45 | double temp = re * y.re - im * y.im; 46 | im = re * y.im + im * y.re; 47 | re = temp; 48 | return *this; 49 | } 50 | cmplx operator*(const cmplx& y) const { 51 | return cmplx(re * y.re - im * y.im, re * y.im + im * y.re); 52 | } 53 | 54 | // Z = X * y 55 | cmplx& operator*=(double y) { 56 | re *= y; 57 | im *= y; 58 | return *this; 59 | } 60 | cmplx operator*(double y) const { 61 | return cmplx(re * y, im * y); 62 | } 63 | 64 | // Z = X + Y 65 | cmplx& operator+=(const cmplx& y) { 66 | re += y.re; 67 | im += y.im; 68 | return *this; 69 | } 70 | cmplx operator+(const cmplx& y) const { 71 | return cmplx(re + y.re, im + y.im); 72 | } 73 | 74 | // Z = X - Y 75 | cmplx& operator-=(const cmplx& y) { 76 | re -= y.re; 77 | im -= y.im; 78 | return *this; 79 | } 80 | cmplx operator-(const cmplx& y) const { 81 | return cmplx(re - y.re, im - y.im); 82 | } 83 | 84 | // Z = X / Y 85 | cmplx& operator/=(const cmplx& y) { 86 | double temp, denom = y.re*y.re + y.im*y.im; 87 | if (denom == 0.0) denom = 1e-10; 88 | temp = (re * y.re + im * y.im) / denom; 89 | im = (im * y.re - re * y.im) / denom; 90 | re = temp; 91 | return *this; 92 | } 93 | cmplx operator/(const cmplx& y) const { 94 | double denom = y.re*y.re + y.im*y.im; 95 | if (denom == 0.0) denom = 1e-10; 96 | return cmplx((re * y.re + im * y.im) / denom, (im * y.re - re * y.im) / denom); 97 | } 98 | 99 | // Z = (cmplx conjugate of X) * Y 100 | // Z1 = x1 + jy1, or Z1 = |Z1|exp(jP1) 101 | // Z2 = x2 + jy2, or Z2 = |Z2|exp(jP2) 102 | // Z = (x1 - jy1) * (x2 + jy2) 103 | // or Z = |Z1|*|Z2| exp (j (P2 - P1)) 104 | cmplx& operator%=(const cmplx& y) { 105 | double temp = re * y.re + im * y.im; 106 | im = re * y.im - im * y.re; 107 | re = temp; 108 | return *this; 109 | } 110 | cmplx operator%(const cmplx& y) const { 111 | cmplx z; 112 | z.re = re * y.re + im * y.im; 113 | z.im = re * y.im - im * y.re; 114 | return z; 115 | } 116 | 117 | // n = |Z| * |Z| 118 | double norm() const { 119 | return (re * re + im * im); 120 | } 121 | 122 | // n = |Z| 123 | double mag() const { 124 | return sqrt(norm()); 125 | } 126 | 127 | // Z = x + jy 128 | // Z = |Z|exp(jP) 129 | // arg returns P 130 | double arg() const { 131 | return atan2(im, re); 132 | } 133 | 134 | }; 135 | 136 | inline cmplx cmac (const cmplx *a, const cmplx *b, int ptr, int len) { 137 | cmplx z; 138 | ptr %= len; 139 | for (int i = 0; i < len; i++) { 140 | z += a[i] * b[ptr]; 141 | ptr = (ptr + 1) % len; 142 | } 143 | return z; 144 | } 145 | 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/contestia.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // contestia.h 3 | // 4 | // Copyright (C) 2006-2010 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. 8 | // 9 | // Fldigi is free software: you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // Fldigi is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with fldigi. If not, see . 21 | // ---------------------------------------------------------------------------- 22 | 23 | #ifndef _CONTESTIA_H 24 | #define _CONTESTIA_H 25 | 26 | #include "modem.h" 27 | #include "jalocha/pj_mfsk.h" 28 | //Android 29 | //#include "sound.h" 30 | #include "complex.h" 31 | 32 | #define TONE_DURATION (SCBLOCKSIZE * 16) 33 | #define SR4 ((TONE_DURATION) / 4) 34 | 35 | class contestia : public modem { 36 | private: 37 | 38 | MFSK_Transmitter < double >*Tx; 39 | MFSK_Receiver < double >*Rx; 40 | 41 | double *txfbuffer; 42 | int txbufferlen; 43 | 44 | double phaseacc; 45 | cmplx prevsymbol; 46 | int preamble; 47 | unsigned int shreg; 48 | 49 | double np; 50 | double sp; 51 | double sigpwr; 52 | double noisepwr; 53 | 54 | int escape; 55 | int smargin; 56 | int sinteg; 57 | int tones; 58 | int bw; 59 | double tone_bw; 60 | 61 | int preamblesent; 62 | int postamblesent; 63 | double preamblephase; 64 | 65 | double txbasefreq; 66 | double tone_midfreq; 67 | double lastfreq; 68 | 69 | double ampshape[SR4]; 70 | double tonebuff[TONE_DURATION]; 71 | 72 | double nco(double freq); 73 | void send_tones(); 74 | 75 | public: 76 | //Android contestia(trx_mode omode = MODE_CONTESTIA); 77 | contestia(int omode = MODE_CONTESTIA); 78 | ~contestia(); 79 | void init(); 80 | void rx_init(); 81 | void rx_flush(); 82 | void tx_init(); 83 | void restart(); 84 | //Android int rx_process(const double *buf, int len); 85 | int rx_process(const short *buf, int len); 86 | int tx_process(); 87 | int unescape(int c); 88 | }; 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/debug.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // debug.h 3 | // 4 | // Copyright (C) 2008 5 | // Stelios Bounanos, M0GLD 6 | // 7 | // This file is part of fldigi. 8 | // 9 | // fldigi is free software; you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation; either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // fldigi is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with this program. If not, see . 21 | // ---------------------------------------------------------------------------- 22 | 23 | #ifndef _DEBUG_H_ 24 | #define _DEBUG_H_ 25 | 26 | #define DEBUG_PSKMAIL 1 27 | 28 | #include "util.h" 29 | 30 | class debug 31 | { 32 | public: 33 | enum level_e { 34 | QUIET_LEVEL, ERROR_LEVEL, WARN_LEVEL, INFO_LEVEL, 35 | VERBOSE_LEVEL, DEBUG_LEVEL, LOG_NLEVELS 36 | }; 37 | enum source_e { 38 | LOG_ARQCONTROL = 1 << 0, LOG_AUDIO = 1 << 1, LOG_MODEM = 1 << 2, 39 | LOG_RIGCONTROL = 1 << 3, LOG_RPC = 1 << 4, LOG_SPOTTER = 1 << 5, 40 | LOG_OTHER = 1 << 6 41 | }; 42 | static void start(const char* filename); 43 | static void stop(void); 44 | static void log(level_e level, const char* func, const char* srcf, int line, 45 | const char* format, ...) format__(printf, 5, 6); 46 | static void elog(const char* func, const char* srcf, int line, const char* text); 47 | static void rotate_log(const char* filename); 48 | static void show(void); 49 | static level_e level; 50 | static uint32_t mask; 51 | private: 52 | static void sync_text(void*); 53 | debug(const char* filename); 54 | debug(const debug&); 55 | debug& operator=(const debug&); 56 | ~debug(); 57 | static debug* inst; 58 | }; 59 | 60 | #define LOG(level__, source__, ...) \ 61 | do { \ 62 | if (level__ <= debug::level && source__ & debug::mask) \ 63 | debug::log(level__, __func__, __FILE__, __LINE__, __VA_ARGS__); \ 64 | } while (0) 65 | 66 | #define LOG_DEBUG(...) LOG(debug::DEBUG_LEVEL, log_source_, __VA_ARGS__) 67 | #define LOG_VERBOSE(...) LOG(debug::VERBOSE_LEVEL, log_source_, __VA_ARGS__) 68 | #define LOG_INFO(...) LOG(debug::INFO_LEVEL, log_source_, __VA_ARGS__) 69 | #define LOG_WARN(...) LOG(debug::WARN_LEVEL, log_source_, __VA_ARGS__) 70 | #define LOG_ERROR(...) LOG(debug::ERROR_LEVEL, log_source_, __VA_ARGS__) 71 | 72 | #define LOG_PERROR(msg__) \ 73 | do { \ 74 | if (debug::ERROR_LEVEL <= debug::level && log_source_ & debug::mask) \ 75 | debug::elog(__func__, __FILE__, __LINE__, msg__); \ 76 | } while (0) 77 | 78 | unused__ static uint32_t log_source_ = debug::LOG_OTHER; 79 | #if defined(__GNUC__) && (__GNUC__ >= 3) 80 | # define LOG_FILE_SOURCE(source__) \ 81 | __attribute__((constructor)) \ 82 | static void log_set_source_(void) { log_source_ = source__; } 83 | #else 84 | # define LOG_FILE_SOURCE(source__) 85 | #endif 86 | 87 | #define LOG_SET_SOURCE(source__) log_source_ = source__ 88 | 89 | extern bool debug_pskmail; 90 | extern bool debug_audio; 91 | 92 | #endif // _DEBUG_H_ 93 | 94 | // Local Variables: 95 | // mode: c++ 96 | // c-file-style: "linux" 97 | // End: 98 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/dominoex.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // dominoex.h -- DominoEX modem 3 | // 4 | // Copyright (C) 2001, 2002, 2003 5 | // Tomi Manninen (oh2bns@sral.fi) 6 | // Copyright (C) 2006 7 | // Hamish Moffatt (hamish@debian.org) 8 | // Copyright (C) 2006 9 | // David Freese (w1hkj@w1hkj.com) 10 | // 11 | // Fldigi is free software: you can redistribute it and/or modify 12 | // it under the terms of the GNU General Public License as published by 13 | // the Free Software Foundation, either version 3 of the License, or 14 | // (at your option) any later version. 15 | // 16 | // Fldigi is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU General Public License 22 | // along with fldigi. If not, see . 23 | // ---------------------------------------------------------------------------- 24 | 25 | #ifndef _DOMINOEX_H 26 | #define _DOMINOEX_H 27 | 28 | #include 29 | 30 | #include "complex.h" 31 | #include "modem.h" 32 | #include "filters.h" 33 | #include "fftfilt.h" 34 | #include "dominovar.h" 35 | //Android #include "mbuffer.h" 36 | 37 | // NASA coefficients for viterbi encode/decode algorithms 38 | #define K 7 39 | #define POLY1 0x6d 40 | #define POLY2 0x4f 41 | 42 | //#include "mfskvaricode.h" 43 | #include "interleave.h" 44 | #include "viterbi.h" 45 | 46 | #define NUMTONES 18 47 | #define MAXFFTS 8 48 | #define BASEFREQ 1000.0 49 | #define FIRSTIF 1500.0 50 | 51 | #define SCOPESIZE 64 52 | 53 | struct domrxpipe { 54 | cmplx vector[MAXFFTS * NUMTONES * 6]; 55 | }; 56 | 57 | class dominoex : public modem { 58 | public: 59 | enum { 60 | TX_STATE_PREAMBLE, 61 | TX_STATE_START, 62 | TX_STATE_DATA, 63 | TX_STATE_END, 64 | TX_STATE_FLUSH 65 | }; 66 | protected: 67 | // common variables 68 | double phase[MAXFFTS + 1]; 69 | double txphase; 70 | int symlen; 71 | int doublespaced; 72 | double tonespacing; 73 | int counter; 74 | unsigned int twosym; 75 | int paths; 76 | int numbins; 77 | bool slowcpu; 78 | int basetone; 79 | int lotone; 80 | int hitone; 81 | int extones; 82 | 83 | // rx variables 84 | C_FIR_filter *hilbert; 85 | sfft *binsfft[MAXFFTS]; 86 | fftfilt *fft; 87 | Cmovavg *vidfilter[SCOPESIZE]; 88 | Cmovavg *syncfilter; 89 | 90 | domrxpipe *pipe; 91 | unsigned int pipeptr; 92 | //Android not yet mbuffer scopedata; 93 | //Android not yet mbuffer videodata; 94 | 95 | cmplx currvector; 96 | 97 | int currsymbol; 98 | int prev1symbol; 99 | int prev2symbol; 100 | 101 | double met1; 102 | double met2; 103 | double sig; 104 | double noise; 105 | double s2n; 106 | 107 | int synccounter; 108 | 109 | unsigned char symbolbuf[MAX_VARICODE_LEN]; 110 | int symcounter; 111 | 112 | int symbolbit; 113 | 114 | bool filter_reset; 115 | bool staticburst; 116 | bool outofrange; 117 | 118 | // tx variables 119 | int txstate; 120 | int txprevtone; 121 | unsigned int bitshreg; 122 | std::string strSecXmtText; 123 | 124 | // FEC variables 125 | viterbi *MuPskDec; 126 | interleave *MuPskRxinlv; 127 | encoder *MuPskEnc; 128 | interleave *MuPskTxinlv; 129 | int Mu_bitstate; 130 | unsigned char Mu_symbolpair[2]; 131 | unsigned int Mu_datashreg; 132 | int Mu_symcounter; 133 | 134 | private: 135 | cmplx mixer(int n, cmplx in); 136 | void recvchar(int c); 137 | void decodesymbol(); 138 | void decodeDomino(int c); 139 | int harddecode(); 140 | void update_syncscope(); 141 | void synchronize(); 142 | void afc(); 143 | void reset_afc(); 144 | void eval_s2n(); 145 | void sendtone(int tone, int duration); 146 | void sendsymbol(int sym); 147 | void sendchar(unsigned char c, int secondary); 148 | void sendidle(); 149 | void sendsecondary(); 150 | void flushtx(); 151 | int get_secondary_char(); 152 | void reset_filters(); 153 | // MultiPsk FEC scheme 154 | // Rx 155 | unsigned int MuPskPriSecChar(unsigned int c); 156 | void decodeMuPskSymbol(unsigned char symbol); 157 | void decodeMuPskEX(int c); 158 | // Tx 159 | unsigned char MuPskSec2Pri(int c); 160 | void sendMuPskEX(unsigned char c, int secondary); 161 | void MuPskClearbits(); 162 | void MuPskFlushTx(); 163 | void MuPsk_sec2pri_init(void); 164 | public: 165 | //Android 166 | //dominoex (trx_mode md); 167 | dominoex (int md); 168 | ~dominoex (); 169 | void init(); 170 | void rx_init(); 171 | //Android 172 | //void tx_init(SoundBase *sc); 173 | void tx_init(); 174 | void restart(); 175 | //Android 176 | //int rx_process(const double *buf, int len); 177 | int rx_process(const short *buf, int len); 178 | int tx_process(); 179 | }; 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/dominovar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * varicode.h -- DominoEX Varicode 3 | * 4 | * Copyright (C) 2001, 2002, 2003 5 | * Tomi Manninen (oh2bns@sral.fi) 6 | * 7 | * This file is part of fldigi. 8 | * 9 | * Fldigi is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * Fldigi is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with fldigi. If not, see . 21 | * 22 | */ 23 | 24 | #ifndef _DOMVARICODE_H 25 | #define _DOMVARICODE_H 26 | 27 | #define MAX_VARICODE_LEN 3 28 | 29 | extern unsigned char *dominoex_varienc(unsigned char c, int secondary); 30 | extern int dominoex_varidec(unsigned int symbol); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/fft.h: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Real Discrete Fourier Transform 3 | // dimension :one 4 | // data length :power of 2, must be larger than 4 5 | // decimation :frequency 6 | // radix :4, 2 7 | // data :inplace 8 | // classes: 9 | // Cfft: real discrete fourier transform class 10 | // functions: 11 | // Cfft::rdft : compute the forward real discrete fourier transform 12 | // Cfft::cdft : compute the forward complex discrete fourier transform 13 | // Cfft::fft : compute the forward real dft on a set of integer values 14 | // 15 | // This class is derived from the work of Takuya Ooura, who has kindly put his 16 | // fft algorithims in the public domain. Thank you Takuya Ooura! 17 | //=========================================================================== 18 | 19 | #ifndef FFT_H 20 | #define FFT_H 21 | 22 | #include "complex.h" 23 | 24 | enum fftPrefilter {FFT_NONE, FFT_HAMMING, FFT_HANNING, FFT_BLACKMAN, FFT_TRIANGULAR}; 25 | 26 | class Cfft { 27 | private: 28 | double xi; 29 | double *w; 30 | int *ip; 31 | double *fftwin; 32 | fftPrefilter wintype; 33 | int fftlen; 34 | int fftsiz; 35 | void makewt(); 36 | void makect(); 37 | void bitrv2(int n, int *ip, double *a); 38 | void bitrv2conj(int n, int *ip, double *a); 39 | void cftfsub(int n, double *a); 40 | void cftbsub(int n, double *a); 41 | void cftmdl(int n, int l, double *a); 42 | void cft1st(int n, double *a); 43 | void rftfsub(int n, double *a); 44 | void rftbsub(int n, double *a); 45 | 46 | public: 47 | Cfft(int n); 48 | ~Cfft(); 49 | void resize(int n); 50 | void cdft(double *a); 51 | //Android void cdft(complex *a) { cdft( (double *) a); } 52 | void cdft(cmplx *a) { cdft( (double *) a); } 53 | void icdft(double *a); 54 | //Android void icdft(complex *a) { icdft( (double *) a); } 55 | void icdft(cmplx *a) { icdft( (double *) a); } 56 | void sifft(short int *siData, double *out); 57 | //Android void sifft(short int *siData, complex *a) { sifft(siData, (double *) a); } 58 | void sifft(short int *siData, cmplx *a) { sifft(siData, (double *) a); } 59 | void rdft(double *a); 60 | //Android void rdft(complex *a) { rdft( (double *) a); } 61 | void rdft(cmplx *a) { rdft( (double *) a); } 62 | void irdft(double *a); 63 | //Android void irdft(complex *a) { irdft( (double *) a); } 64 | void irdft(cmplx *a) { irdft( (double *) a); } 65 | 66 | void setWindow(fftPrefilter pf); 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/fftfilt.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Copyright (C) 2014 3 | // David Freese, W1HKJ 4 | // 5 | // This file is part of fldigi 6 | // 7 | // fldigi is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // fldigi is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | // ---------------------------------------------------------------------------- 20 | 21 | #ifndef _FFTFILT_H 22 | #define _FFTFILT_H 23 | 24 | #include "complex.h" 25 | //Android #include "gfft.h" 26 | #include "fft.h" 27 | 28 | //---------------------------------------------------------------------- 29 | 30 | class fftfilt { 31 | enum {NONE, BLACKMAN, HAMMING, HANNING}; 32 | 33 | protected: 34 | int flen; 35 | int flen2; 36 | //Android g_fft *fft; 37 | Cfft *fft; 38 | //Android g_fft *ift; 39 | Cfft *ift; 40 | 41 | cmplx *ht; 42 | cmplx *filter; 43 | cmplx *timedata; 44 | cmplx *freqdata; 45 | cmplx *ovlbuf; 46 | cmplx *output; 47 | int inptr; 48 | int pass; 49 | int window; 50 | 51 | inline double fsinc(double fc, int i, int len) { 52 | return (i == len/2) ? 2.0 * fc: 53 | sin(2 * M_PI * fc * (i - len/2)) / (M_PI * (i - len/2)); 54 | } 55 | inline double _blackman(int i, int len) { 56 | return (0.42 - 57 | 0.50 * cos(2.0 * M_PI * i / len) + 58 | 0.08 * cos(4.0 * M_PI * i / len)); 59 | } 60 | void init_filter(); 61 | 62 | public: 63 | fftfilt(double f1, double f2, int len); 64 | fftfilt(double f, int len); 65 | ~fftfilt(); 66 | // f1 < f2 ==> bandpass 67 | // f1 > f2 ==> band reject 68 | void create_filter(double f1, double f2); 69 | void create_lpf(double f) { 70 | create_filter(0, f); 71 | } 72 | void create_hpf(double f) { 73 | create_filter(f, 0); 74 | } 75 | void rtty_filter(double); 76 | 77 | int run(const cmplx& in, cmplx **out); 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/filters.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // 3 | // filters.h -- Several Digital Filter classes used in fldigi 4 | // 5 | // Copyright (C) 2006-2008 6 | // Dave Freese, W1HKJ 7 | // 8 | // This file is part of fldigi. These filters are based on the 9 | // gmfsk design and the design notes given in 10 | // "Digital Signal Processing", A Practical Guid for Engineers and Scientists 11 | // by Steven W. Smith. 12 | // 13 | // Fldigi is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU General Public License as published by 15 | // the Free Software Foundation, either version 3 of the License, or 16 | // (at your option) any later version. 17 | // 18 | // Fldigi is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU General Public License 24 | // along with fldigi. If not, see . 25 | // ---------------------------------------------------------------------------- 26 | 27 | 28 | #ifndef _FILTER_H 29 | #define _FILTER_H 30 | 31 | #include "complex.h" 32 | 33 | //===================================================================== 34 | // FIR filters 35 | //===================================================================== 36 | 37 | class C_FIR_filter { 38 | #define FIRBufferLen 4096 39 | private: 40 | int length; 41 | int decimateratio; 42 | 43 | double *ifilter; 44 | double *qfilter; 45 | 46 | double ffreq; 47 | 48 | double ibuffer[FIRBufferLen]; 49 | double qbuffer[FIRBufferLen]; 50 | 51 | int pointer; 52 | int counter; 53 | 54 | cmplx fu; 55 | 56 | inline double sinc(double x) { 57 | if (fabs(x) < 1e-10) 58 | return 1.0; 59 | else 60 | return sin(M_PI * x) / (M_PI * x); 61 | } 62 | inline double cosc(double x) { 63 | if (fabs(x) < 1e-10) 64 | return 0.0; 65 | else 66 | return (1.0 - cos(M_PI * x)) / (M_PI * x); 67 | } 68 | inline double hamming(double x) { 69 | return 0.54 - 0.46 * cos(2 * M_PI * x); 70 | } 71 | inline double mac(const double *a, const double *b, unsigned int size) { 72 | double sum = 0.0; 73 | double sum2 = 0.0; 74 | double sum3 = 0.0; 75 | double sum4 = 0.0; 76 | // Reduces read-after-write dependencies : Each subsum does not wait for the others. 77 | // The CPU can therefore schedule each line independently. 78 | for (; size > 3; size -= 4, a += 4, b+=4) 79 | { 80 | sum += a[0] * b[0]; 81 | sum2 += a[1] * b[1]; 82 | sum3 += a[2] * b[2]; 83 | sum4 += a[3] * b[3]; 84 | } 85 | for (; size; --size) 86 | sum += (*a++) * (*b++); 87 | return sum + sum2 + sum3 + sum4 ; 88 | } 89 | 90 | protected: 91 | 92 | public: 93 | C_FIR_filter (); 94 | ~C_FIR_filter (); 95 | void init (int len, int dec, double *ifil, double *qfil); 96 | void init_lowpass (int len, int dec, double freq ); 97 | void init_bandpass (int len, int dec, double freq1, double freq2); 98 | void init_hilbert (int len, int dec); 99 | double *bp_FIR(int len, int hilbert, double f1, double f2); 100 | void dump(); 101 | int run (const cmplx &in, cmplx &out); 102 | int Irun (const double &in, double &out); 103 | int Qrun (const double &in, double &out); 104 | }; 105 | 106 | //===================================================================== 107 | // Moving average filter 108 | //===================================================================== 109 | 110 | class Cmovavg { 111 | #define MAXMOVAVG 2048 112 | private: 113 | double *in; 114 | double out; 115 | int len, pint; 116 | bool empty; 117 | public: 118 | Cmovavg(int filtlen); 119 | ~Cmovavg(); 120 | double run(double a); 121 | void setLength(int filtlen); 122 | void reset(); 123 | double value() { return out / (len > 0 ? len : 1); } 124 | }; 125 | 126 | 127 | //===================================================================== 128 | // Sliding FFT 129 | //===================================================================== 130 | 131 | class sfft { 132 | #define K1 0.99999999999L 133 | private: 134 | int fftlen; 135 | int first; 136 | int last; 137 | int ptr; 138 | struct vrot_bins_pair ; 139 | vrot_bins_pair * __restrict__ vrot_bins ; 140 | cmplx * __restrict__ delay; 141 | double k2; 142 | int count; 143 | public: 144 | sfft(int len, int first, int last); 145 | ~sfft(); 146 | bool is_stable(); 147 | void reset(); 148 | void run(const cmplx& input, cmplx * __restrict__ result, int stride ); 149 | }; 150 | 151 | 152 | 153 | //============================================================================= 154 | // Goertzel DFT 155 | //============================================================================= 156 | 157 | class goertzel { 158 | private: 159 | int N; 160 | int count; 161 | double Q0; 162 | double Q1; 163 | double Q2; 164 | double k1; 165 | double k2; 166 | double k3; 167 | bool isvalid; 168 | public: 169 | goertzel(int n, double freq, double sr); 170 | ~goertzel(); 171 | void reset(); 172 | void reset(int n, double freq, double sr); 173 | bool run(double v); 174 | double real(); 175 | double imag(); 176 | double mag(); 177 | }; 178 | 179 | #endif /* _FILTER_H */ 180 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/interleave.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // interleave.h -- MFSK (de)interleaver 3 | // 4 | // Copyright (C) 2006 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // gmfsk Copyright (C) 2001, 2002, 2003 10 | // Tomi Manninen (oh2bns@sral.fi) 11 | // 12 | // Fldigi is free software: you can redistribute it and/or modify 13 | // it under the terms of the GNU General Public License as published by 14 | // the Free Software Foundation, either version 3 of the License, or 15 | // (at your option) any later version. 16 | // 17 | // Fldigi is distributed in the hope that it will be useful, 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU General Public License 23 | // along with fldigi. If not, see . 24 | // ---------------------------------------------------------------------------- 25 | 26 | #ifndef _INTERLEAVE_H 27 | #define _INTERLEAVE_H 28 | 29 | #define INTERLEAVE_FWD 0 30 | #define INTERLEAVE_REV 1 31 | #define PUNCTURE 128 32 | 33 | class interleave 34 | { 35 | protected: 36 | int size; 37 | int depth; 38 | int len; 39 | int direction; 40 | unsigned char *table; 41 | unsigned char *tab(int i, int j, int k) { 42 | return &table[(size * size * i) + (size * j) + k]; 43 | } 44 | 45 | public: 46 | interleave(int _size, int depth, int dir); 47 | ~interleave(); 48 | void symbols (unsigned char *psyms); 49 | void bits (unsigned int *pbits); 50 | void flush(); 51 | }; 52 | 53 | // ---------------------------------------------------------------------------- 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/jalocha/pj_cmpx.h: -------------------------------------------------------------------------------- 1 | 2 | // Complex numbers 3 | // (c) 1999-2003, Pawel Jalocha 4 | 5 | #ifndef __CMPX_H__ 6 | #define __CMPX_H__ 7 | 8 | #include 9 | #define _USE_MATH_DEFINES 10 | #include 11 | 12 | // ---------------------------------------------------------------------------- 13 | // float/double/other-complex type 14 | 15 | template 16 | class Cmpx 17 | { 18 | public: 19 | Type Re,Im; 20 | 21 | public: 22 | template 23 | Cmpx const &operator=(const Cmpx &New) 24 | { Re=New.Re; Im=New.Im; return (*this); } 25 | template 26 | Cmpx const &operator=(const Type2 &New) 27 | { Re=New; Im=0; return (*this); } 28 | template 29 | void Set(Type2 NewRe, Type2 NewIm=0) { Re=NewRe; Im=NewIm; } 30 | template 31 | void Set(Cmpx New) { Re=New.Re; Im=New.Im; } 32 | void SetPhase(double Phase, double Mag=1.0) { Re=Mag*cos(Phase); Im=Mag*sin(Phase); } 33 | void Conugate(void) { Im=(-Im); } 34 | void Negate(void) { Re=(-Re); Im=(-Im); } 35 | void QuarterTurnLeft(void) { Type OldIm=Im; Im=Re; Re=(-OldIm); } 36 | void QuarterTurnRight(void) { Type OldIm=Im; Im=(-Re); Re=OldIm; } 37 | double Energy(void) { return Re*Re+Im*Im; } 38 | double Mag2(void) { return Re*Re+Im*Im; } 39 | double Mag(void) { return sqrt(Re*Re+Im*Im); } 40 | double Phase(void) { return atan2(Im,Re); } 41 | int Zero(void) { return (Re==0)&&(Im==0); } 42 | int NotZero(void) { return (Re!=0)||(Im!=0); } 43 | // template 44 | // void operator *= (const Type2 Mult) 45 | // { Re*=Mult; Im*=Mult; } 46 | // template 47 | // void operator /= (const Type2 Mult) 48 | // { Re*=Mult; Im*=Mult; } 49 | template 50 | double VectDotProd(Cmpx X) { return Re*X.Re+Im*X.Im; } 51 | void Print(char *Form="%+6.3f") 52 | { printf("["); printf(Form,Re); printf(","); printf(Form,Im); printf("]"); } 53 | } ; 54 | 55 | typedef Cmpx fcmpx; 56 | typedef Cmpx dcmpx; 57 | 58 | // Some complex operators: 59 | // at least with the BC++ they carry some overhead because 60 | // a function is always called instead of making the code inline. 61 | 62 | template // equal (both Re and Im) ? 63 | inline int operator ==(Cmpx &Left, Cmpx &Right) 64 | { return (Left.Re==Right.Re)&&(Left.Im==Right.Im); } 65 | 66 | template // equal (both Re and Im) ? 67 | inline int operator !=(Cmpx &Left, Cmpx &Right) 68 | { return (Left.Re!=Right.Re)||(Left.Im!=Right.Im); } 69 | 70 | template // equal ? 71 | inline int operator ==(Cmpx &Left, type &Right) 72 | { return (Left.Re==Right)&&(Left.Im==0); } 73 | 74 | template // not equal ? 75 | inline int operator !=(Cmpx &Left, RightType &Right) 76 | { return (Left.Re!=Right)||(Left.Im!=0); } 77 | 78 | template // bigger (magnitude) ? 79 | inline int operator >(Cmpx &Left, Cmpx &Right) 80 | { return Left.Mag2() > Right.Mag2(); } 81 | 82 | template // smaller (magnitude) ? 83 | inline int operator <(Cmpx &Left, Cmpx &Right) 84 | { return Left.Mag2() < Right.Mag2(); } 85 | 86 | template // addition to the argument on the left 87 | inline void operator +=(Cmpx &Dst, Cmpx &Src) 88 | { Dst.Re+=Src.Re; Dst.Im+=Src.Im; } 89 | 90 | template // subtraction from the argument on the left 91 | inline void operator -=(Cmpx &Dst, Cmpx &Src) 92 | { Dst.Re-=Src.Re; Dst.Im-=Src.Im; } 93 | 94 | template // multiplication by a scalar 95 | inline void operator *=(Cmpx &Dst, num Src) 96 | { Dst.Re*=Src; Dst.Im*=Src; } 97 | 98 | template // multiplication by another complex number 99 | inline void operator *=(Cmpx &Dst, Cmpx Src) 100 | { type Re=Dst.Re*Src.Re-Dst.Im*Src.Im; 101 | type Im=Dst.Re*Src.Im+Dst.Im*Src.Re; 102 | Dst.Re=Re; Dst.Im=Im; } 103 | 104 | template // division by a scalar 105 | inline void operator /=(Cmpx &Dst, num Src) 106 | { Dst.Re/=Src; Dst.Im/=Src; } 107 | 108 | template // scalar multiplication 109 | inline double operator *(Cmpx &Left, Cmpx &Right) 110 | { return Left.Re*Right.Re+Left.Im*Right.Im; } 111 | 112 | // some arithmetic functions: 113 | 114 | // scalar product of two vectors 115 | template 116 | inline double ScalProd(Cmpx &A, Cmpx &B) 117 | { return A.Re*B.Re+A.Im*B.Im; } 118 | 119 | template 120 | inline double ScalProd(typeA Ia, typeA Qa, Cmpx &B) 121 | { return Ia*B.Re+Qa*B.Im; } 122 | 123 | // complex multiply 124 | template 125 | inline void CmpxMultAxB(Cmpx &Dst, Cmpx &A, Cmpx &B) 126 | { Dst.Re=A.Re*B.Re-A.Im*B.Im; 127 | Dst.Im=A.Re*B.Im+A.Im*B.Re; } 128 | 129 | template 130 | inline void CmpxMultAxB(typeDst &DstI, typeDst &DstQ, Cmpx &A, Cmpx &B) 131 | { DstI=A.Re*B.Re-A.Im*B.Im; 132 | DstQ=A.Re*B.Im+A.Im*B.Re; } 133 | 134 | // complex multiply, second argument with a "star" (B.im is negated) 135 | // (effectively subtracts the phase of the second argument) 136 | template 137 | inline void CmpxMultAxBs(Cmpx &Dst, Cmpx &A, Cmpx &B) 138 | { Dst.Re=A.Re*B.Re+A.Im*B.Im; 139 | Dst.Im=A.Im*B.Re-A.Re*B.Im; } 140 | 141 | template 142 | void CmpxSqrt(Cmpx &X) 143 | { Type Mag=X.Mag(); int NegIm=(X.Im<0); 144 | X.Im=sqrt((Mag-X.Re)/2); 145 | X.Re=sqrt((Mag+X.Re)/2); 146 | if(NegIm) X.Re=(-X.Re); } 147 | 148 | template 149 | void CmpxSquare(Cmpx &X) 150 | { Type Re=X.Re*X.Re-X.Im*X.Im; 151 | X.Im=2*X.Re*X.Im; 152 | X.Re=Re; } 153 | 154 | // ---------------------------------------------------------------------------- 155 | 156 | #endif /* __CMPX_H__ */ 157 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/jalocha/pj_fht.h: -------------------------------------------------------------------------------- 1 | // Fast Hadamard Transform, Pawel Jalocha, December 2004 2 | 3 | #ifndef __FHT_H__ 4 | #define __FHT_H__ 5 | 6 | // Forward Fast Hadamard Transform 7 | 8 | template // Type can be float, Cmpx<>, int8_t, etc. 9 | void FHT(Type *Data, size_t Len) 10 | { size_t Step, Ptr, Ptr2; Type Bit1, Bit2, NewBit1, NewBit2; 11 | for(Step=1; Step 26 | void IFHT(Type *Data, size_t Len) 27 | { size_t Step, Ptr, Ptr2; Type Bit1, Bit2, NewBit1, NewBit2; 28 | for(Step=Len/2; Step; Step/=2) 29 | { for(Ptr=0; Ptr 9 | class FIFO 10 | { public: 11 | 12 | size_t Len; 13 | 14 | private: 15 | 16 | size_t ReadPtr; 17 | size_t WritePtr; 18 | Type *Data; 19 | 20 | public: 21 | 22 | FIFO() 23 | { Init(); } 24 | 25 | ~FIFO() 26 | { free(Data); } 27 | 28 | void Init(void) 29 | { Data=0; Len=0; } 30 | 31 | void Free(void) 32 | { free(Data); Data=0; Len=0; } 33 | 34 | void Reset(void) 35 | { ReadPtr=WritePtr=0; } 36 | 37 | void Clear(void) 38 | { ReadPtr=WritePtr; } 39 | 40 | int Preset(void) 41 | { if(ReallocArray(&Data,Len)<0) return -1; 42 | Reset(); return 0; } 43 | 44 | // increment the pointer (with wrapping around) 45 | void IncrPtr(size_t &Ptr, size_t Step=1) 46 | { Ptr+=Step; if(Ptr>=Len) Ptr-=Len; } 47 | 48 | // FIFO is full ? 49 | int Full(void) 50 | { size_t Ptr=WritePtr; IncrPtr(Ptr); 51 | return (Ptr==ReadPtr); } 52 | 53 | // FIFO is empty ? 54 | int Empty(void) 55 | { return (ReadPtr==WritePtr); } 56 | 57 | // how many elements we can write = space left in the FIFO 58 | size_t WriteReady(void) 59 | { int Ready=ReadPtr-WritePtr; 60 | if(Ready<=0) Ready+=Len; 61 | return Ready-1; } 62 | 63 | // how many elements we can read = space taken in the FIFO 64 | size_t ReadReady(void) 65 | { int Ready=WritePtr-ReadPtr; 66 | if(Ready<0) Ready+=Len; 67 | return Ready; } 68 | 69 | // write a new element 70 | int Write(Type &NewData) 71 | { size_t Ptr=WritePtr; IncrPtr(Ptr); 72 | if(Ptr==ReadPtr) return 0; 73 | Data[WritePtr]=NewData; 74 | WritePtr=Ptr; return 1; } 75 | 76 | // read the oldest element 77 | int Read(Type &OldData) 78 | { if(ReadPtr==WritePtr) return 0; 79 | OldData=Data[ReadPtr]; IncrPtr(ReadPtr); return 1; } 80 | 81 | // lookup data in the FIFO but without taking them out 82 | int Lookup(Type &OldData, size_t Offset=0) 83 | { size_t Ready=ReadReady(); if(Offset>=Ready) return 0; 84 | size_t Ptr=ReadPtr; IncrPtr(Ptr,Offset); 85 | OldData=Data[Ptr]; return 1; } 86 | } ; 87 | 88 | /* 89 | // FIFO buffer for batches of data (incomplete) 90 | template 91 | class WideFIFO 92 | { public: 93 | 94 | size_t Width; 95 | size_t Len; 96 | size_t ReadPtr; 97 | size_t WritePtr; 98 | size_t Size; 99 | Type *Data; 100 | 101 | public: 102 | 103 | WideFIFO() 104 | { Init(); } 105 | 106 | ~WideFIFO() 107 | { free(Data); } 108 | 109 | void Init(void) 110 | { Data=0; Size=0; } 111 | 112 | void Free(void) 113 | { free(Data); Data=0; Size=0; } 114 | 115 | // reset: set pointers to the beginning of the buffer 116 | void Reset(void) 117 | { ReadPtr=WritePtr=0; } 118 | 119 | // preset for given length and width 120 | int Preset(size_t NewLen, size_t NewWidth) 121 | { Width=NewWidth; 122 | Len=NewLen; 123 | Size=Width*Len; 124 | if(ReallocArray(&Data,Size)<0) return -1; 125 | Reset(); return 0; } 126 | 127 | // increment the pointer (with wrapping around) 128 | void IncrPtr(size_t &Ptr, size_t Step=1) 129 | { Ptr+=Step; if(Ptr>=Len) Ptr-=Len; } 130 | 131 | int Full(void) 132 | { Ptr=WritePtr; Incr(Ptr); 133 | return (Ptr==ReadPtr); } 134 | 135 | int Empty(void) 136 | { return (ReadPtr==WritePtr); } 137 | 138 | int Write(Type *DataBatch) 139 | { } 140 | 141 | int Read(Type *DataBatch) 142 | { } 143 | } ; 144 | */ 145 | 146 | #endif // of __FIFO_H__ 147 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/jalocha/pj_gray.h: -------------------------------------------------------------------------------- 1 | // Gray code convertion 2 | // (c) 2004, Pawel Jalocha 3 | 4 | #ifndef __GRAY_H__ 5 | #define __GRAY_H__ 6 | 7 | #include 8 | 9 | template 10 | Type GrayCode(Type Binary) 11 | { return Binary ^ (Binary>>1); } 12 | 13 | inline uint8_t BinaryCode(uint8_t Gray) 14 | { Gray ^= (Gray>>4); 15 | Gray ^= (Gray>>2); 16 | Gray ^= (Gray>>1); 17 | return Gray; } 18 | 19 | inline uint16_t BinaryCode(uint16_t Gray) 20 | { Gray ^= (Gray>>8); 21 | Gray ^= (Gray>>4); 22 | Gray ^= (Gray>>2); 23 | Gray ^= (Gray>>1); 24 | return Gray; } 25 | 26 | inline uint32_t BinaryCode(uint32_t Gray) 27 | { Gray ^= (Gray>>16); 28 | Gray ^= (Gray>>8); 29 | Gray ^= (Gray>>4); 30 | Gray ^= (Gray>>2); 31 | Gray ^= (Gray>>1); 32 | return Gray; } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/jalocha/pj_lowpass3.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __LOWPASS3_H__ 3 | #define __LOWPASS3_H__ 4 | 5 | // ========================================================================== 6 | 7 | // IIR low pass filter for integration (averaging) purposes 8 | // Overshoot is about 1% for Feedback=0.5, and about 1e-6 for Feedback=0.1 9 | // Weight is 1 / PeakingTime 10 | 11 | template 12 | class LowPass3_Filter 13 | { 14 | public: 15 | Type Out1, Out2, Output; 16 | template 17 | void Process(InpType Inp, WeightType Weight, WeightType Feedback = 0.1) 18 | { 19 | Weight *= 2.0; 20 | Type DiffI1 = Inp; DiffI1 -= Out1; 21 | Type Diff12 = Out1; Diff12 -= Out2; 22 | Type Diff23 = Out2; Diff23 -= Output; 23 | DiffI1 *= Weight; Out1 += DiffI1; 24 | Diff12 *= Weight; Out2 += Diff12; 25 | Diff23 *= Weight; Output += Diff23; 26 | Diff23 *= Feedback; Out2 += Diff23; 27 | } 28 | template 29 | void operator = (LevelType Level) 30 | { 31 | Out1 = Level; 32 | Out2 = Level; 33 | Output=Level; 34 | } 35 | template 36 | void Set(LevelType Level=0) 37 | { 38 | Out1 = Level; 39 | Out2 = Level; 40 | Output=Level; 41 | } 42 | }; 43 | 44 | 45 | // ========================================================================== 46 | 47 | #endif // of __LOWPASS3_H__ 48 | 49 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/lora.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2019 Joachim Tapparel TCL@EPFL. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3, or (at your option) 8 | * any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; see the file COPYING. If not, write to 17 | * the Free Software Foundation, Inc., 51 Franklin Street, 18 | * Boston, MA 02110-1301, USA. 19 | * 20 | * Modified by Giovanni Camurati to make it a library for fldigi-noise-sdr 21 | * 22 | */ 23 | 24 | #ifndef _LORA_H 25 | #define _LORA_H 26 | 27 | #include 28 | #include "modem.h" 29 | //#include "complex.h" 30 | 31 | #define MAX_PKT_SIZE 255 32 | #define HEADER_SIZE 5 33 | #define CRC_SIZE 4 34 | 35 | const unsigned int whitening_seq[] = { 36 | 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE1, 0xC2, 0x85, 0x0B, 0x17, 0x2F, 0x5E, 37 | 0xBC, 0x78, 0xF1, 0xE3, 0xC6, 0x8D, 0x1A, 0x34, 0x68, 0xD0, 0xA0, 0x40, 38 | 0x80, 0x01, 0x02, 0x04, 0x08, 0x11, 0x23, 0x47, 0x8E, 0x1C, 0x38, 0x71, 39 | 0xE2, 0xC4, 0x89, 0x12, 0x25, 0x4B, 0x97, 0x2E, 0x5C, 0xB8, 0x70, 0xE0, 40 | 0xC0, 0x81, 0x03, 0x06, 0x0C, 0x19, 0x32, 0x64, 0xC9, 0x92, 0x24, 0x49, 41 | 0x93, 0x26, 0x4D, 0x9B, 0x37, 0x6E, 0xDC, 0xB9, 0x72, 0xE4, 0xC8, 0x90, 42 | 0x20, 0x41, 0x82, 0x05, 0x0A, 0x15, 0x2B, 0x56, 0xAD, 0x5B, 0xB6, 0x6D, 43 | 0xDA, 0xB5, 0x6B, 0xD6, 0xAC, 0x59, 0xB2, 0x65, 0xCB, 0x96, 0x2C, 0x58, 44 | 0xB0, 0x61, 0xC3, 0x87, 0x0F, 0x1F, 0x3E, 0x7D, 0xFB, 0xF6, 0xED, 0xDB, 45 | 0xB7, 0x6F, 0xDE, 0xBD, 0x7A, 0xF5, 0xEB, 0xD7, 0xAE, 0x5D, 0xBA, 0x74, 46 | 0xE8, 0xD1, 0xA2, 0x44, 0x88, 0x10, 0x21, 0x43, 0x86, 0x0D, 0x1B, 0x36, 47 | 0x6C, 0xD8, 0xB1, 0x63, 0xC7, 0x8F, 0x1E, 0x3C, 0x79, 0xF3, 0xE7, 0xCE, 48 | 0x9C, 0x39, 0x73, 0xE6, 0xCC, 0x98, 0x31, 0x62, 0xC5, 0x8B, 0x16, 0x2D, 49 | 0x5A, 0xB4, 0x69, 0xD2, 0xA4, 0x48, 0x91, 0x22, 0x45, 0x8A, 0x14, 0x29, 50 | 0x52, 0xA5, 0x4A, 0x95, 0x2A, 0x54, 0xA9, 0x53, 0xA7, 0x4E, 0x9D, 0x3B, 51 | 0x77, 0xEE, 0xDD, 0xBB, 0x76, 0xEC, 0xD9, 0xB3, 0x67, 0xCF, 0x9E, 0x3D, 52 | 0x7B, 0xF7, 0xEF, 0xDF, 0xBF, 0x7E, 0xFD, 0xFA, 0xF4, 0xE9, 0xD3, 0xA6, 53 | 0x4C, 0x99, 0x33, 0x66, 0xCD, 0x9A, 0x35, 0x6A, 0xD4, 0xA8, 0x51, 0xA3, 54 | 0x46, 0x8C, 0x18, 0x30, 0x60, 0xC1, 0x83, 0x07, 0x0E, 0x1D, 0x3A, 0x75, 55 | 0xEA, 0xD5, 0xAA, 0x55, 0xAB, 0x57, 0xAF, 0x5F, 0xBE, 0x7C, 0xF9, 0xF2, 56 | 0xE5, 0xCA, 0x94, 0x28, 0x50, 0xA1, 0x42, 0x84, 0x09, 0x13, 0x27, 0x4F, 57 | 0x9F, 0x3F, 0x7F}; 58 | 59 | class lora : public modem { 60 | private: 61 | int txstate; 62 | int payload_cnt; 63 | int len; 64 | int len_i; 65 | bool end; 66 | unsigned int payload[MAX_PKT_SIZE]; 67 | unsigned int payload_w[2 * MAX_PKT_SIZE]; 68 | int data[HEADER_SIZE + 2 * MAX_PKT_SIZE + CRC_SIZE]; 69 | int data_i[8 * (HEADER_SIZE + 2 * MAX_PKT_SIZE + CRC_SIZE)]; 70 | 71 | bool implicit_header; 72 | bool has_crc; 73 | bool simple; 74 | int sf; 75 | int cr; 76 | double bw; 77 | 78 | unsigned int number_of_bins; ///< number of bin per loar symbol 79 | double symbols_per_second; ///< lora symbols per second 80 | unsigned int samples_per_symbol; ///< samples per symbols(Works only for 2^sf) 81 | 82 | std::vector upchirp; ///< reference upchirp 83 | std::vector downchirp; ///< reference downchirp 84 | std::vector symbol; ///< reference downchirp 85 | 86 | unsigned int n_up; ///< number of upchirps in the preamble 87 | uint32_t symb_cnt; ///< counter of the number of lora symbols sent 88 | 89 | void simple_enc(); 90 | void whithen(); 91 | void add_header(); 92 | void compute_header(int *data); 93 | unsigned int crc16(unsigned int crcValue, unsigned char newByte); 94 | void add_crc(); 95 | void hamming_enc(); 96 | void interleave(); 97 | void gray_enc(); 98 | double get_phase(unsigned int i, unsigned int id); 99 | inline void build_ref_chirps(double *upchirp, double *downchirp); 100 | inline void build_upchirp(double *upchirp, uint32_t id); 101 | void modulate(); 102 | 103 | public: 104 | enum { 105 | TX_STATE_GET_PAYLOAD, 106 | TX_STATE_PROCESS_PKT, 107 | TX_STATE_END, 108 | }; 109 | 110 | lora(int loramode); 111 | ~lora(); 112 | void init(); 113 | void rx_init(); 114 | void tx_init(); 115 | void restart(); 116 | int rx_process(const short *, int ); 117 | int tx_process(); 118 | }; 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/mfskvaricode.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // mfskvaricode.h -- MFSK Varicode 3 | // 4 | // Copyright (C) 2006 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // 10 | // Fldigi is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Fldigi is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with fldigi. If not, see . 22 | // ---------------------------------------------------------------------------- 23 | 24 | #ifndef _MFSKVARICODE_H 25 | #define _MFSKVARICODE_H 26 | 27 | extern const char *varienc(int c); 28 | extern int varidec(unsigned int symbol); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/misc.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // misc.h -- Miscellaneous helper functions 3 | // 4 | // Copyright (C) 2006-2008 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. These filters were adapted from code contained 8 | // in the gmfsk source code distribution. 9 | // 10 | // Fldigi is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Fldigi is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with fldigi. If not, see . 22 | // ---------------------------------------------------------------------------- 23 | 24 | #ifndef _MISC_H 25 | #define _MISC_H 26 | 27 | #define _USE_MATH_DEFINES 28 | #include 29 | 30 | extern unsigned long hweight32(unsigned long w); 31 | extern unsigned short int hweight16(unsigned short int w); 32 | extern unsigned char hweight8(unsigned char w); 33 | extern int parity(unsigned long w); 34 | extern unsigned long rbits32(unsigned long w); 35 | extern unsigned short int rbits16(unsigned short int w); 36 | extern unsigned char rbits8(unsigned char w); 37 | 38 | extern unsigned int log2u(unsigned int x); 39 | 40 | extern unsigned char graydecode(unsigned char data); 41 | extern unsigned char grayencode(unsigned char data); 42 | //Android conflict with util.h definition extern void MilliSleep(long msecs); 43 | 44 | inline double sinc(double x) 45 | { 46 | return (fabs(x) < 1e-10) ? 1.0 : (sin(M_PI * x) / (M_PI * x)); 47 | } 48 | 49 | inline double cosc(double x) 50 | { 51 | return (fabs(x) < 1e-10) ? 0.0 : ((1.0 - cos(M_PI * x)) / (M_PI * x)); 52 | } 53 | 54 | inline double clamp(double x, double min, double max) 55 | { 56 | return (x < min) ? min : ((x > max) ? max : x); 57 | } 58 | 59 | /// This is always called with an int weight 60 | inline double decayavg(double average, double input, int weight) 61 | { 62 | if (weight <= 1) return input; 63 | return ( ( input - average ) / (double)weight ) + average ; 64 | } 65 | 66 | // following are defined inline to provide best performance 67 | inline double blackman(double x) 68 | { 69 | return (0.42 - 0.50 * cos(2 * M_PI * x) + 0.08 * cos(4 * M_PI * x)); 70 | } 71 | 72 | inline double hamming(double x) 73 | { 74 | return 0.54 - 0.46 * cos(2 * M_PI * x); 75 | } 76 | 77 | inline double hanning(double x) 78 | { 79 | return 0.5 - 0.5 * cos(2 * M_PI * x); 80 | } 81 | 82 | inline double rcos( double t, double T, double alpha=1.0 ) 83 | { 84 | if( t == 0 ) return 1.0; 85 | double taT = T / (2.0 * alpha); 86 | if( fabs(t) == taT ) return ((alpha/2.0) * sin(M_PI/(2.0*alpha))); 87 | return (sin(M_PI*t/T)/(M_PI*t/T))*cos(alpha*M_PI*t/T)/(1.0-(t/taT)*(t/taT)); 88 | } 89 | 90 | // Rectangular - no pre filtering of data array 91 | void RectWindow(double *array, int n); 92 | // Hamming - used by gmfsk 93 | void HammingWindow(double *array, int n); 94 | // Hanning - used by winpsk 95 | void HanningWindow(double *array, int n); 96 | // Best lob suppression - least in band ripple 97 | void BlackmanWindow(double *array, int n); 98 | // Simple about effective as Hamming or Hanning 99 | void TriangularWindow(double *array, int n); 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/morse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * morse.h -- morse code tables 3 | * 4 | * Copyright (C) 2017 5 | * 6 | * Fldigi is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Fldigi is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with fldigi. If not, see . 18 | * 19 | */ 20 | 21 | #ifndef _MORSE_H 22 | #define _MORSE_H 23 | 24 | #include 25 | 26 | #define MorseTableSize 256 27 | 28 | #define CW_DOT_REPRESENTATION '.' 29 | #define CW_DASH_REPRESENTATION '-' 30 | 31 | struct CWstruct { 32 | bool enabled; // true if character is active 33 | std::string chr; // utf-8 string representation of character 34 | std::string prt; // utf-8 printable representation 35 | std::string rpr; // Dot-dash code representation 36 | }; 37 | 38 | class cMorse { 39 | private: 40 | static CWstruct cw_table[]; 41 | std::string utf8; 42 | std::string toprint; 43 | int ptr; 44 | public: 45 | cMorse() { 46 | init(); 47 | } 48 | ~cMorse() { 49 | } 50 | void init(); 51 | void enable(std::string, bool); 52 | std::string rx_lookup(std::string); 53 | std::string tx_lookup(int); 54 | std::string tx_print() { return toprint; } 55 | int tx_length(int); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/mt63.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // mt63.h 3 | // 4 | // Copyright (C) 2006-2009 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // Copyright (C) 2005 10 | // Tomi Manninen (oh2bns@sral.fi) 11 | // 12 | // Fldigi is free software: you can redistribute it and/or modify 13 | // it under the terms of the GNU General Public License as published by 14 | // the Free Software Foundation, either version 3 of the License, or 15 | // (at your option) any later version. 16 | // 17 | // Fldigi is distributed in the hope that it will be useful, 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU General Public License 23 | // along with fldigi. If not, see . 24 | // ---------------------------------------------------------------------------- 25 | 26 | #ifndef MT63_MODEM_H 27 | #define MT63_MODEM_H 28 | 29 | #include "dsp.h" 30 | #include "mt63base.h" 31 | #include "modem.h" 32 | 33 | 34 | class mt63 : public modem { 35 | private: 36 | int Interleave; 37 | int flush; 38 | int escape; 39 | bool long_integral; 40 | 41 | MT63tx *Tx; 42 | MT63rx *Rx; 43 | 44 | dspLevelMonitor *InpLevel; 45 | double_buff *InpBuff; 46 | double_buff *emptyBuff; 47 | bool flushbuffer; 48 | double FEC_offset; 49 | double FEC_snr; 50 | 51 | public: 52 | //Android mt63(trx_mode mode); 53 | mt63(int mode); 54 | ~mt63(); 55 | void init(); 56 | void rx_init(); 57 | //Android void tx_init(SoundBase*); 58 | void tx_init(); 59 | void restart(); 60 | //Android buffer is array of shorts now int rx_process(const double *buf, int len); 61 | int rx_process(const short *buf, int len); 62 | int tx_process(); 63 | 64 | void rx_flush(); 65 | void set_freq(double); 66 | }; 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/olivia.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // olivia.h 3 | // 4 | // Copyright (C) 2006-2010 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // Copyright (C) 2005 10 | // Tomi Manninen (oh2bns@sral.fi) 11 | // 12 | // This file is part of fldigi. 13 | // 14 | // Fldigi is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // Fldigi is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with fldigi. If not, see . 26 | // ---------------------------------------------------------------------------- 27 | 28 | #ifndef _OLIVIA_H 29 | #define _OLIVIA_H 30 | 31 | #include "modem.h" 32 | #include "jalocha/pj_mfsk.h" 33 | //Android #include "sound.h" 34 | #include "complex.h" 35 | 36 | #define TONE_DURATION (SCBLOCKSIZE * 16) 37 | #define SR4 ((TONE_DURATION) / 4) 38 | 39 | class olivia : public modem { 40 | private: 41 | 42 | MFSK_Transmitter < double >*Tx; 43 | MFSK_Receiver < double >*Rx; 44 | 45 | double *txfbuffer; 46 | int txbufferlen; 47 | 48 | double phaseacc; 49 | cmplx prevsymbol; 50 | int preamble; 51 | unsigned int shreg; 52 | 53 | double np; 54 | double sp; 55 | double sigpwr; 56 | double noisepwr; 57 | 58 | int escape; 59 | int smargin; 60 | int sinteg; 61 | int tones; 62 | int bw; 63 | double tone_bw; 64 | 65 | int preamblesent; 66 | int postamblesent; 67 | double preamblephase; 68 | 69 | double txbasefreq; 70 | double tone_midfreq; 71 | double lastfreq; 72 | 73 | double ampshape[SR4]; 74 | double tonebuff[TONE_DURATION]; 75 | 76 | double nco(double freq); 77 | void send_tones(); 78 | 79 | public: 80 | //Android olivia(trx_mode omode = MODE_OLIVIA); 81 | olivia(int omode); 82 | ~olivia(); 83 | void init(); 84 | void rx_init(); 85 | void rx_flush(); 86 | //Android void tx_init(SoundBase *sc); 87 | void tx_init(); 88 | void restart(); 89 | //Android int rx_process(const double *buf, int len); 90 | int rx_process(const short *buf, int len); 91 | int tx_process(); 92 | int unescape(int c); 93 | }; 94 | 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/psk.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // psk.h -- psk modem 3 | // 4 | // Copyright (C) 2006-2008 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // 10 | // Fldigi is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Fldigi is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with fldigi. If not, see . 22 | // ---------------------------------------------------------------------------- 23 | 24 | #ifndef _PSK_H 25 | #define _PSK_H 26 | 27 | #include "complex.h" 28 | #include "modem.h" 29 | //Android test #include "globals.h" 30 | #include "viterbi.h" 31 | #include "filters.h" 32 | #include "pskcoeff.h" 33 | #include "pskvaricode.h" 34 | //Android #include "viewpsk.h" 35 | //Android #include "pskeval.h" 36 | #include "interleave.h" 37 | 38 | //MFSK varicode instead of psk for PSKR modes 39 | #include "mfskvaricode.h" 40 | 41 | //===================================================================== 42 | #define PipeLen (64) 43 | 44 | #define SNTHRESHOLD 6.0 45 | #define AFCDECAYSLOW 8 46 | 47 | #define NUM_FILTERS 3 48 | #define GOERTZEL 288 //96 x 2 must be an integer value 49 | 50 | #define MAX_CARRIERS 32 51 | 52 | //===================================================================== 53 | 54 | class psk : public modem { 55 | private: 56 | // tx & rx 57 | int symbollen; 58 | int symbits; 59 | bool _qpsk; 60 | bool _pskr; 61 | bool _16psk; 62 | bool _8psk; 63 | bool _xpsk; 64 | bool _disablefec; 65 | bool _puncturing; 66 | int flushlength; 67 | double separation; 68 | double phaseacc[MAX_CARRIERS]; 69 | cmplx prevsymbol[MAX_CARRIERS]; 70 | unsigned int shreg; 71 | //FEC: 2nd stream 72 | unsigned int shreg2; 73 | int numinterleavers; //interleaver size (speed dependant) 74 | //double numcarriers; //Number of parallel carriers for M CAR PSK and PSKR and QPSKR 75 | int numcarriers; //Number of parallel carriers for M CAR PSK and PSKR and QPSKR 76 | double inter_carrier; // Frequency gap betweeb carriers 77 | 78 | // rx variables & functions 79 | C_FIR_filter *fir1[MAX_CARRIERS]; 80 | C_FIR_filter *fir2[MAX_CARRIERS]; 81 | // C_FIR_filter *fir3; 82 | double *fir1c; 83 | double *fir2c; 84 | Cmovavg *snfilt; 85 | Cmovavg *imdfilt; 86 | 87 | double I1[NUM_FILTERS]; 88 | double I2[NUM_FILTERS]; 89 | double Q1[NUM_FILTERS]; 90 | double Q2[NUM_FILTERS]; 91 | double COEF[NUM_FILTERS]; 92 | double m_Energy[NUM_FILTERS]; 93 | int m_NCount; 94 | bool imdValid; 95 | 96 | encoder *enc; 97 | viterbi *dec; 98 | //PSKR modes - 2nd Viterbi decoder and 2 receive de-interleaver for comparison 99 | viterbi *dec2; 100 | interleave *Rxinlv; 101 | interleave *Rxinlv2; 102 | interleave *Txinlv; 103 | unsigned int bitshreg; 104 | int rxbitstate; 105 | //PSKR modes - Soft decoding 106 | unsigned char symbolpair[2]; 107 | double fecmet; 108 | double fecmet2; 109 | 110 | bool vestigial; 111 | int sfft_size; 112 | sfft *vestigial_sfft; 113 | cmplx sfft_bins[11]; 114 | 115 | double phase; 116 | double freqerr; 117 | int bits; 118 | double bitclk; 119 | double syncbuf[16]; 120 | double scope_pipe[2*PipeLen];//[PipeLen]; 121 | unsigned int pipeptr; 122 | unsigned int dcdshreg; 123 | //PSKR modes - 2nd stream 124 | unsigned int dcdshreg2; 125 | 126 | int dcd; 127 | int dcdbits; 128 | cmplx quality; 129 | int acquire; 130 | int idepth; 131 | 132 | //Android viewpsk* pskviewer; 133 | //Android pskeval* evalpsk; 134 | 135 | void rx_symbol(cmplx symbol, int car); 136 | void rx_bit(int bit); 137 | void rx_bit2(int bit); 138 | void rx_qpsk(int bits); 139 | void rx_pskr(unsigned char symbol); 140 | double scopedata[16]; 141 | // IMD & s/n variables 142 | double k0, k1, k2; 143 | double I11, I12, I21, I22, I31, I32; 144 | double snratio, s2n, imdratio, imd; 145 | double E1, E2, E3; 146 | double afcmetric; 147 | 148 | //PSKR modes 149 | bool firstbit; 150 | bool startpreamble; 151 | 152 | //PSKR & 8PSK modes 153 | bool PSKviterbi; 154 | double vphase; 155 | double maxamp; 156 | 157 | 158 | //MULTI-CARRIER 159 | double sc_bw; // single carrier bandwidth 160 | 161 | 162 | // cmplx thirdorder; 163 | // tx variables & functions 164 | int accumulated_bits; //JD for multiple carriers 165 | int txsymbols[MAX_CARRIERS]; 166 | 167 | double *tx_shape; 168 | int preamble; 169 | void tx_carriers(); 170 | void tx_symbol(int sym); 171 | void tx_bit(int bit); 172 | void tx_xpsk(int bit); 173 | void tx_char(unsigned char c); 174 | void tx_flush(); 175 | void update_syncscope(); 176 | void signalquality(); 177 | void findsignal(); 178 | void phaseafc(); 179 | void afc(); 180 | void coreafc(); 181 | void vestigial_afc(); 182 | 183 | void initSN_IMD(); 184 | void resetSN_IMD(); 185 | void calcSN_IMD(cmplx z); 186 | //PSKR modes - for Tx interleaver priming 187 | void clearbits(); 188 | 189 | protected: 190 | void s2nreport(void); 191 | 192 | public: 193 | //Android not yet psk(trx_mode mode); 194 | psk(int pskmode); 195 | ~psk(); 196 | void init(); 197 | void rx_init(); 198 | //Android void tx_init(SoundBase *sc); 199 | void tx_init(); 200 | void restart(); 201 | //Android reals now 202 | // int rx_process(const double *buf, int len); 203 | int rx_process(const short *, int ); 204 | int tx_process(); 205 | void searchDown(); 206 | void searchUp(); 207 | 208 | /*Android 209 | void clear_viewer() { pskviewer->clear(); } 210 | void clear_ch(int n) { pskviewer->clearch(n); } 211 | int viewer_get_freq(int n) { 212 | if (pskviewer) pskviewer->get_freq(n); 213 | return 0; 214 | } 215 | */ 216 | 217 | }; 218 | 219 | #endif 220 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/pskcoeff.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Copyright (C) 2014 3 | // David Freese, W1HKJ 4 | // 5 | // This file is part of fldigi 6 | // 7 | // fldigi is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // fldigi is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | // ---------------------------------------------------------------------------- 20 | 21 | #ifndef _COEFF_H 22 | #define _COEFF_H 23 | 24 | #define FIRLEN 64 25 | 26 | extern double gmfir1c[FIRLEN]; 27 | extern double gmfir2c[FIRLEN]; 28 | extern double syncfilt[16]; 29 | 30 | extern void raisedcosfilt(double *); 31 | extern void wsincfilt(double *, double fc, bool blackman); 32 | //Android less taps for slow cpus 33 | extern void wsincfilt32(double *, double fc, bool blackman); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/pskrep.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Copyright (C) 2014 3 | // David Freese, W1HKJ 4 | // 5 | // This file is part of fldigi 6 | // 7 | // fldigi is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // fldigi is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | // ---------------------------------------------------------------------------- 20 | 21 | #ifndef PSKREP_H_ 22 | #define PSKREP_H_ 23 | 24 | bool pskrep_start(void); 25 | void pskrep_stop(); 26 | const char* pskrep_error(void); 27 | unsigned pskrep_count(void); 28 | 29 | // The regular expression that matches the spotter's buffer when it calls us. 30 | // It must define at least two capturing groups, the second of which is the 31 | // spotted callsign. 32 | #define CALLSIGN_RE "[[:alnum:]]?[[:alpha:]/]+[[:digit:]]+[[:alnum:]/]+" 33 | #define PSKREP_RE "(de|cq|qrz)[^[:alnum:]/\n]+" "(" CALLSIGN_RE ")" " +(.* +)?\\2[^[:alnum:]]+$" 34 | #define PSKREP_RE_INDEX 2 35 | 36 | #endif // PSKREP_H_ 37 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/pskvaricode.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // varicode.h -- PSK31 Varicode 3 | // 4 | // Copyright (C) 2006 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source code 8 | // distribution. 9 | // 10 | // Fldigi is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Fldigi is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with fldigi. If not, see . 22 | // ---------------------------------------------------------------------------- 23 | 24 | 25 | #ifndef _VARICODE_H 26 | #define _VARICODE_H 27 | 28 | extern const char *psk_varicode_encode(unsigned char c); 29 | extern int psk_varicode_decode(unsigned int symbol); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/rsid.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // 3 | // rsid.h 4 | // 5 | // Copyright (C) 2008, 2009 6 | // Dave Freese, W1HKJ 7 | // Copyright (C) 2009 8 | // Stelios Bounanos, M0GLD 9 | // Copyright (C) 2014 10 | // John Douyere, VK2ETA 11 | // 12 | // This file is part of fldigi. 13 | // 14 | // Fldigi is free software: you can redistribute it and/or modify 15 | // it under the terms of the GNU General Public License as published by 16 | // the Free Software Foundation, either version 3 of the License, or 17 | // (at your option) any later version. 18 | // 19 | // Fldigi is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with fldigi. If not, see . 26 | // ---------------------------------------------------------------------------- 27 | 28 | // ---------------------------------------------------------------------------- 29 | // Tone separation: 10.766Hz 30 | // Integer tone separator (x 16): 172 31 | // Error on 16 tones: 0.25Hz 32 | 33 | // Tone duration: 0.093 sec 34 | // Tone duration, #samples at 8ksps: 743 35 | // Error on 15 tones: negligible 36 | 37 | // 1024 samples -> 512 tones 38 | // 2048 samples, second half zeros 39 | 40 | // each 512 samples new FFT 41 | // ---------------------------------------------------------------------------- 42 | 43 | #ifndef RSID_H 44 | #define RSID_H 45 | 46 | #include 47 | 48 | //Android not yet #include 49 | //Android 50 | #include "complex.h" 51 | //Android #include "ringbuffer.h" 52 | #include "globals.h" 53 | #include "modem.h" 54 | #include "complex.h" 55 | //Android#include "gfft.h" 56 | #include "fft.h" 57 | 58 | #define RSID_SAMPLE_RATE 11025.0 59 | 60 | #define RSID_FFT_SAMPLES 512 61 | #define RSID_FFT_SIZE 1024 62 | #define RSID_ARRAY_SIZE (RSID_FFT_SIZE * 2) 63 | #define RSID_BUFFER_SIZE (RSID_ARRAY_SIZE * 2) 64 | 65 | #define RSID_NSYMBOLS 15 66 | #define RSID_NTIMES (RSID_NSYMBOLS * 2) 67 | #define RSID_PRECISION 2.7 // detected frequency precision in Hz 68 | 69 | // each rsid symbol has a duration equal to 1024 samples at 11025 Hz smpl rate 70 | #define RSID_SYMLEN (1024.0 / RSID_SAMPLE_RATE) // 0.09288 // duration of each rsid symbol 71 | 72 | //Android Moved from rsid.cxx 73 | #define NUM_MODES 9999 74 | //Android new for when a mode does not have a dedicated rsid code 75 | #define NO_RSID 9995 76 | 77 | 78 | enum { 79 | RSID_BANDWIDTH_500 = 0, 80 | RSID_BANDWIDTH_1K, 81 | RSID_BANDWIDTH_WIDE, 82 | }; 83 | 84 | typedef double rs_fft_type; 85 | //typedef std::complex rs_cpx_type; 86 | //Android typedef std::complex rs_cpx_type; 87 | typedef cmplx rs_cpx_type; 88 | 89 | //Android struct RSIDs { unsigned short rs; trx_mode mode; const char* name; }; 90 | struct RSIDs { unsigned short rs; int mode; const char* name; }; 91 | 92 | class cRsId { 93 | 94 | protected: 95 | enum { INITIAL, EXTENDED, WAIT }; 96 | 97 | public: 98 | 99 | //Android public access for Java side 100 | static const RSIDs rsid_ids_1[]; 101 | static const int rsid_ids_size1; 102 | static const RSIDs rsid_ids_2[]; 103 | static const int rsid_ids_size2; 104 | 105 | 106 | private: 107 | // Table of precalculated Reed Solomon symbols 108 | unsigned char *pCodes1; 109 | unsigned char *pCodes2; 110 | 111 | bool found1; 112 | bool found2; 113 | 114 | //Android static const RSIDs rsid_ids_1[]; 115 | //Android static const int rsid_ids_size1; 116 | static const int Squares[]; 117 | static const int indices[]; 118 | 119 | //Android static const RSIDs rsid_ids_2[]; 120 | //Android static const int rsid_ids_size2; 121 | 122 | int rsid_secondary_time_out; 123 | 124 | int hamming_resolution; 125 | 126 | int fftCounter; 127 | 128 | // Span of FFT bins, in which the RSID will be searched for 129 | int nBinLow; 130 | int nBinHigh; 131 | 132 | float aInputSamples[RSID_ARRAY_SIZE * 2]; 133 | rs_fft_type fftwindow[RSID_ARRAY_SIZE]; 134 | //Android using old fft routines rs_cpx_type aFFTReal[RSID_ARRAY_SIZE]; 135 | rs_fft_type aFFTReal[RSID_ARRAY_SIZE]; 136 | rs_fft_type aFFTAmpl[RSID_FFT_SIZE]; 137 | 138 | //Android g_fft *rsfft; 139 | Cfft *rsfft; 140 | 141 | bool bPrevTimeSliceValid; 142 | int iPrevDistance; 143 | int iPrevBin; 144 | int iPrevSymbol; 145 | 146 | int fft_buckets[RSID_NTIMES][RSID_FFT_SIZE]; 147 | 148 | bool bPrevTimeSliceValid2; 149 | int iPrevDistance2; 150 | int iPrevBin2; 151 | int iPrevSymbol2; 152 | 153 | // resample 154 | //Android not yet SRC_STATE* src_state; 155 | //Android not yet SRC_DATA src_data; 156 | int inptr; 157 | static long src_callback(void* cb_data, float** data); 158 | 159 | // transmit 160 | double *outbuf; 161 | size_t symlen; 162 | unsigned short rmode; 163 | unsigned short rmode2; 164 | 165 | private: 166 | void Encode(int code, unsigned char *rsid); 167 | // void search(void); 168 | void search(bool doSearch); 169 | void setup_mode(int m); 170 | 171 | void CalculateBuckets(const rs_fft_type *pSpectrum, int iBegin, int iEnd); 172 | inline int HammingDistance(int iBucket, unsigned char *p2); 173 | bool search_amp( int &bin_out, int &symbol_out, unsigned char *pcode_table ); 174 | void apply ( int iBin, int iSymbol, int extended ); 175 | double wpm; 176 | double cwrisetime; 177 | double rtty_baud; 178 | bool rtty_shaped; 179 | 180 | public: 181 | cRsId(double _wpm, double _cwrisetime, int _rtty_baud, bool _rtty_shaped); 182 | ~cRsId(); 183 | void reset(); 184 | // void receive(const float* buf, size_t len); 185 | void receive(const float* buf, size_t len, bool doSearch); 186 | void send(bool postidle); 187 | //Android added 188 | void sendThisMode(bool preRSID, int thisMode); 189 | //Android bool assigned(trx_mode mode); 190 | bool assigned(int mode); 191 | 192 | friend void reset_rsid(void *who); 193 | }; 194 | 195 | #endif 196 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/thor.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // thor.h -- thor modem 3 | // 4 | // Copyright (C) 2008-2012 5 | // David Freese 6 | // John Douyere 7 | // John Phelps 8 | // 9 | // This file is part of fldigi. 10 | // 11 | // Fldigi is free software: you can redistribute it and/or modify 12 | // it under the terms of the GNU General Public License as published by 13 | // the Free Software Foundation, either version 3 of the License, or 14 | // (at your option) any later version. 15 | // 16 | // Fldigi is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU General Public License 22 | // along with fldigi. If not, see . 23 | // ---------------------------------------------------------------------------- 24 | 25 | #ifndef _thor_H 26 | #define _thor_H 27 | 28 | #include 29 | 30 | #include "complex.h" 31 | #include "modem.h" 32 | #include "globals.h" 33 | #include "filters.h" 34 | #include "fftfilt.h" 35 | #include "dominovar.h" 36 | //Not used ???? #include "mbuffer.h" 37 | 38 | // NASA coefficients for viterbi encode/decode algorithms 39 | #define THOR_K 7 40 | #define THOR_POLY1 0x6d 41 | #define THOR_POLY2 0x4f 42 | 43 | //VK2ETA high speed modes 44 | // IEEE coefficients for viterbi encode/decode algorithms 45 | #define THOR_K15 15 46 | #define K15_POLY1 044735 47 | #define K15_POLY2 063057 48 | 49 | //#include "mfskvaricode.h" 50 | #include "interleave.h" 51 | 52 | #include "viterbi.h" 53 | 54 | 55 | #define THORNUMTONES 18 56 | #define THORMAXFFTS 8 57 | #define THORBASEFREQ 1500.0 58 | #define THORFIRSTIF 2000.0 59 | 60 | #define THORSCOPESIZE 64 61 | 62 | #define THORSLOWPATHS 3 63 | #define THORFASTPATHS 5 64 | 65 | // the following constant changes if a mode with more tones than 25x4 is 66 | // created 67 | #define MAXPATHS (8 * THORFASTPATHS * THORNUMTONES ) 68 | 69 | struct THORrxpipe { 70 | cmplx vector[THORMAXFFTS * THORNUMTONES * 6]; 71 | }; 72 | 73 | class thor : public modem { 74 | public: 75 | enum { 76 | TX_STATE_PREAMBLE, 77 | TX_STATE_START, 78 | TX_STATE_DATA, 79 | TX_STATE_END, 80 | TX_STATE_FLUSH 81 | }; 82 | protected: 83 | // common variables 84 | double phase[THORMAXFFTS + 1]; 85 | double txphase; 86 | int symlen; 87 | int doublespaced; 88 | double tonespacing; 89 | int counter; 90 | unsigned int twosym; 91 | int paths; 92 | int numbins; 93 | bool slowcpu; 94 | int basetone; 95 | int lotone; 96 | int hitone; 97 | int extones; 98 | 99 | // rx variables 100 | C_FIR_filter *hilbert; 101 | sfft *binsfft[THORMAXFFTS]; 102 | fftfilt *fft; 103 | Cmovavg *vidfilter[THORSCOPESIZE]; 104 | Cmovavg *syncfilter; 105 | 106 | THORrxpipe *pipe; 107 | unsigned int pipeptr; 108 | unsigned int datashreg; 109 | // mbuffer scopedata; 110 | // mbuffer videodata; 111 | 112 | cmplx currvector; 113 | 114 | int currsymbol; 115 | int prev1symbol; 116 | int prev2symbol; 117 | 118 | double currmag; 119 | double prev1mag; 120 | double prev2mag; 121 | 122 | double met1; 123 | double met2; 124 | double sig; 125 | double noise; 126 | double s2n; 127 | 128 | int synccounter; 129 | 130 | unsigned char symbolbuf[MAX_VARICODE_LEN]; 131 | int symcounter; 132 | 133 | int symbolbit; 134 | 135 | bool filter_reset; 136 | bool staticburst; 137 | 138 | int fec_confidence; 139 | 140 | // tx variables 141 | int txstate; 142 | int txprevtone; 143 | unsigned int bitshreg; 144 | std::string strSecXmtText; 145 | unsigned int cptr; 146 | 147 | viterbi *Dec; 148 | interleave *Rxinlv; 149 | encoder *Enc; 150 | interleave *Txinlv; 151 | int bitstate; 152 | unsigned char symbolpair[2]; 153 | 154 | int flushlength; 155 | 156 | 157 | private: 158 | cmplx mixer(int n, const cmplx& in); 159 | 160 | // Rx 161 | void recvchar(int c); 162 | void decodesymbol(); 163 | void softdecodesymbol(); 164 | int harddecode(); 165 | int softdecode(); 166 | void update_syncscope(); 167 | void synchronize(); 168 | void reset_afc(); 169 | void eval_s2n(); 170 | int get_secondary_char(); 171 | void reset_filters(); 172 | void decodePairs(unsigned char symbol); 173 | bool preambledetect(int c); 174 | void softflushrx(); 175 | 176 | // Tx 177 | void sendtone(int tone, int duration); 178 | void sendsymbol(int sym); 179 | void sendchar(unsigned char c, int secondary); 180 | void sendidle(); 181 | void sendsecondary(); 182 | void flushtx(); 183 | void Clearbits(); 184 | 185 | protected: 186 | void s2nreport(void); 187 | 188 | public: 189 | //Android thor (trx_mode md); 190 | thor (int md); 191 | ~thor (); 192 | void init(); 193 | void rx_init(); 194 | //Android void tx_init(SoundBase *sc); 195 | void tx_init(); 196 | void restart(); 197 | //Android int rx_process(const double *buf, int len); 198 | int rx_process(const short *buf, int len); 199 | int tx_process(); 200 | }; 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/thorvaricode.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // thorvaricode.h -- DEX Varicode 3 | // 4 | // Copyright (C) 2008 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. 8 | // 9 | // Fldigi is free software: you can redistribute it and/or modify 10 | // it under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 3 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // Fldigi is distributed in the hope that it will be useful, 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with fldigi. If not, see . 21 | // ---------------------------------------------------------------------------- 22 | 23 | #ifndef _DEXVARICODE_H 24 | #define _DEXVARICODE_H 25 | 26 | extern const char *thorvarienc(int c, int secondary); 27 | extern int thorvaridec(unsigned int symbol); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/include/viterbi.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // viterbi.h -- Viterbi decoder 3 | // 4 | // Copyright (C) 2006 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. These filters were adapted from code contained 8 | // in the gmfsk source code distribution. 9 | // 10 | // Fldigi is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Fldigi is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with fldigi. If not, see . 22 | // ---------------------------------------------------------------------------- 23 | 24 | 25 | #ifndef VITERBI_H 26 | #define VITERBI_H 27 | 28 | #define PATHMEM 128 29 | 30 | class viterbi { 31 | private: 32 | int _traceback; 33 | int _chunksize; 34 | int nstates; 35 | int *output; 36 | int outsize; 37 | int *metrics[PATHMEM]; 38 | int *history[PATHMEM]; 39 | int sequence[PATHMEM]; 40 | int mettab[2][256]; 41 | unsigned int ptr; 42 | int traceback(int *metric); 43 | int _k; 44 | int _poly1; 45 | int _poly2; 46 | public: 47 | viterbi(int k, int poly1, int poly2); 48 | ~viterbi(); 49 | void reset(); 50 | void init(); 51 | int settraceback(int trace); 52 | int setchunksize(int chunk); 53 | int decode(unsigned char *sym, int *metric); 54 | }; 55 | 56 | 57 | 58 | class encoder { 59 | private: 60 | int *output; 61 | unsigned int shreg; 62 | unsigned int shregmask; 63 | int _k; 64 | int _poly1; 65 | int _poly2; 66 | public: 67 | encoder(int k, int poly1, int poly2); 68 | ~encoder(); 69 | int encode(int bit); 70 | void init(void); 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/libsamplerate/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2002-2011 Erik de Castro Lopo 3 | ** 4 | ** This program is free software; you can redistribute it and/or modify 5 | ** it under the terms of the GNU General Public License as published by 6 | ** the Free Software Foundation; either version 2 of the License, or 7 | ** (at your option) any later version. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* 20 | ** This code is part of Secret Rabbit Code aka libsamplerate. A commercial 21 | ** use license for this code is available, please see: 22 | ** http://www.mega-nerd.com/SRC/procedure.html 23 | */ 24 | 25 | #ifndef COMMON_H_INCLUDED 26 | #define COMMON_H_INCLUDED 27 | 28 | #ifdef HAVE_STDINT_H 29 | #include 30 | #elif (SIZEOF_INT == 4) 31 | typedef int int32_t ; 32 | #elif (SIZEOF_LONG == 4) 33 | typedef long int32_t ; 34 | #endif 35 | 36 | #define SRC_MAX_RATIO 256 37 | #define SRC_MAX_RATIO_STR "256" 38 | 39 | #define SRC_MIN_RATIO_DIFF (1e-20) 40 | 41 | #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 42 | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) 43 | 44 | #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0]))) 45 | #define OFFSETOF(type,member) ((int) (&((type*) 0)->member)) 46 | 47 | #define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20)) 48 | 49 | /* 50 | ** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html 51 | */ 52 | #ifdef UNUSED 53 | #elif defined (__GNUC__) 54 | # define UNUSED(x) UNUSED_ ## x __attribute__ ((unused)) 55 | #elif defined (__LCLINT__) 56 | # define UNUSED(x) /*@unused@*/ x 57 | #else 58 | # define UNUSED(x) x 59 | #endif 60 | 61 | #ifdef __GNUC__ 62 | # define WARN_UNUSED __attribute__ ((warn_unused_result)) 63 | #else 64 | # define WARN_UNUSED 65 | #endif 66 | 67 | 68 | #include "samplerate.h" 69 | 70 | enum 71 | { SRC_FALSE = 0, 72 | SRC_TRUE = 1, 73 | 74 | SRC_MODE_PROCESS = 555, 75 | SRC_MODE_CALLBACK = 556 76 | } ; 77 | 78 | enum 79 | { SRC_ERR_NO_ERROR = 0, 80 | 81 | SRC_ERR_MALLOC_FAILED, 82 | SRC_ERR_BAD_STATE, 83 | SRC_ERR_BAD_DATA, 84 | SRC_ERR_BAD_DATA_PTR, 85 | SRC_ERR_NO_PRIVATE, 86 | SRC_ERR_BAD_SRC_RATIO, 87 | SRC_ERR_BAD_PROC_PTR, 88 | SRC_ERR_SHIFT_BITS, 89 | SRC_ERR_FILTER_LEN, 90 | SRC_ERR_BAD_CONVERTER, 91 | SRC_ERR_BAD_CHANNEL_COUNT, 92 | SRC_ERR_SINC_BAD_BUFFER_LEN, 93 | SRC_ERR_SIZE_INCOMPATIBILITY, 94 | SRC_ERR_BAD_PRIV_PTR, 95 | SRC_ERR_BAD_SINC_STATE, 96 | SRC_ERR_DATA_OVERLAP, 97 | SRC_ERR_BAD_CALLBACK, 98 | SRC_ERR_BAD_MODE, 99 | SRC_ERR_NULL_CALLBACK, 100 | SRC_ERR_NO_VARIABLE_RATIO, 101 | SRC_ERR_SINC_PREPARE_DATA_BAD_LEN, 102 | 103 | /* This must be the last error number. */ 104 | SRC_ERR_MAX_ERROR 105 | } ; 106 | 107 | typedef struct SRC_PRIVATE_tag 108 | { double last_ratio, last_position ; 109 | 110 | int error ; 111 | int channels ; 112 | 113 | /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */ 114 | int mode ; 115 | 116 | /* Pointer to data to converter specific data. */ 117 | void *private_data ; 118 | 119 | /* Varispeed process function. */ 120 | int (*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; 121 | 122 | /* Constant speed process function. */ 123 | int (*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; 124 | 125 | /* State reset. */ 126 | void (*reset) (struct SRC_PRIVATE_tag *psrc) ; 127 | 128 | /* Data specific to SRC_MODE_CALLBACK. */ 129 | src_callback_t callback_func ; 130 | void *user_callback_data ; 131 | long saved_frames ; 132 | float *saved_data ; 133 | } SRC_PRIVATE ; 134 | 135 | /* In src_sinc.c */ 136 | const char* sinc_get_name (int src_enum) ; 137 | const char* sinc_get_description (int src_enum) ; 138 | 139 | int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ; 140 | 141 | /* In src_linear.c */ 142 | const char* linear_get_name (int src_enum) ; 143 | const char* linear_get_description (int src_enum) ; 144 | 145 | int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ; 146 | 147 | /* In src_zoh.c */ 148 | const char* zoh_get_name (int src_enum) ; 149 | const char* zoh_get_description (int src_enum) ; 150 | 151 | int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ; 152 | 153 | /*---------------------------------------------------------- 154 | ** Common static inline functions. 155 | */ 156 | 157 | static inline double 158 | fmod_one (double x) 159 | { double res ; 160 | 161 | res = x - lrint (x) ; 162 | if (res < 0.0) 163 | return res + 1.0 ; 164 | 165 | return res ; 166 | } /* fmod_one */ 167 | 168 | #endif /* COMMON_H_INCLUDED */ 169 | 170 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/libsamplerate/config.h: -------------------------------------------------------------------------------- 1 | /* src/config.h. Generated from config.h.in by configure. */ 2 | /* src/config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Set to 1 if the compile is GNU GCC. */ 5 | #define COMPILER_IS_GCC 1 6 | 7 | /* Target processor clips on negative float to int conversion. */ 8 | #define CPU_CLIPS_NEGATIVE 0 9 | 10 | /* Target processor clips on positive float to int conversion. */ 11 | #define CPU_CLIPS_POSITIVE 0 12 | 13 | /* Target processor is big endian. */ 14 | #define CPU_IS_BIG_ENDIAN 0 15 | 16 | /* Target processor is little endian. */ 17 | #define CPU_IS_LITTLE_ENDIAN 1 18 | 19 | /* Major version of GCC or 3 otherwise. */ 20 | #define GCC_MAJOR_VERSION 4 21 | 22 | /* Define to 1 if you have the `alarm' function. */ 23 | #define HAVE_ALARM 1 24 | 25 | /* Define to 1 if you have the `calloc' function. */ 26 | #define HAVE_CALLOC 1 27 | 28 | /* Define to 1 if you have the `ceil' function. */ 29 | #define HAVE_CEIL 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_DLFCN_H 1 33 | 34 | /* Set to 1 if you have libfftw3. */ 35 | /* #undef HAVE_FFTW3 */ 36 | 37 | /* Define to 1 if you have the `floor' function. */ 38 | #define HAVE_FLOOR 1 39 | 40 | /* Define to 1 if you have the `fmod' function. */ 41 | #define HAVE_FMOD 1 42 | 43 | /* Define to 1 if you have the `free' function. */ 44 | #define HAVE_FREE 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_INTTYPES_H 1 48 | 49 | /* Define to 1 if you have the `m' library (-lm). */ 50 | #define HAVE_LIBM 1 51 | 52 | /* Define if you have C99's lrint function. */ 53 | #define HAVE_LRINT 1 54 | 55 | /* Define if you have C99's lrintf function. */ 56 | #define HAVE_LRINTF 1 57 | 58 | /* Define to 1 if you have the `malloc' function. */ 59 | #define HAVE_MALLOC 1 60 | 61 | /* Define to 1 if you have the `memcpy' function. */ 62 | #define HAVE_MEMCPY 1 63 | 64 | /* Define to 1 if you have the `memmove' function. */ 65 | #define HAVE_MEMMOVE 1 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_MEMORY_H 1 69 | 70 | /* Define if you have signal SIGALRM. */ 71 | #define HAVE_SIGALRM 1 72 | 73 | /* Define to 1 if you have the `signal' function. */ 74 | /* #undef HAVE_SIGNAL */ 75 | 76 | /* Set to 1 if you have libsndfile. */ 77 | #define HAVE_SNDFILE 0 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #define HAVE_STDINT_H 1 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #define HAVE_STDLIB_H 1 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #define HAVE_STRINGS_H 1 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #define HAVE_STRING_H 1 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #define HAVE_SYS_STAT_H 1 93 | 94 | /* Define to 1 if you have the header file. */ 95 | #define HAVE_SYS_TIMES_H 1 96 | 97 | /* Define to 1 if you have the header file. */ 98 | #define HAVE_SYS_TYPES_H 1 99 | 100 | /* Define to 1 if you have the header file. */ 101 | #define HAVE_UNISTD_H 1 102 | 103 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 104 | */ 105 | #define LT_OBJDIR ".libs/" 106 | 107 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 108 | /* #undef NO_MINUS_C_MINUS_O */ 109 | 110 | /* Set to 1 if compiling for Win32 */ 111 | #define OS_IS_WIN32 0 112 | 113 | /* Name of package */ 114 | #define PACKAGE "libsamplerate" 115 | 116 | /* Define to the address where bug reports for this package should be sent. */ 117 | #define PACKAGE_BUGREPORT "erikd@mega-nerd.com" 118 | 119 | /* Define to the full name of this package. */ 120 | #define PACKAGE_NAME "libsamplerate" 121 | 122 | /* Define to the full name and version of this package. */ 123 | #define PACKAGE_STRING "libsamplerate 0.1.8" 124 | 125 | /* Define to the one symbol short name of this package. */ 126 | #define PACKAGE_TARNAME "libsamplerate" 127 | 128 | /* Define to the home page for this package. */ 129 | #define PACKAGE_URL "http://www.mega-nerd.com/libsamplerate/" 130 | 131 | /* Define to the version of this package. */ 132 | #define PACKAGE_VERSION "0.1.8" 133 | 134 | /* The size of `double', as computed by sizeof. */ 135 | #define SIZEOF_DOUBLE 8 136 | 137 | /* The size of `float', as computed by sizeof. */ 138 | #define SIZEOF_FLOAT 4 139 | 140 | /* The size of `int', as computed by sizeof. */ 141 | #define SIZEOF_INT 4 142 | 143 | /* The size of `long', as computed by sizeof. */ 144 | #define SIZEOF_LONG 4 145 | 146 | /* Define to 1 if you have the ANSI C header files. */ 147 | #define STDC_HEADERS 1 148 | 149 | /* Version number of package */ 150 | #define VERSION "0.1.8" 151 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/libsamplerate/samplerate.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2002-2011 Erik de Castro Lopo 3 | ** 4 | ** This program is free software; you can redistribute it and/or modify 5 | ** it under the terms of the GNU General Public License as published by 6 | ** the Free Software Foundation; either version 2 of the License, or 7 | ** (at your option) any later version. 8 | ** 9 | ** This program is distributed in the hope that it will be useful, 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ** GNU General Public License for more details. 13 | ** 14 | ** You should have received a copy of the GNU General Public License 15 | ** along with this program; if not, write to the Free Software 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 17 | */ 18 | 19 | /* 20 | ** This code is part of Secret Rabbit Code aka libsamplerate. A commercial 21 | ** use license for this code is available, please see: 22 | ** http://www.mega-nerd.com/SRC/procedure.html 23 | */ 24 | 25 | /* 26 | ** API documentation is available here: 27 | ** http://www.mega-nerd.com/SRC/api.html 28 | */ 29 | 30 | #ifndef SAMPLERATE_H 31 | #define SAMPLERATE_H 32 | 33 | #ifdef __cplusplus 34 | //Android extern "C" { 35 | #endif /* __cplusplus */ 36 | 37 | 38 | /* Opaque data type SRC_STATE. */ 39 | typedef struct SRC_STATE_tag SRC_STATE ; 40 | 41 | /* SRC_DATA is used to pass data to src_simple() and src_process(). */ 42 | typedef struct 43 | { float *data_in, *data_out ; 44 | 45 | long input_frames, output_frames ; 46 | long input_frames_used, output_frames_gen ; 47 | 48 | int end_of_input ; 49 | 50 | double src_ratio ; 51 | } SRC_DATA ; 52 | 53 | /* SRC_CB_DATA is used with callback based API. */ 54 | typedef struct 55 | { long frames ; 56 | float *data_in ; 57 | } SRC_CB_DATA ; 58 | 59 | /* 60 | ** User supplied callback function type for use with src_callback_new() 61 | ** and src_callback_read(). First parameter is the same pointer that was 62 | ** passed into src_callback_new(). Second parameter is pointer to a 63 | ** pointer. The user supplied callback function must modify *data to 64 | ** point to the start of the user supplied float array. The user supplied 65 | ** function must return the number of frames that **data points to. 66 | */ 67 | 68 | typedef long (*src_callback_t) (void *cb_data, float **data) ; 69 | 70 | /* 71 | ** Standard initialisation function : return an anonymous pointer to the 72 | ** internal state of the converter. Choose a converter from the enums below. 73 | ** Error returned in *error. 74 | */ 75 | 76 | SRC_STATE* src_new (int converter_type, int channels, int *error) ; 77 | 78 | /* 79 | ** Initilisation for callback based API : return an anonymous pointer to the 80 | ** internal state of the converter. Choose a converter from the enums below. 81 | ** The cb_data pointer can point to any data or be set to NULL. Whatever the 82 | ** value, when processing, user supplied function "func" gets called with 83 | ** cb_data as first parameter. 84 | */ 85 | 86 | SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels, 87 | int *error, void* cb_data) ; 88 | 89 | /* 90 | ** Cleanup all internal allocations. 91 | ** Always returns NULL. 92 | */ 93 | 94 | SRC_STATE* src_delete (SRC_STATE *state) ; 95 | 96 | /* 97 | ** Standard processing function. 98 | ** Returns non zero on error. 99 | */ 100 | 101 | int src_process (SRC_STATE *state, SRC_DATA *data) ; 102 | 103 | /* 104 | ** Callback based processing function. Read up to frames worth of data from 105 | ** the converter int *data and return frames read or -1 on error. 106 | */ 107 | long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ; 108 | 109 | /* 110 | ** Simple interface for performing a single conversion from input buffer to 111 | ** output buffer at a fixed conversion ratio. 112 | ** Simple interface does not require initialisation as it can only operate on 113 | ** a single buffer worth of audio. 114 | */ 115 | 116 | int src_simple (SRC_DATA *data, int converter_type, int channels) ; 117 | 118 | /* 119 | ** This library contains a number of different sample rate converters, 120 | ** numbered 0 through N. 121 | ** 122 | ** Return a string giving either a name or a more full description of each 123 | ** sample rate converter or NULL if no sample rate converter exists for 124 | ** the given value. The converters are sequentially numbered from 0 to N. 125 | */ 126 | 127 | const char *src_get_name (int converter_type) ; 128 | const char *src_get_description (int converter_type) ; 129 | const char *src_get_version (void) ; 130 | 131 | /* 132 | ** Set a new SRC ratio. This allows step responses 133 | ** in the conversion ratio. 134 | ** Returns non zero on error. 135 | */ 136 | 137 | int src_set_ratio (SRC_STATE *state, double new_ratio) ; 138 | 139 | /* 140 | ** Reset the internal SRC state. 141 | ** Does not modify the quality settings. 142 | ** Does not free any memory allocations. 143 | ** Returns non zero on error. 144 | */ 145 | 146 | int src_reset (SRC_STATE *state) ; 147 | 148 | /* 149 | ** Return TRUE if ratio is a valid conversion ratio, FALSE 150 | ** otherwise. 151 | */ 152 | 153 | int src_is_valid_ratio (double ratio) ; 154 | 155 | /* 156 | ** Return an error number. 157 | */ 158 | 159 | int src_error (SRC_STATE *state) ; 160 | 161 | /* 162 | ** Convert the error number into a string. 163 | */ 164 | const char* src_strerror (int error) ; 165 | 166 | /* 167 | ** The following enums can be used to set the interpolator type 168 | ** using the function src_set_converter(). 169 | */ 170 | 171 | enum 172 | { 173 | SRC_SINC_BEST_QUALITY = 0, 174 | SRC_SINC_MEDIUM_QUALITY = 1, 175 | SRC_SINC_FASTEST = 2, 176 | SRC_ZERO_ORDER_HOLD = 3, 177 | SRC_LINEAR = 4, 178 | } ; 179 | 180 | /* 181 | ** Extra helper functions for converting from short to float and 182 | ** back again. 183 | */ 184 | 185 | void src_short_to_float_array (const short *in, float *out, int len) ; 186 | void src_float_to_short_array (const float *in, short *out, int len) ; 187 | 188 | void src_int_to_float_array (const int *in, float *out, int len) ; 189 | void src_float_to_int_array (const float *in, int *out, int len) ; 190 | 191 | 192 | #ifdef __cplusplus 193 | } /* extern "C" */ 194 | #endif /* __cplusplus */ 195 | 196 | #endif /* SAMPLERATE_H */ 197 | 198 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/mfsk/interleave.cxx: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // interleave.cxx -- MFSK (de)interleaver 3 | // 4 | // Copyright (C) 2006-2008 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. Adapted from code contained in gmfsk source 8 | // code 9 | // distribution. 10 | // gmfsk Copyright (C) 2001, 2002, 2003 11 | // Tomi Manninen (oh2bns@sral.fi) 12 | // 13 | // Fldigi is free software: you can redistribute it and/or modify 14 | // it under the terms of the GNU General Public License as published by 15 | // the Free Software Foundation, either version 3 of the License, or 16 | // (at your option) any later version. 17 | // 18 | // Fldigi is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | // GNU General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU General Public License 24 | // along with fldigi. If not, see . 25 | // ---------------------------------------------------------------------------- 26 | 27 | // Android #include 28 | 29 | #include 30 | 31 | #include "interleave.h" 32 | 33 | // ---------------------------------------------------------------------- 34 | 35 | interleave::interleave(int _size, int _depth, int dir) { 36 | size = _size; 37 | depth = _depth; 38 | direction = dir; 39 | len = size * size * depth; 40 | table = new unsigned char[len]; 41 | flush(); 42 | } 43 | 44 | interleave::~interleave() { delete[] table; } 45 | 46 | void interleave::symbols(unsigned char *psyms) { 47 | int i, j, k; 48 | 49 | for (k = 0; k < depth; k++) { 50 | for (i = 0; i < size; i++) 51 | for (j = 0; j < size - 1; j++) 52 | *tab(k, i, j) = *tab(k, i, j + 1); 53 | 54 | for (i = 0; i < size; i++) 55 | *tab(k, i, size - 1) = psyms[i]; 56 | 57 | for (i = 0; i < size; i++) { 58 | if (direction == INTERLEAVE_FWD) 59 | psyms[i] = *tab(k, i, size - i - 1); 60 | else 61 | psyms[i] = *tab(k, i, i); 62 | } 63 | } 64 | } 65 | 66 | void interleave::bits(unsigned int *pbits) { 67 | unsigned char syms[size]; 68 | int i; 69 | 70 | for (i = 0; i < size; i++) 71 | syms[i] = (*pbits >> (size - i - 1)) & 1; 72 | 73 | symbols(syms); 74 | 75 | for (*pbits = i = 0; i < size; i++) 76 | *pbits = (*pbits << 1) | syms[i]; 77 | } 78 | 79 | void interleave::flush(void) { 80 | // Fill entire RX interleaver with punctures or 0 depending on whether 81 | // Rx or Tx 82 | if (direction == INTERLEAVE_REV) 83 | memset(table, PUNCTURE, len); 84 | else 85 | memset(table, 0, len); 86 | } 87 | 88 | // ---------------------------------------------------------------------- 89 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/mfsk/mfskvaricode.cxx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eurecom-s3/noise-sdr/06e12a0baa35f3e0defc2727516706c97dd77419/fldigi-noise-sdr/src/fldigi/mfsk/mfskvaricode.cxx -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/misc/configuration.cxx: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // configuration.cxx 3 | // 4 | // Copyright (C) 2006-2010 5 | // Dave Freese, W1HKJ 6 | // Copyright (C) 2007-2008 7 | // Leigh L. Klotz, Jr., WA5ZNU 8 | // Copyright (C) 2007-2010 9 | // Stelios Bounanos, M0GLD 10 | // Copyright (C) 2013 11 | // Remi Chateauneu, F4ECW 12 | // 13 | // This file is part of fldigi. 14 | // 15 | // Fldigi is free software: you can redistribute it and/or modify 16 | // it under the terms of the GNU General Public License as published by 17 | // the Free Software Foundation, either version 3 of the License, or 18 | // (at your option) any later version. 19 | // 20 | // Fldigi is distributed in the hope that it will be useful, 21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | // GNU General Public License for more details. 24 | // 25 | // You should have received a copy of the GNU General Public License 26 | // along with fldigi. If not, see . 27 | // ---------------------------------------------------------------------------- 28 | 29 | // Android#include 30 | 31 | #include "configuration.h" 32 | //#include "confdialog.h" 33 | //#include "xmlreader.h" 34 | //#include "soundconf.h" 35 | //#include "fl_digi.h" 36 | //#include "main.h" 37 | //#include "gettext.h" 38 | //#include "nls.h" 39 | //#include "icons.h" 40 | 41 | #if USE_HAMLIB 42 | #include "hamlib.h" 43 | #include "rigclass.h" 44 | #endif 45 | 46 | //#include "rigio.h" 47 | //#include "rigxml.h" 48 | //#include "debug.h" 49 | 50 | //#include 51 | 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | #ifdef __linux__ 59 | #include 60 | #include 61 | #include 62 | //# include 63 | #endif 64 | #ifdef __APPLE__ 65 | #include 66 | #endif 67 | #ifndef __CYGWIN__ 68 | #include 69 | #else 70 | #include 71 | #endif 72 | 73 | // this tests depends on a modified FL/filename.H in the Fltk-1.3.0 74 | // change 75 | //# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) 76 | // to 77 | //# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) && 78 | //! defined(__WOE32__) 79 | 80 | #include 81 | 82 | using namespace std; 83 | 84 | // By redefining the ELEM_ macro, we can control what the CONFIG_LIST macro 85 | // will expand to, and accomplish several things: 86 | // 1) Declare "struct configuration". See ELEM_DECLARE_CONFIGURATION 87 | // in configuration.h. 88 | // 2) Define progdefaults, the configuration struct that is initialised with 89 | // fldigi's default options 90 | #define ELEM_PROGDEFAULTS(type_, var_, tag_, doc_, ...) __VA_ARGS__, 91 | // 3) Define an array of tag element pointers 92 | //Android #define ELEM_TAG_ARRAY(type_, var_, tag_, doc_, ...) \ 93 | // (*tag_ ? new tag_elem(tag_, "type: " #type_ "; default: " #__VA_ARGS__ "\n" doc_, \ 94 | // progdefaults.var_) : 0), 95 | 96 | // First define the default config 97 | #undef ELEM_ 98 | #define ELEM_ ELEM_PROGDEFAULTS 99 | configuration progdefaults = {CONFIG_LIST}; 100 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/misc/misc.cxx: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // misc.cxx -- Miscellaneous helper functions 3 | // 4 | // Copyright (C) 2006-2007 5 | // Dave Freese, W1HKJ 6 | // 7 | // This file is part of fldigi. These filters were adapted from code contained 8 | // in the gmfsk source code distribution. 9 | // 10 | // Fldigi is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Fldigi is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with fldigi. If not, see . 22 | // ---------------------------------------------------------------------------- 23 | 24 | // Android #include 25 | 26 | #include "misc.h" 27 | #include 28 | 29 | // ---------------------------------------------------------------------------- 30 | 31 | /* 32 | * Hamming weight (number of bits that are ones). 33 | */ 34 | unsigned long hweight32(unsigned long w) { 35 | w = (w & 0x55555555) + ((w >> 1) & 0x55555555); 36 | w = (w & 0x33333333) + ((w >> 2) & 0x33333333); 37 | w = (w & 0x0F0F0F0F) + ((w >> 4) & 0x0F0F0F0F); 38 | w = (w & 0x00FF00FF) + ((w >> 8) & 0x00FF00FF); 39 | w = (w & 0x0000FFFF) + ((w >> 16) & 0x0000FFFF); 40 | return w; 41 | } 42 | 43 | unsigned short int hweight16(unsigned short int w) { 44 | w = (w & 0x5555) + ((w >> 1) & 0x5555); 45 | w = (w & 0x3333) + ((w >> 2) & 0x3333); 46 | w = (w & 0x0F0F) + ((w >> 4) & 0x0F0F); 47 | w = (w & 0x00FF) + ((w >> 8) & 0x00FF); 48 | return w; 49 | } 50 | 51 | unsigned char hweight8(unsigned char w) { 52 | w = (w & 0x55) + ((w >> 1) & 0x55); 53 | w = (w & 0x33) + ((w >> 2) & 0x33); 54 | w = (w & 0x0F) + ((w >> 4) & 0x0F); 55 | return w; 56 | } 57 | 58 | // ---------------------------------------------------------------------------- 59 | 60 | /* 61 | * Parity function. Return one if `w' has odd number of ones, zero otherwise. 62 | */ 63 | 64 | int parity(unsigned long w) { return hweight32(w) & 1; } 65 | 66 | // ---------------------------------------------------------------------------- 67 | 68 | /* 69 | * Reverse order of bits. 70 | */ 71 | unsigned long rbits32(unsigned long w) { 72 | w = ((w >> 1) & 0x55555555) | ((w << 1) & 0xAAAAAAAA); 73 | w = ((w >> 2) & 0x33333333) | ((w << 2) & 0xCCCCCCCC); 74 | w = ((w >> 4) & 0x0F0F0F0F) | ((w << 4) & 0xF0F0F0F0); 75 | w = ((w >> 8) & 0x00FF00FF) | ((w << 8) & 0xFF00FF00); 76 | w = ((w >> 16) & 0x0000FFFF) | ((w << 16) & 0xFFFF0000); 77 | return w; 78 | } 79 | 80 | unsigned short int rbits16(unsigned short int w) { 81 | w = ((w >> 1) & 0x5555) | ((w << 1) & 0xAAAA); 82 | w = ((w >> 2) & 0x3333) | ((w << 2) & 0xCCCC); 83 | w = ((w >> 4) & 0x0F0F) | ((w << 4) & 0xF0F0); 84 | w = ((w >> 8) & 0x00FF) | ((w << 8) & 0xFF00); 85 | return w; 86 | } 87 | 88 | unsigned char rbits8(unsigned char w) { 89 | w = ((w >> 1) & 0x55) | ((w << 1) & 0xFF); 90 | w = ((w >> 2) & 0x33) | ((w << 2) & 0xCC); 91 | w = ((w >> 4) & 0x0F) | ((w << 4) & 0xF0); 92 | return w; 93 | } 94 | 95 | // ---------------------------------------------------------------------------- 96 | 97 | // Integer base-2 logarithm 98 | 99 | unsigned int log2u(unsigned int x) { 100 | int y = 0; 101 | x >>= 1; 102 | while (x) { 103 | x >>= 1; 104 | y++; 105 | } 106 | return y; 107 | } 108 | 109 | // ---------------------------------------------------------------------------- 110 | 111 | // Gray encoding and decoding (8 bit) 112 | 113 | unsigned char grayencode(unsigned char data) 114 | // unsigned char graydecode(unsigned char data) 115 | { 116 | unsigned char bits = data; 117 | 118 | bits ^= data >> 1; 119 | bits ^= data >> 2; 120 | bits ^= data >> 3; 121 | bits ^= data >> 4; 122 | bits ^= data >> 5; 123 | bits ^= data >> 6; 124 | bits ^= data >> 7; 125 | 126 | return bits; 127 | } 128 | 129 | unsigned char graydecode(unsigned char data) 130 | // unsigned char grayencode(unsigned char data) 131 | { 132 | return data ^ (data >> 1); 133 | } 134 | 135 | // ---------------------------------------------------------------------------- 136 | 137 | // Rectangular - no pre filtering of data array 138 | void RectWindow(double *array, int n) { 139 | for (int i = 0; i < n; i++) 140 | array[i] = 1.0; 141 | } 142 | 143 | // Hamming - used by gmfsk 144 | void HammingWindow(double *array, int n) { 145 | double pwr = 0.0; 146 | double inv_n = 1.0 / (double)n; 147 | for (int i = 0; i < n; i++) { 148 | array[i] = hamming((double)i * inv_n); 149 | pwr += array[i] * array[i]; 150 | } 151 | pwr = sqrt((double)n / pwr); 152 | for (int i = 0; i < n; i++) 153 | array[i] *= pwr; 154 | } 155 | 156 | // Hanning - used by winpsk 157 | void HanningWindow(double *array, int n) { 158 | double pwr = 0.0; 159 | double inv_n = 1.0 / (double)n; 160 | for (int i = 0; i < n; i++) { 161 | array[i] = hanning((double)i * inv_n); 162 | pwr += array[i] * array[i]; 163 | } 164 | pwr = sqrt((double)n / pwr); 165 | for (int i = 0; i < n; i++) 166 | array[i] *= pwr; 167 | } 168 | 169 | // Best lob suppression - least in band ripple 170 | void BlackmanWindow(double *array, int n) { 171 | double pwr = 0.0; 172 | double inv_n = 1.0 / (double)n; 173 | for (int i = 0; i < n; i++) { 174 | array[i] = blackman((double)i * inv_n); 175 | pwr += array[i] * array[i]; 176 | } 177 | pwr = sqrt((double)n / pwr); 178 | for (int i = 0; i < n; i++) 179 | array[i] *= pwr; 180 | } 181 | 182 | // Simple about effective as Hamming or Hanning 183 | void TriangularWindow(double *array, int n) { 184 | double pwr = 0.0; 185 | for (int i = 0; i < n; i++) 186 | array[i] = 1.0; 187 | double inv_n = 1.0 / (double)n; 188 | for (int i = 0; i < n / 4; i++) { 189 | array[i] = 4.0 * (double)i * inv_n; 190 | array[n - i] = array[i]; 191 | } 192 | for (int i = 0; i < n; i++) 193 | pwr += array[i] * array[i]; 194 | pwr = sqrt((double)n / pwr); 195 | for (int i = 0; i < n; i++) 196 | array[i] *= pwr; 197 | } 198 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/mt63/alias_1k.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * alias_1k.dat -- Anti-alias filter 1000 Hz bandwidth 3 | * 4 | * Copyright (C) 1999-2004 Pawel Jalocha, SP9VRC 5 | * 6 | * This file is part of fldigi. 7 | * 8 | * Fldigi is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Fldigi is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with fldigi. If not, see . 20 | * 21 | */ 22 | 23 | // Filter coefficiants made by ALIAS.C for the following parameters: 24 | // FilterLen=64 SampleRate=8000.0 FreqLow=500.0 FreqUpp=1500.0 25 | // PassBandLow=375.0 PassBandUpp=1625.0 StopBandLow=0.0 StopBandUpp=2000.0 26 | // => PeakInStopBand=-90.99 dB 27 | // Programmers's scale factor: 2.000000 28 | // Programmers's comments: Anti-alias filter 1000 Hz bandwidth, decimation by 4 29 | 30 | const int Alias_1k_Len=64; 31 | 32 | double Alias_1k_I[Alias_1k_Len] = { 33 | +0.00003605 , // 0 34 | +0.00001835 , // 1 35 | -0.00022227 , // 2 36 | -0.00079785 , // 3 37 | -0.00099442 , // 4 38 | +0.00032296 , // 5 39 | +0.00276603 , // 6 40 | +0.00365685 , // 7 41 | +0.00128973 , // 8 42 | -0.00107943 , // 9 43 | +0.00195568 , // 10 44 | +0.00914871 , // 11 45 | +0.01100689 , // 12 46 | +0.00254789 , // 13 47 | -0.00580382 , // 14 48 | -0.00014844 , // 15 49 | +0.01341757 , // 16 50 | +0.01123057 , // 17 51 | -0.01328109 , // 18 52 | -0.03176715 , // 19 53 | -0.01791993 , // 20 54 | +0.00579429 , // 21 55 | -0.00986091 , // 22 56 | -0.06425601 , // 23 57 | -0.08967807 , // 24 58 | -0.04429128 , // 25 59 | +0.00513920 , // 26 60 | -0.04459511 , // 27 61 | -0.16886923 , // 28 62 | -0.19065374 , // 29 63 | +0.01930718 , // 30 64 | +0.34486939 , // 31 65 | +0.50345887 , // 32 66 | +0.34486939 , // 33 67 | +0.01930718 , // 34 68 | -0.19065374 , // 35 69 | -0.16886923 , // 36 70 | -0.04459511 , // 37 71 | +0.00513920 , // 38 72 | -0.04429128 , // 39 73 | -0.08967807 , // 40 74 | -0.06425601 , // 41 75 | -0.00986091 , // 42 76 | +0.00579429 , // 43 77 | -0.01791993 , // 44 78 | -0.03176715 , // 45 79 | -0.01328109 , // 46 80 | +0.01123057 , // 47 81 | +0.01341757 , // 48 82 | -0.00014844 , // 49 83 | -0.00580382 , // 50 84 | +0.00254789 , // 51 85 | +0.01100689 , // 52 86 | +0.00914871 , // 53 87 | +0.00195568 , // 54 88 | -0.00107943 , // 55 89 | +0.00128973 , // 56 90 | +0.00365685 , // 57 91 | +0.00276603 , // 58 92 | +0.00032296 , // 59 93 | -0.00099442 , // 60 94 | -0.00079785 , // 61 95 | -0.00022227 , // 62 96 | +0.00001835 // 63 97 | } ; 98 | 99 | double Alias_1k_Q[Alias_1k_Len] = { 100 | -0.00000000 , // 0 101 | -0.00009527 , // 1 102 | -0.00023082 , // 2 103 | +0.00005162 , // 3 104 | +0.00123007 , // 4 105 | +0.00255193 , // 5 106 | +0.00207549 , // 6 107 | -0.00064302 , // 7 108 | -0.00244045 , // 8 109 | +0.00005205 , // 9 110 | +0.00410793 , // 10 111 | +0.00211830 , // 11 112 | -0.00729235 , // 12 113 | -0.01359800 , // 13 114 | -0.00757272 , // 14 115 | +0.00172023 , // 15 116 | -0.00460378 , // 16 117 | -0.02559228 , // 17 118 | -0.03408530 , // 18 119 | -0.01416468 , // 19 120 | +0.00731461 , // 20 121 | -0.00712536 , // 21 122 | -0.04328548 , // 22 123 | -0.04099291 , // 23 124 | +0.01821691 , // 24 125 | +0.06428190 , // 25 126 | +0.02790538 , // 26 127 | -0.03602086 , // 27 128 | +0.01583703 , // 28 129 | +0.22015579 , // 29 130 | +0.40003327 , // 30 131 | +0.32856209 , // 31 132 | -0.00000000 , // 32 133 | -0.32856209 , // 33 134 | -0.40003327 , // 34 135 | -0.22015579 , // 35 136 | -0.01583703 , // 36 137 | +0.03602086 , // 37 138 | -0.02790538 , // 38 139 | -0.06428190 , // 39 140 | -0.01821691 , // 40 141 | +0.04099291 , // 41 142 | +0.04328548 , // 42 143 | +0.00712536 , // 43 144 | -0.00731461 , // 44 145 | +0.01416468 , // 45 146 | +0.03408530 , // 46 147 | +0.02559228 , // 47 148 | +0.00460378 , // 48 149 | -0.00172023 , // 49 150 | +0.00757272 , // 50 151 | +0.01359800 , // 51 152 | +0.00729235 , // 52 153 | -0.00211830 , // 53 154 | -0.00410793 , // 54 155 | -0.00005205 , // 55 156 | +0.00244045 , // 56 157 | +0.00064302 , // 57 158 | -0.00207549 , // 58 159 | -0.00255193 , // 59 160 | -0.00123007 , // 60 161 | -0.00005162 , // 61 162 | +0.00023082 , // 62 163 | +0.00009527 // 63 164 | } ; 165 | 166 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/mt63/alias_2k.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * alias_2k.dat -- Anti-alias filter 2000 Hz bandwidth 3 | * 4 | * Copyright (C) 1999-2004 Pawel Jalocha, SP9VRC 5 | * 6 | * This file is part of fldigi. 7 | * 8 | * Fldigi is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Fldigi is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with fldigi. If not, see . 20 | * 21 | */ 22 | 23 | // Filter coefficiants made by ALIAS.C for the following parameters: 24 | // FilterLen=64 SampleRate=8000.0 FreqLow=500.0 FreqUpp=2500.0 25 | // PassBandLow=375.0 PassBandUpp=2625.0 StopBandLow=0.0 StopBandUpp=3000.0 26 | // => PeakInStopBand=-89.35 dB 27 | // Programmers's scale factor: 1.000000 28 | // Programmers's comments: Anti-alias filter 2000 Hz bandwidth, decimation by 2 29 | 30 | const int Alias_2k_Len=64; 31 | 32 | double Alias_2k_I[Alias_2k_Len] = { 33 | +0.00007244 , // 0 34 | +0.00002831 , // 1 35 | -0.00031179 , // 2 36 | -0.00027704 , // 3 37 | +0.00026218 , // 4 38 | -0.00057780 , // 5 39 | -0.00083336 , // 6 40 | +0.00119188 , // 7 41 | +0.00014945 , // 8 42 | -0.00077327 , // 9 43 | +0.00360739 , // 10 44 | +0.00224833 , // 11 45 | -0.00032116 , // 12 46 | +0.00696821 , // 13 47 | +0.00439713 , // 14 48 | -0.00157675 , // 15 49 | +0.00906983 , // 16 50 | +0.00372045 , // 17 51 | -0.00786599 , // 18 52 | +0.00735339 , // 19 53 | -0.00253048 , // 20 54 | -0.02189728 , // 21 55 | +0.00134354 , // 22 56 | -0.01477966 , // 23 57 | -0.04434362 , // 24 58 | -0.00479913 , // 25 59 | -0.03000591 , // 26 60 | -0.07609801 , // 27 61 | +0.00258946 , // 28 62 | -0.04271980 , // 29 63 | -0.14710769 , // 30 64 | +0.14198817 , // 31 65 | +0.42372962 , // 32 66 | +0.14198817 , // 33 67 | -0.14710769 , // 34 68 | -0.04271980 , // 35 69 | +0.00258946 , // 36 70 | -0.07609801 , // 37 71 | -0.03000591 , // 38 72 | -0.00479913 , // 39 73 | -0.04434362 , // 40 74 | -0.01477966 , // 41 75 | +0.00134354 , // 42 76 | -0.02189728 , // 43 77 | -0.00253048 , // 44 78 | +0.00735339 , // 45 79 | -0.00786599 , // 46 80 | +0.00372045 , // 47 81 | +0.00906983 , // 48 82 | -0.00157675 , // 49 83 | +0.00439713 , // 50 84 | +0.00696821 , // 51 85 | -0.00032116 , // 52 86 | +0.00224833 , // 53 87 | +0.00360739 , // 54 88 | -0.00077327 , // 55 89 | +0.00014945 , // 56 90 | +0.00119188 , // 57 91 | -0.00083336 , // 58 92 | -0.00057780 , // 59 93 | +0.00026218 , // 60 94 | -0.00027704 , // 61 95 | -0.00031179 , // 62 96 | +0.00002831 // 63 97 | } ; 98 | 99 | double Alias_2k_Q[Alias_2k_Len] = { 100 | -0.00000000 , // 0 101 | -0.00015159 , // 1 102 | -0.00014608 , // 2 103 | +0.00036770 , // 3 104 | +0.00010339 , // 4 105 | -0.00031581 , // 5 106 | +0.00128580 , // 6 107 | +0.00120582 , // 7 108 | -0.00051862 , // 8 109 | +0.00225671 , // 9 110 | +0.00226918 , // 10 111 | -0.00216340 , // 11 112 | +0.00181728 , // 12 113 | +0.00176390 , // 13 114 | -0.00692361 , // 14 115 | -0.00105199 , // 15 116 | -0.00081355 , // 16 117 | -0.01498960 , // 17 118 | -0.00512332 , // 18 119 | -0.00331671 , // 19 120 | -0.02395357 , // 20 121 | -0.00602102 , // 21 122 | -0.00049919 , // 22 123 | -0.02943663 , // 23 124 | +0.00351421 , // 24 125 | +0.01576926 , // 25 126 | -0.02737092 , // 26 127 | +0.03572558 , // 27 128 | +0.06272088 , // 28 129 | -0.01659059 , // 29 130 | +0.15254255 , // 30 131 | +0.33394426 , // 31 132 | -0.00000000 , // 32 133 | -0.33394426 , // 33 134 | -0.15254255 , // 34 135 | +0.01659059 , // 35 136 | -0.06272088 , // 36 137 | -0.03572558 , // 37 138 | +0.02737092 , // 38 139 | -0.01576926 , // 39 140 | -0.00351421 , // 40 141 | +0.02943663 , // 41 142 | +0.00049919 , // 42 143 | +0.00602102 , // 43 144 | +0.02395357 , // 44 145 | +0.00331671 , // 45 146 | +0.00512332 , // 46 147 | +0.01498960 , // 47 148 | +0.00081355 , // 48 149 | +0.00105199 , // 49 150 | +0.00692361 , // 50 151 | -0.00176390 , // 51 152 | -0.00181728 , // 52 153 | +0.00216340 , // 53 154 | -0.00226918 , // 54 155 | -0.00225671 , // 55 156 | +0.00051862 , // 56 157 | -0.00120582 , // 57 158 | -0.00128580 , // 58 159 | +0.00031581 , // 59 160 | -0.00010339 , // 60 161 | -0.00036770 , // 61 162 | +0.00014608 , // 62 163 | +0.00015159 // 63 164 | } ; 165 | 166 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/mt63/morse.dat: -------------------------------------------------------------------------------- 1 | // computer readable Morse code table 2 | // 3 | // For a given character you should pick up a 31-bit code from the table. 4 | // Bits should be taken starting from the LSB. 5 | // Bit equal 1 means carrier ON, bit 0 means carrier off 6 | // Each code includes one quiet dot at the start and two at the end. 7 | // The code should be read until the last '1', 8 | // but this last '1' must not be transmitted 9 | // 10 | const int MorseTableSize=128; 11 | long MorseTable[MorseTableSize] = { 12 | 0x00000004L , // 0x00 13 | 0x00000004L , // 0x01 14 | 0x00000004L , // 0x02 15 | 0x00000004L , // 0x03 16 | 0x00000004L , // 0x04 17 | 0x00000004L , // 0x05 18 | 0x00000004L , // 0x06 19 | 0x00000004L , // 0x07 20 | 0x00000004L , // 0x08 21 | 0x00000004L , // 0x09 22 | 0x00000004L , // 0x0A 23 | 0x00000004L , // 0x0B 24 | 0x00000004L , // 0x0C 25 | 0x00000004L , // 0x0D 26 | 0x00000004L , // 0x0E 27 | 0x00000004L , // 0x0F 28 | 0x00000004L , // 0x10 29 | 0x00000004L , // 0x11 30 | 0x00000004L , // 0x12 31 | 0x00000004L , // 0x13 32 | 0x00000004L , // 0x14 33 | 0x00000004L , // 0x15 34 | 0x00000004L , // 0x16 35 | 0x00000004L , // 0x17 36 | 0x00000004L , // 0x18 37 | 0x00000004L , // 0x19 38 | 0x00000004L , // 0x1A 39 | 0x00000004L , // 0x1B 40 | 0x00000004L , // 0x1C 41 | 0x00000004L , // 0x1D 42 | 0x00000004L , // 0x1E 43 | 0x00000004L , // 0x1F 44 | 0x00000004L , // 0x20 = ' ' 45 | 0x00000004L , // 0x21 = '!' 46 | 0x00000004L , // 0x22 = '"' 47 | 0x00000004L , // 0x23 = '#' 48 | 0x0013ABAAL , // 0x24 = '$' 49 | 0x00000004L , // 0x25 = '%' 50 | 0x00000004L , // 0x26 = '&' 51 | 0x004BBBBAL , // 0x27 = ''' 52 | 0x0004BBAEL , // 0x28 = '(' 53 | 0x004EBBAEL , // 0x29 = ')' 54 | 0x0004BABAL , // 0x2A = '*' 55 | 0x00012EBAL , // 0x2B = '+' 56 | 0x004EEAEEL , // 0x2C = ',' 57 | 0x0004EAAEL , // 0x2D = '-' 58 | 0x0013AEBAL , // 0x2E = '.' 59 | 0x00012EAEL , // 0x2F = '/' 60 | 0x004EEEEEL , // 0x30 = '0' 61 | 0x0013BBBAL , // 0x31 = '1' 62 | 0x0004EEEAL , // 0x32 = '2' 63 | 0x00013BAAL , // 0x33 = '3' 64 | 0x00004EAAL , // 0x34 = '4' 65 | 0x000012AAL , // 0x35 = '5' 66 | 0x00004AAEL , // 0x36 = '6' 67 | 0x00012AEEL , // 0x37 = '7' 68 | 0x0004AEEEL , // 0x38 = '8' 69 | 0x0012EEEEL , // 0x39 = '9' 70 | 0x0012AEEEL , // 0x3A = ':' 71 | 0x0012EBAEL , // 0x3B = ';' 72 | 0x00000004L , // 0x3C = '<' 73 | 0x00013AAEL , // 0x3D = '=' 74 | 0x00000004L , // 0x3E = '>' 75 | 0x0004AEEAL , // 0x3F = '?' 76 | 0x00000004L , // 0x40 = '@' 77 | 0x0000013AL , // 0x41 = 'A' 78 | 0x000012AEL , // 0x42 = 'B' 79 | 0x00004BAEL , // 0x43 = 'C' 80 | 0x000004AEL , // 0x44 = 'D' 81 | 0x00000012L , // 0x45 = 'E' 82 | 0x000012EAL , // 0x46 = 'F' 83 | 0x000012EEL , // 0x47 = 'G' 84 | 0x000004AAL , // 0x48 = 'H' 85 | 0x0000004AL , // 0x49 = 'I' 86 | 0x00013BBAL , // 0x4A = 'J' 87 | 0x000013AEL , // 0x4B = 'K' 88 | 0x000012BAL , // 0x4C = 'L' 89 | 0x000004EEL , // 0x4D = 'M' 90 | 0x0000012EL , // 0x4E = 'N' 91 | 0x00004EEEL , // 0x4F = 'O' 92 | 0x00004BBAL , // 0x50 = 'P' 93 | 0x00013AEEL , // 0x51 = 'Q' 94 | 0x000004BAL , // 0x52 = 'R' 95 | 0x0000012AL , // 0x53 = 'S' 96 | 0x0000004EL , // 0x54 = 'T' 97 | 0x000004EAL , // 0x55 = 'U' 98 | 0x000013AAL , // 0x56 = 'V' 99 | 0x000013BAL , // 0x57 = 'W' 100 | 0x00004EAEL , // 0x58 = 'X' 101 | 0x00013BAEL , // 0x59 = 'Y' 102 | 0x00004AEEL , // 0x5A = 'Z' 103 | 0x00000004L , // 0x5B = '[' 104 | 0x00000004L , // 0x5C = '\' 105 | 0x00000004L , // 0x5D = ']' 106 | 0x00000004L , // 0x5E = '^' 107 | 0x0013AEEAL , // 0x5F = '_' 108 | 0x00000004L , // 0x60 = '`' 109 | 0x0000013AL , // 0x61 = 'a' 110 | 0x000012AEL , // 0x62 = 'b' 111 | 0x00004BAEL , // 0x63 = 'c' 112 | 0x000004AEL , // 0x64 = 'd' 113 | 0x00000012L , // 0x65 = 'e' 114 | 0x000012EAL , // 0x66 = 'f' 115 | 0x000012EEL , // 0x67 = 'g' 116 | 0x000004AAL , // 0x68 = 'h' 117 | 0x0000004AL , // 0x69 = 'i' 118 | 0x00013BBAL , // 0x6A = 'j' 119 | 0x000013AEL , // 0x6B = 'k' 120 | 0x000012BAL , // 0x6C = 'l' 121 | 0x000004EEL , // 0x6D = 'm' 122 | 0x0000012EL , // 0x6E = 'n' 123 | 0x00004EEEL , // 0x6F = 'o' 124 | 0x00004BBAL , // 0x70 = 'p' 125 | 0x00013AEEL , // 0x71 = 'q' 126 | 0x000004BAL , // 0x72 = 'r' 127 | 0x0000012AL , // 0x73 = 's' 128 | 0x0000004EL , // 0x74 = 't' 129 | 0x000004EAL , // 0x75 = 'u' 130 | 0x000013AAL , // 0x76 = 'v' 131 | 0x000013BAL , // 0x77 = 'w' 132 | 0x00004EAEL , // 0x78 = 'x' 133 | 0x00013BAEL , // 0x79 = 'y' 134 | 0x00004AEEL , // 0x7A = 'z' 135 | 0x00000004L , // 0x7B = '{' 136 | 0x00000004L , // 0x7C = '|' 137 | 0x00000004L , // 0x7D = '}' 138 | 0x00000004L , // 0x7E = '~' 139 | 0x00000004L // 0x7F = '' 140 | } ; 141 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/mt63/mt63intl.dat: -------------------------------------------------------------------------------- 1 | /* 2 | * mt63intl.dat -- interleave patterns 3 | * 4 | * Copyright (C) 1999-2004 Pawel Jalocha, SP9VRC 5 | * 6 | * This file is part of fldigi. 7 | * 8 | * Fldigi is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Fldigi is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with fldigi. If not, see . 20 | * 21 | */ 22 | 23 | // interleave pattern for the original MT63ASC (short interleave) 24 | int ShortIntlvPatt[64] = { 25 | 4,5,6,7, 26 | 4,5,6,7, 27 | 4,5,6,7, 28 | 4,5,6,7, 29 | 4,5,6,7, 30 | 4,5,6,7, 31 | 4,5,6,7, 32 | 4,5,6,7, 33 | 4,5,6,7, 34 | 4,5,6,7, 35 | 4,5,6,7, 36 | 4,5,6,7, 37 | 4,5,6,7, 38 | 4,5,6,7, 39 | 4,5,6,7, 40 | 4,5,6,7 } ; 41 | 42 | // interleave pattern for doubled interleave 43 | int LongIntlvPatt[64] = { 44 | 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 45 | 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, 46 | 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, 47 | 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0 48 | } ; 49 | 50 | 51 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/psk/pskcoeff.cxx: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Copyright (C) 2014 3 | // David Freese, W1HKJ 4 | // 5 | // This file is part of fldigi 6 | // 7 | // fldigi is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // fldigi is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program. If not, see . 19 | // ---------------------------------------------------------------------------- 20 | 21 | // Android #include 22 | 23 | #include "pskcoeff.h" 24 | 25 | // Linux PSK31 modem driver for soundcard -- Filter coefficients 26 | // 27 | // these FIR coefs are those used by G0TJZ in his TMC320C50 code 28 | // 29 | // Hansi Reiser, DL9RDZ, 20 April 1998 30 | // 31 | 32 | #define _USE_MATH_DEFINES 33 | #include 34 | 35 | // 64-tap raised-cosine FIR 36 | // implements 37 | // u[n] = (1.0 - cos(2PI * n / 64))/128.0 38 | // used in gmfsk, twpsk etc. 39 | 40 | double gmfir1c[64] = { 41 | 0.000000, // 0 42 | 0.000038, // 1 43 | 0.000150, // 2 44 | 0.000336, // 3 45 | 0.000595, // 4 46 | 0.000922, // 5 47 | 0.001317, // 6 48 | 0.001773, // 7 49 | 0.002288, // 8 50 | 0.002856, // 9 51 | 0.003472, // 10 52 | 0.004130, // 11 53 | 0.004823, // 12 54 | 0.005545, // 13 55 | 0.006288, // 14 56 | 0.007047, // 15 57 | 0.007812, // 16 58 | 0.008578, // 17 59 | 0.009337, // 18 60 | 0.010080, // 19 61 | 0.010802, // 20 62 | 0.011495, // 21 63 | 0.012153, // 22 64 | 0.012769, // 23 65 | 0.013337, // 24 66 | 0.013852, // 25 67 | 0.014308, // 26 68 | 0.014703, // 27 69 | 0.015030, // 28 70 | 0.015289, // 29 71 | 0.015475, // 30 72 | 0.015587, // 31 73 | 0.015625, // 32 74 | 0.015587, // 33 75 | 0.015475, // 34 76 | 0.015289, // 35 77 | 0.015030, // 36 78 | 0.014703, // 37 79 | 0.014308, // 38 80 | 0.013852, // 39 81 | 0.013337, // 40 82 | 0.012769, // 41 83 | 0.012153, // 42 84 | 0.011495, // 43 85 | 0.010802, // 44 86 | 0.010080, // 45 87 | 0.009337, // 46 88 | 0.008578, // 47 89 | 0.007813, // 48 90 | 0.007047, // 49 91 | 0.006288, // 50 92 | 0.005545, // 51 93 | 0.004823, // 52 94 | 0.004130, // 53 95 | 0.003472, // 54 96 | 0.002856, // 55 97 | 0.002288, // 56 98 | 0.001773, // 57 99 | 0.001317, // 58 100 | 0.000922, // 59 101 | 0.000595, // 60 102 | 0.000336, // 61 103 | 0.000150, // 62 104 | 0.000038, // 63 105 | }; 106 | 107 | // 4-bit receive filter for 31.25 baud BPSK 108 | // Designed by G3PLX 109 | // 110 | 111 | double gmfir2c[64] = { 112 | 0.000625000, 0.000820912, 0.001374651, 0.002188141, 0.003110600, 113 | 0.003956273, 0.004526787, 0.004635947, 0.004134515, 0.002932456, 114 | 0.001016352, -0.001539947, -0.004572751, -0.007834665, -0.011009254, 115 | -0.013733305, -0.015625000, -0.016315775, -0.015483216, -0.012882186, 116 | -0.008371423, -0.001933193, 0.006315933, 0.016124399, 0.027115485, 117 | 0.038807198, 0.050640928, 0.062016866, 0.072333574, 0.081028710, 118 | 0.087617820, 0.091728168, 0.093125000, 0.091728168, 0.087617820, 119 | 0.081028710, 0.072333574, 0.062016866, 0.050640928, 0.038807198, 120 | 0.027115485, 0.016124399, 0.006315933, -0.001933193, -0.008371423, 121 | -0.012882186, -0.015483216, -0.016315775, -0.015625000, -0.013733305, 122 | -0.011009254, -0.007834665, -0.004572751, -0.001539947, 0.001016352, 123 | 0.002932456, 0.004134515, 0.004635947, 0.004526787, 0.003956273, 124 | 0.003110600, 0.002188141, 0.001374651, 0.000820912}; 125 | 126 | // sync filter 127 | // weighting for sync samples 128 | // sum of all weights = 1.0 129 | 130 | double syncfilt[16] = {-0.097545161, -0.093796555, -0.086443400, -0.075768274, 131 | -0.062181416, -0.046204960, -0.028452874, -0.009607360, 132 | 0.009607360, 0.028452874, 0.046204960, 0.062181416, 133 | 0.075768274, 0.086443400, 0.093796555, 0.097545161}; 134 | 135 | // experimental filters (higher precision) 136 | // identical to the G0TJZ filter but with double precision 137 | void raisedcosfilt(double *firc) { 138 | for (int i = 0; i < 64; i++) 139 | firc[i] = (1.0 - cos(M_PI * i / 32.0)) / 128.0; 140 | } 141 | 142 | void wsincfilt(double *firc, double fc, bool blackman) { 143 | double normalize = 0; 144 | // sin(x-tau)/(x-tau) 145 | for (int i = 0; i < 64; i++) 146 | if (i == 32) 147 | firc[i] = 2.0 * M_PI * fc; 148 | else 149 | firc[i] = sin(2 * M_PI * fc * (i - 32)) / (i - 32); 150 | // blackman window 151 | if (blackman) 152 | for (int i = 0; i < 64; i++) 153 | firc[i] = firc[i] * (0.42 - 0.5 * cos(2 * M_PI * i / 64) + 154 | 0.08 * cos(4 * M_PI * i / 64)); 155 | // hamming window 156 | else 157 | for (int i = 0; i < 64; i++) 158 | firc[i] = firc[i] * (0.54 - 0.46 * cos(2 * M_PI * i / 64)); 159 | // normalization factor 160 | for (int i = 0; i < 64; i++) 161 | normalize += firc[i]; 162 | // normalize the filter 163 | for (int i = 0; i < 64; i++) 164 | firc[i] /= normalize; 165 | } 166 | 167 | // Android: 32 taps version of the filter instead of the 64 168 | // Key factor in CPU load reduction (for "slowcpu" option). 169 | void wsincfilt32(double *firc, double fc, bool blackman) { 170 | double normalize = 0; 171 | // Math.sin(x-tau)/(x-tau) 172 | for (int i = 0; i < 32; i++) 173 | if (i == 16) 174 | firc[i] = 2.0 * M_PI * fc; 175 | else 176 | firc[i] = (sin(2 * M_PI * fc * (i - 16))) / (i - 16); 177 | // blackman window 178 | if (blackman) 179 | for (int i = 0; i < 32; i++) 180 | firc[i] = firc[i] * (0.42 - 0.5 * cos(2 * M_PI * i / 32) + 181 | 0.08 * cos(4 * M_PI * i / 32)); 182 | // hamming window 183 | else 184 | for (int i = 0; i < 32; i++) 185 | firc[i] = firc[i] * (0.54 - 0.46 * cos(2 * M_PI * i / 32)); 186 | // normalization factor 187 | for (int i = 0; i < 32; i++) 188 | normalize += firc[i]; 189 | // normalize the filter 190 | for (int i = 0; i < 32; i++) 191 | firc[i] /= normalize; 192 | } 193 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/fldigi/psk/pskvaricode.cxx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eurecom-s3/noise-sdr/06e12a0baa35f3e0defc2727516706c97dd77419/fldigi-noise-sdr/src/fldigi/psk/pskvaricode.cxx -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/libion/chipset.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define ALOGE(...) fprintf(stderr, __VA_ARGS__); 5 | 6 | #define CHIPSET_MSM -1 7 | #define CHIPSET_MEDIATEK 1 8 | #define CHIPSET_EXYNOS 4 9 | #define CHIPSET_MAKO 25 10 | #define CHIPSET_TEGRA 2 11 | #define CHIPSET_UNIVERSAL 1 12 | #define CHIPSET_KIRIN 1 13 | #define CHIPSET_SPREADTRUM 2 14 | #define CHIPSET_QCT 22 15 | 16 | int ion_magic_number(int fd, int len) { 17 | // inspired/taken from drammer 18 | int chipset = -1; 19 | int err = -1; 20 | ion_user_handle_t ion_handle; 21 | 22 | // attempt to guess ID from processor type 23 | chipset = CHIPSET_MSM; 24 | std::ifstream cpuinfo("/proc/cpuinfo"); 25 | for (std::string line; getline(cpuinfo, line);) { 26 | if (line.find("Qualcomm") != std::string::npos) { 27 | printf("Detected chipset: Qualcomm\n"); 28 | chipset = CHIPSET_MSM; 29 | break; 30 | } 31 | if (line.find("Exynos") != std::string::npos) { 32 | printf("Detected chipset: Exynos\n"); 33 | chipset = CHIPSET_EXYNOS; 34 | break; 35 | } 36 | if (line.find(": 0x53") != std::string::npos) { 37 | printf("Detected chipset: Exynos\n"); // S7, S7 Edge, but probably more :( 38 | chipset = CHIPSET_EXYNOS; 39 | break; 40 | } 41 | if (line.find(": sc") != std::string::npos) { 42 | // Hardware : sc8830 43 | printf("Detected chipset: Spreadtrum\n"); 44 | chipset = CHIPSET_SPREADTRUM; 45 | break; 46 | } 47 | if (line.find("EXYNOS") != std::string::npos) { 48 | // Samsung EXYNOS5433 49 | printf("Detected chipset: Exynos\n"); 50 | chipset = CHIPSET_EXYNOS; 51 | break; 52 | } 53 | if (line.find("UNIVERSAL") != std::string::npos) { 54 | printf("Detected chipset: UNIVERSAL\n"); 55 | chipset = CHIPSET_UNIVERSAL; 56 | break; 57 | } 58 | if (line.find("MAKO") != std::string::npos) { 59 | printf("Detected chipset: Mako\n"); 60 | chipset = CHIPSET_MAKO; 61 | break; 62 | } 63 | if (line.find("Flounder") != std::string::npos) { 64 | printf("Detected chipset: Tegra\n"); 65 | chipset = CHIPSET_TEGRA; 66 | break; 67 | } 68 | if (line.find(": MT") != std::string::npos) { 69 | printf("Detected chipset: Mediatek\n"); 70 | chipset = CHIPSET_MEDIATEK; 71 | break; 72 | } 73 | if (line.find(": hi") != std::string::npos) { 74 | printf("Detected chipset Kirin\n"); 75 | chipset = CHIPSET_KIRIN; 76 | break; 77 | } 78 | if (line.find("Kirin") != std::string::npos) { 79 | printf("Detected chipset Kirin\n"); 80 | chipset = CHIPSET_KIRIN; 81 | break; 82 | } 83 | if (line.find("MSM8627") != std::string::npos) { 84 | printf("Detected cihpset MSM8627\n"); 85 | chipset = CHIPSET_QCT; 86 | } 87 | } 88 | 89 | // chipset found 90 | if (chipset != -1) { 91 | // try anyhow before returning 92 | printf("Trying chipset %d\n", chipset); 93 | err = ion_alloc(fd, len, 0, (0x1 << chipset), 0, &ion_handle); 94 | if (err == 0) { 95 | // chipset found 96 | ion_free(fd, ion_handle); 97 | printf("Detected chipset %d\n", chipset); 98 | return chipset; 99 | } 100 | } 101 | 102 | // chipset not found, "bruteforcing" 103 | chipset = -1; 104 | while (chipset++ < 1000) { 105 | printf("Trying chipset %d\n", chipset); 106 | err = ion_alloc(fd, len, 0, (0x1 << chipset), 0, &ion_handle); 107 | if (err == 0) { 108 | // chipset found 109 | ion_free(fd, ion_handle); 110 | printf("Detected chipset %d\n", chipset); 111 | return chipset; 112 | } 113 | } 114 | 115 | // chipset not found 116 | return -1; 117 | } 118 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/libion/include/ion/ion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ion.c 3 | * 4 | * Memory Allocator functions for ion 5 | * 6 | * Copyright 2011 Google, Inc 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #ifndef __SYS_CORE_ION_H 22 | #define __SYS_CORE_ION_H 23 | 24 | #include 25 | #include 26 | 27 | __BEGIN_DECLS 28 | 29 | struct ion_handle; 30 | 31 | int ion_open(); 32 | int ion_close(int fd); 33 | int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, 34 | unsigned int flags, ion_user_handle_t *handle); 35 | int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, 36 | unsigned int flags, int *handle_fd); 37 | int ion_sync_fd(int fd, int handle_fd); 38 | int ion_free(int fd, ion_user_handle_t handle); 39 | int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, 40 | int flags, off_t offset, unsigned char **ptr, int *map_fd); 41 | int ion_share(int fd, ion_user_handle_t handle, int *share_fd); 42 | int ion_import(int fd, int share_fd, ion_user_handle_t *handle); 43 | 44 | int ion_magic_number(int fd, int len); 45 | 46 | __END_DECLS 47 | 48 | #endif /* __SYS_CORE_ION_H */ 49 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/libion/ion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ion.c 3 | * 4 | * Memory Allocator functions for ion 5 | * 6 | * Copyright 2011 Google, Inc 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | #define LOG_TAG "ion" 21 | 22 | /*#include */ 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #define ALOGE(...) fprintf(stderr, __VA_ARGS__); 34 | 35 | int ion_open() 36 | { 37 | int fd = open("/dev/ion", O_RDONLY); 38 | if (fd < 0) 39 | ALOGE("open /dev/ion failed!\n"); 40 | return fd; 41 | } 42 | 43 | int ion_close(int fd) 44 | { 45 | int ret = close(fd); 46 | if (ret < 0) 47 | return -errno; 48 | return ret; 49 | } 50 | 51 | static int ion_ioctl(int fd, int req, void *arg) 52 | { 53 | int ret = ioctl(fd, req, arg); 54 | if (ret < 0) { 55 | ALOGE("ioctl %x failed with code %d: %s\n", req, 56 | ret, strerror(errno)); 57 | return -errno; 58 | } 59 | return ret; 60 | } 61 | 62 | int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, 63 | unsigned int flags, ion_user_handle_t *handle) 64 | { 65 | int ret; 66 | struct ion_allocation_data data = { 67 | .len = len, 68 | .align = align, 69 | .heap_id_mask = heap_mask, 70 | .flags = flags, 71 | }; 72 | 73 | if (handle == NULL) 74 | return -EINVAL; 75 | 76 | ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); 77 | if (ret < 0) 78 | return ret; 79 | *handle = data.handle; 80 | return ret; 81 | } 82 | 83 | int ion_free(int fd, ion_user_handle_t handle) 84 | { 85 | struct ion_handle_data data = { 86 | .handle = handle, 87 | }; 88 | return ion_ioctl(fd, ION_IOC_FREE, &data); 89 | } 90 | 91 | int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, 92 | int flags, off_t offset, unsigned char **ptr, int *map_fd) 93 | { 94 | int ret; 95 | unsigned char *tmp_ptr; 96 | struct ion_fd_data data = { 97 | .handle = handle, 98 | }; 99 | 100 | if (map_fd == NULL) 101 | return -EINVAL; 102 | if (ptr == NULL) 103 | return -EINVAL; 104 | 105 | ret = ion_ioctl(fd, ION_IOC_MAP, &data); 106 | if (ret < 0) 107 | return ret; 108 | if (data.fd < 0) { 109 | ALOGE("map ioctl returned negative fd\n"); 110 | return -EINVAL; 111 | } 112 | tmp_ptr = mmap(NULL, length, prot, flags, data.fd, offset); 113 | if (tmp_ptr == MAP_FAILED) { 114 | ALOGE("mmap failed: %s\n", strerror(errno)); 115 | return -errno; 116 | } 117 | *map_fd = data.fd; 118 | *ptr = tmp_ptr; 119 | return ret; 120 | } 121 | 122 | int ion_share(int fd, ion_user_handle_t handle, int *share_fd) 123 | { 124 | int ret; 125 | struct ion_fd_data data = { 126 | .handle = handle, 127 | }; 128 | 129 | if (share_fd == NULL) 130 | return -EINVAL; 131 | 132 | ret = ion_ioctl(fd, ION_IOC_SHARE, &data); 133 | if (ret < 0) 134 | return ret; 135 | if (data.fd < 0) { 136 | ALOGE("share ioctl returned negative fd\n"); 137 | return -EINVAL; 138 | } 139 | *share_fd = data.fd; 140 | return ret; 141 | } 142 | 143 | int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, 144 | unsigned int flags, int *handle_fd) { 145 | ion_user_handle_t handle; 146 | int ret; 147 | 148 | ret = ion_alloc(fd, len, align, heap_mask, flags, &handle); 149 | if (ret < 0) 150 | return ret; 151 | ret = ion_share(fd, handle, handle_fd); 152 | ion_free(fd, handle); 153 | return ret; 154 | } 155 | 156 | int ion_import(int fd, int share_fd, ion_user_handle_t *handle) 157 | { 158 | int ret; 159 | struct ion_fd_data data = { 160 | .fd = share_fd, 161 | }; 162 | 163 | if (handle == NULL) 164 | return -EINVAL; 165 | 166 | ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); 167 | if (ret < 0) 168 | return ret; 169 | *handle = data.handle; 170 | return ret; 171 | } 172 | 173 | int ion_sync_fd(int fd, int handle_fd) 174 | { 175 | struct ion_fd_data data = { 176 | .fd = handle_fd, 177 | }; 178 | return ion_ioctl(fd, ION_IOC_SYNC, &data); 179 | } 180 | -------------------------------------------------------------------------------- /fldigi-noise-sdr/src/libion/kernel-headers/linux/ion.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_LINUX_ION_H 20 | #define _UAPI_LINUX_ION_H 21 | #include 22 | #include 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | typedef int ion_user_handle_t; 25 | enum ion_heap_type { 26 | ION_HEAP_TYPE_SYSTEM, 27 | ION_HEAP_TYPE_SYSTEM_CONTIG, 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | ION_HEAP_TYPE_CARVEOUT, 30 | ION_HEAP_TYPE_CHUNK, 31 | ION_HEAP_TYPE_DMA, 32 | ION_HEAP_TYPE_CUSTOM, 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | ION_NUM_HEAPS = 16, 35 | }; 36 | #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) 37 | #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) 40 | #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) 41 | #define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 42 | #define ION_FLAG_CACHED 1 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | #define ION_FLAG_CACHED_NEEDS_SYNC 2 45 | struct ion_allocation_data { 46 | size_t len; 47 | size_t align; 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | unsigned int heap_id_mask; 50 | unsigned int flags; 51 | ion_user_handle_t handle; 52 | }; 53 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 | struct ion_fd_data { 55 | ion_user_handle_t handle; 56 | int fd; 57 | }; 58 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 | struct ion_handle_data { 60 | ion_user_handle_t handle; 61 | }; 62 | struct ion_custom_data { 63 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 | unsigned int cmd; 65 | unsigned long arg; 66 | }; 67 | #define ION_IOC_MAGIC 'I' 68 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 | #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data) 70 | #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) 71 | #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data) 72 | #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) 73 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 74 | #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data) 75 | #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data) 76 | #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data) 77 | #endif 78 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 79 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-normal/generate-example.sh: -------------------------------------------------------------------------------- 1 | python3.6 ../glonass-sim.py signal --fs 1.5e6 --duration 5 -s 0 --sr 100 --cr 511000 -o /tmp/glonass.complex 2 | python3.6 ../../../offline-noise-sdr/generate/rf-pwm.py generate --fs-in 1.5e6 --fs-out 3e6 --f-if 0.8750e6 --input-file /tmp/glonass.complex --output-file /tmp/glonass-example.rfpwm 3 | # reduce doppler offset 4 | python3.6 ../../../offline-noise-sdr/generate/rf-pwm.py generate --fs-in 1.5e6 --fs-out 3e6 --f-if 871500 --input-file /tmp/glonass.complex --output-file /tmp/glonass-example-offset.rfpwm 5 | adb push /tmp/glonass-example.rfpwm /data/local/tmp 6 | adb push /tmp/glonass-example-offset.rfpwm /data/local/tmp 7 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-normal/gnss-sdr-1.5M.conf: -------------------------------------------------------------------------------- 1 | ; This is a GNSS-SDR configuration file 2 | ; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | ; SPDX-FileCopyrightText: (C) 2010-2020 (see AUTHORS file for a list of contributors) 5 | 6 | [GNSS-SDR] 7 | 8 | ;######### GLOBAL OPTIONS ################## 9 | ;GNSS-SDR.internal_fs_sps=6625000 10 | GNSS-SDR.internal_fs_sps=1500000 11 | 12 | ;######### SIGNAL_SOURCE CONFIG ############ 13 | SignalSource.implementation=File_Signal_Source 14 | ;SignalSource.filename=/home/giovanni/gqrx_20210409_082716_399992468_79999_fc.raw 15 | SignalSource.filename=/tmp/glonass_rec 16 | ;SignalSource.item_type=ibyte 17 | SignalSource.item_type=gr_complex 18 | ;SignalSource.sampling_frequency=6625000 19 | SignalSource.sampling_frequency=1500000 20 | SignalSource.samples=0 21 | SignalSource.dump=true; 22 | SignalSource.dump_filename=./signal_glonass.bin 23 | 24 | ;######### SIGNAL_CONDITIONER CONFIG ############ 25 | SignalConditioner.implementation=Signal_Conditioner 26 | ;DataTypeAdapter.implementation=Ibyte_To_Complex 27 | DataTypeAdapter.implementation=Pass_Through 28 | DataTypeAdapter.item_type=gr_complex 29 | InputFilter.implementation=Pass_Through 30 | InputFilter.item_type=gr_complex 31 | Resampler.implementation=Pass_Through 32 | Resampler.item_type=gr_complex 33 | 34 | ;######### CHANNELS GLOBAL CONFIG ############ 35 | Channel.signal=1G 36 | Channels.in_acquisition=2 37 | Channels_1G.count=8 38 | 39 | ;Channel0.satellite=24 ; k=2 40 | ;Channel1.satellite=1 ; k=1 41 | ;Channel2.satellite=2 ; k=-4 42 | ;Channel3.satellite=20 ; k=-5 43 | ;Channel4.satellite=21 ; k=4 44 | 45 | ;######### ACQUISITION GLOBAL CONFIG ############ 46 | Acquisition_1G.implementation=GLONASS_L1_CA_PCPS_Acquisition 47 | Acquisition_1G.item_type=gr_complex 48 | Acquisition_1G.threshold=0.0 49 | Acquisition_1G.pfa=0.0001 50 | Acquisition_1G.doppler_max=10000 51 | Acquisition_1G.doppler_step=250 52 | Acquisition_1G.dump=false; 53 | Acquisition_1G.dump_filename=/archive/glo_acquisition.dat 54 | ;Acquisition_1G.coherent_integration_time_ms=1 55 | ;Acquisition_1G.max_dwells = 5 56 | 57 | ;######### TRACKING GLOBAL CONFIG ############ 58 | Tracking_1G.implementation=GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking 59 | Tracking_1G.item_type=gr_complex 60 | Tracking_1G.early_late_space_chips=0.5 61 | Tracking_1G.pll_bw_hz=40.0; 62 | Tracking_1G.dll_bw_hz=3.0; 63 | Tracking_1G.pll_bw_narrow_hz = 25.0; 64 | Tracking_1G.dll_bw_narrow_hz = 2.0; 65 | Tracking_1G.extend_correlation_ms = 1; 66 | Tracking_1G.dump=false; 67 | Tracking_1G.dump_filename=/archive/glo_tracking_ch_ 68 | 69 | ;######### TELEMETRY DECODER GPS CONFIG ############ 70 | TelemetryDecoder_1G.implementation=GLONASS_L1_CA_Telemetry_Decoder 71 | 72 | ;######### OBSERVABLES CONFIG ############ 73 | Observables.implementation=Hybrid_Observables 74 | Observables.dump=false 75 | Observables.dump_filename=/archive/glo_observables.dat 76 | 77 | ;######### PVT CONFIG ############ 78 | PVT.implementation=RTKLIB_PVT 79 | PVT.positioning_mode=Single 80 | PVT.output_rate_ms=100 81 | PVT.display_rate_ms=500 82 | PVT.trop_model=Saastamoinen 83 | PVT.flag_rtcm_server=true 84 | PVT.flag_rtcm_tty_port=false 85 | PVT.rtcm_dump_devname=/dev/pts/1 86 | PVT.rtcm_tcp_port=2101 87 | PVT.rtcm_MT1019_rate_ms=5000 88 | PVT.rtcm_MT1045_rate_ms=5000 89 | PVT.rtcm_MT1097_rate_ms=1000 90 | PVT.rtcm_MT1077_rate_ms=1000 91 | PVT.rinex_version=2 92 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-normal/gnss-sdr.conf: -------------------------------------------------------------------------------- 1 | ; This is a GNSS-SDR configuration file 2 | ; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | ; SPDX-FileCopyrightText: (C) 2010-2020 (see AUTHORS file for a list of contributors) 5 | 6 | [GNSS-SDR] 7 | 8 | ;######### GLOBAL OPTIONS ################## 9 | ;GNSS-SDR.internal_fs_sps=6625000 10 | GNSS-SDR.internal_fs_sps=2000000 11 | 12 | ;######### SIGNAL_SOURCE CONFIG ############ 13 | SignalSource.implementation=File_Signal_Source 14 | ;SignalSource.filename=/home/giovanni/gqrx_20210409_082716_399992468_79999_fc.raw 15 | SignalSource.filename=/tmp/glonass_rec 16 | ;SignalSource.item_type=ibyte 17 | SignalSource.item_type=gr_complex 18 | ;SignalSource.sampling_frequency=6625000 19 | SignalSource.sampling_frequency=2000000 20 | SignalSource.samples=0 21 | SignalSource.dump=true; 22 | SignalSource.dump_filename=./signal_glonass.bin 23 | 24 | ;######### SIGNAL_CONDITIONER CONFIG ############ 25 | SignalConditioner.implementation=Signal_Conditioner 26 | ;DataTypeAdapter.implementation=Ibyte_To_Complex 27 | DataTypeAdapter.implementation=Pass_Through 28 | DataTypeAdapter.item_type=gr_complex 29 | InputFilter.implementation=Pass_Through 30 | InputFilter.item_type=gr_complex 31 | Resampler.implementation=Pass_Through 32 | Resampler.item_type=gr_complex 33 | 34 | ;######### CHANNELS GLOBAL CONFIG ############ 35 | Channel.signal=1G 36 | Channels.in_acquisition=2 37 | Channels_1G.count=8 38 | 39 | ;Channel0.satellite=24 ; k=2 40 | ;Channel1.satellite=1 ; k=1 41 | ;Channel2.satellite=2 ; k=-4 42 | ;Channel3.satellite=20 ; k=-5 43 | ;Channel4.satellite=21 ; k=4 44 | 45 | ;######### ACQUISITION GLOBAL CONFIG ############ 46 | Acquisition_1G.implementation=GLONASS_L1_CA_PCPS_Acquisition 47 | Acquisition_1G.item_type=gr_complex 48 | Acquisition_1G.threshold=0.0 49 | Acquisition_1G.pfa=0.0001 50 | Acquisition_1G.doppler_max=10000 51 | Acquisition_1G.doppler_step=250 52 | Acquisition_1G.dump=false; 53 | Acquisition_1G.dump_filename=/archive/glo_acquisition.dat 54 | ;Acquisition_1G.coherent_integration_time_ms=1 55 | ;Acquisition_1G.max_dwells = 5 56 | 57 | ;######### TRACKING GLOBAL CONFIG ############ 58 | Tracking_1G.implementation=GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking 59 | Tracking_1G.item_type=gr_complex 60 | Tracking_1G.early_late_space_chips=0.5 61 | Tracking_1G.pll_bw_hz=40.0; 62 | Tracking_1G.dll_bw_hz=3.0; 63 | Tracking_1G.pll_bw_narrow_hz = 25.0; 64 | Tracking_1G.dll_bw_narrow_hz = 2.0; 65 | Tracking_1G.extend_correlation_ms = 1; 66 | Tracking_1G.dump=false; 67 | Tracking_1G.dump_filename=/archive/glo_tracking_ch_ 68 | 69 | ;######### TELEMETRY DECODER GPS CONFIG ############ 70 | TelemetryDecoder_1G.implementation=GLONASS_L1_CA_Telemetry_Decoder 71 | 72 | ;######### OBSERVABLES CONFIG ############ 73 | Observables.implementation=Hybrid_Observables 74 | Observables.dump=false 75 | Observables.dump_filename=/archive/glo_observables.dat 76 | 77 | ;######### PVT CONFIG ############ 78 | PVT.implementation=RTKLIB_PVT 79 | PVT.positioning_mode=Single 80 | PVT.output_rate_ms=100 81 | PVT.display_rate_ms=500 82 | PVT.trop_model=Saastamoinen 83 | PVT.flag_rtcm_server=true 84 | PVT.flag_rtcm_tty_port=false 85 | PVT.rtcm_dump_devname=/dev/pts/1 86 | PVT.rtcm_tcp_port=2101 87 | PVT.rtcm_MT1019_rate_ms=5000 88 | PVT.rtcm_MT1045_rate_ms=5000 89 | PVT.rtcm_MT1097_rate_ms=1000 90 | PVT.rtcm_MT1077_rate_ms=1000 91 | PVT.rinex_version=2 92 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-normal/receive-1.5M.sh: -------------------------------------------------------------------------------- 1 | gnss-sdr --config-file gnss-sdr-1.5M.conf --signal_source $1 2 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-normal/receive.sh: -------------------------------------------------------------------------------- 1 | gnss-sdr --config-file gnss-sdr.conf --alsologtostderr --signal_source $1 2 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-slow-10/generate-slow-10-example.sh: -------------------------------------------------------------------------------- 1 | python3.6 ../glonass-sim.py signal --fs 80000 --duration 250 -s 0 --sr 10 --cr 51100 -o /tmp/glonass-slow-10.complex --nav 2 | python3.6 ../../../offline-noise-sdr/generate/rf-pwm.py generate --fs-in 80e3 --fs-out 0.4e6 --f-if 56.25e3 --input-file /tmp/glonass-slow-10.complex --output-file /tmp/glonass-slow-10.rfpwm 3 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-slow-10/gnss-sdr.conf: -------------------------------------------------------------------------------- 1 | ; This is a GNSS-SDR configuration file 2 | ; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | ; SPDX-FileCopyrightText: (C) 2010-2020 (see AUTHORS file for a list of contributors) 5 | 6 | [GNSS-SDR] 7 | 8 | ;######### GLOBAL OPTIONS ################## 9 | ;GNSS-SDR.internal_fs_sps=6625000 10 | GNSS-SDR.internal_fs_sps=800000 11 | 12 | ;######### SIGNAL_SOURCE CONFIG ############ 13 | SignalSource.implementation=File_Signal_Source 14 | ;SignalSource.filename=/home/giovanni/gqrx_20210409_082716_399992468_79999_fc.raw 15 | SignalSource.filename=/tmp/glonass_rec 16 | ;SignalSource.item_type=ibyte 17 | SignalSource.item_type=gr_complex 18 | ;SignalSource.sampling_frequency=6625000 19 | SignalSource.sampling_frequency=80000 20 | SignalSource.samples=0 21 | SignalSource.dump=true; 22 | SignalSource.dump_filename=./signal_glonass.bin 23 | 24 | ;######### SIGNAL_CONDITIONER CONFIG ############ 25 | SignalConditioner.implementation=Signal_Conditioner 26 | ;DataTypeAdapter.implementation=Ibyte_To_Complex 27 | DataTypeAdapter.implementation=Pass_Through 28 | DataTypeAdapter.item_type=gr_complex 29 | InputFilter.implementation=Pass_Through 30 | InputFilter.item_type=gr_complex 31 | Resampler.implementation=Pass_Through 32 | Resampler.item_type=gr_complex 33 | 34 | ;######### CHANNELS GLOBAL CONFIG ############ 35 | Channel.signal=1G 36 | Channels.in_acquisition=2 37 | Channels_1G.count=8 38 | 39 | ;Channel0.satellite=24 ; k=2 40 | ;Channel1.satellite=1 ; k=1 41 | ;Channel2.satellite=2 ; k=-4 42 | ;Channel3.satellite=20 ; k=-5 43 | ;Channel4.satellite=21 ; k=4 44 | 45 | ;######### ACQUISITION GLOBAL CONFIG ############ 46 | Acquisition_1G.implementation=GLONASS_L1_CA_PCPS_Acquisition 47 | Acquisition_1G.item_type=gr_complex 48 | Acquisition_1G.threshold=0.0 49 | Acquisition_1G.pfa=0.0001 50 | Acquisition_1G.doppler_max=10000 51 | Acquisition_1G.doppler_step=250 52 | Acquisition_1G.dump=false; 53 | Acquisition_1G.dump_filename=/archive/glo_acquisition.dat 54 | ;Acquisition_1G.coherent_integration_time_ms=1 55 | ;Acquisition_1G.max_dwells = 5 56 | 57 | ;######### TRACKING GLOBAL CONFIG ############ 58 | Tracking_1G.implementation=GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking 59 | Tracking_1G.item_type=gr_complex 60 | Tracking_1G.early_late_space_chips=0.5 61 | Tracking_1G.pll_bw_hz=40.0; 62 | Tracking_1G.dll_bw_hz=3.0; 63 | Tracking_1G.pll_bw_narrow_hz = 25.0; 64 | Tracking_1G.dll_bw_narrow_hz = 2.0; 65 | Tracking_1G.extend_correlation_ms = 1; 66 | Tracking_1G.dump=false; 67 | Tracking_1G.dump_filename=/archive/glo_tracking_ch_ 68 | 69 | ;######### TELEMETRY DECODER GPS CONFIG ############ 70 | TelemetryDecoder_1G.implementation=GLONASS_L1_CA_Telemetry_Decoder 71 | 72 | ;######### OBSERVABLES CONFIG ############ 73 | Observables.implementation=Hybrid_Observables 74 | Observables.dump=false 75 | Observables.dump_filename=/archive/glo_observables.dat 76 | 77 | ;######### PVT CONFIG ############ 78 | PVT.implementation=RTKLIB_PVT 79 | PVT.positioning_mode=Single 80 | PVT.output_rate_ms=100 81 | PVT.display_rate_ms=500 82 | PVT.trop_model=Saastamoinen 83 | PVT.flag_rtcm_server=true 84 | PVT.flag_rtcm_tty_port=false 85 | PVT.rtcm_dump_devname=/dev/pts/1 86 | PVT.rtcm_tcp_port=2101 87 | PVT.rtcm_MT1019_rate_ms=5000 88 | PVT.rtcm_MT1045_rate_ms=5000 89 | PVT.rtcm_MT1097_rate_ms=1000 90 | PVT.rtcm_MT1077_rate_ms=1000 91 | PVT.rinex_version=2 92 | -------------------------------------------------------------------------------- /gnss/glonass/glonass-slow-10/receive.sh: -------------------------------------------------------------------------------- 1 | gnss-sdr --config-file gnss-sdr.conf --signal_source $1 2 | -------------------------------------------------------------------------------- /gnss/gps/generate-slow-100-example.sh: -------------------------------------------------------------------------------- 1 | python3.6 gps-sim-slow-100.py 2 | python3.6 ../../offline-noise-sdr/generate/rf-pwm.py generate --fs-in 80e3 --fs-out 0.4e6 --f-if 15e3 --input-file /tmp/time --output-file /tmp/gps-slow-100-sat24-f015e3.rfpwm 3 | adb push /tmp/gps-slow-100-sat24-f015e3.rfpwm /data/local/tmp/ 4 | -------------------------------------------------------------------------------- /gnss/gps/gnss-sdr.conf: -------------------------------------------------------------------------------- 1 | ; This is a GNSS-SDR configuration file 2 | ; The configuration API is described at https://gnss-sdr.org/docs/sp-blocks/ 3 | ; SPDX-License-Identifier: GPL-3.0-or-later 4 | ; SPDX-FileCopyrightText: (C) 2010-2020 (see AUTHORS file for a list of contributors) 5 | 6 | ; Default configuration file 7 | ; You can define your own receiver and invoke it by doing 8 | ; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf 9 | ; 10 | 11 | [GNSS-SDR] 12 | 13 | ;######### GLOBAL OPTIONS ################## 14 | ;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [samples per second]. 15 | GNSS-SDR.internal_fs_sps=8000000 16 | 17 | 18 | ;######### SUPL RRLP GPS assistance configuration ##### 19 | ; Check https://www.mcc-mnc.com/ 20 | ; On Android: https://play.google.com/store/apps/details?id=net.its_here.cellidinfo&hl=en 21 | GNSS-SDR.SUPL_gps_enabled=false 22 | GNSS-SDR.SUPL_read_gps_assistance_xml=true 23 | GNSS-SDR.SUPL_gps_ephemeris_server=supl.google.com 24 | GNSS-SDR.SUPL_gps_ephemeris_port=7275 25 | GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com 26 | GNSS-SDR.SUPL_gps_acquisition_port=7275 27 | GNSS-SDR.SUPL_MCC=244 28 | GNSS-SDR.SUPL_MNC=5 29 | GNSS-SDR.SUPL_LAC=0x59e2 30 | GNSS-SDR.SUPL_CI=0x31b0 31 | 32 | ;######### SIGNAL_SOURCE CONFIG ############ 33 | SignalSource.implementation=File_Signal_Source 34 | SignalSource.filename=/tmp/prn24 35 | ;SignalSource.filename=/home/giovanni/phd/tools/gps-sdr-sim/gpssim.bin 36 | SignalSource.item_type=gr_complex 37 | ;SignalSource.item_type=ishort 38 | SignalSource.sampling_frequency=8000000 39 | SignalSource.samples=0 40 | SignalSource.repeat=false 41 | SignalSource.enable_throttle_control=false 42 | 43 | 44 | ;######### SIGNAL_CONDITIONER CONFIG ############ 45 | SignalConditioner.implementation=Signal_Conditioner 46 | 47 | ;######### DATA_TYPE_ADAPTER CONFIG ############ 48 | ;DataTypeAdapter.implementation=Ishort_To_Complex 49 | DataTypeAdapter.implementation=Pass_Through 50 | DataTypeAdapter.item_type=gr_complex 51 | 52 | ;######### INPUT_FILTER CONFIG ############ 53 | InputFilter.implementation=Pass_Through ; or Fir_Filter 54 | 55 | InputFilter.input_item_type=gr_complex 56 | InputFilter.output_item_type=gr_complex 57 | InputFilter.taps_item_type=float 58 | InputFilter.number_of_taps=5 59 | InputFilter.number_of_bands=2 60 | InputFilter.band1_begin=0.0 61 | InputFilter.band1_end=0.44 62 | InputFilter.band2_begin=0.55 63 | InputFilter.band2_end=1.0 64 | InputFilter.ampl1_begin=1.0 65 | InputFilter.ampl1_end=1.0 66 | InputFilter.ampl2_begin=0.0 67 | InputFilter.ampl2_end=0.0 68 | InputFilter.band1_error=1.0 69 | InputFilter.band2_error=1.0 70 | InputFilter.filter_type=bandpass 71 | InputFilter.grid_density=16 72 | InputFilter.sampling_frequency=4000000 73 | InputFilter.IF=0 74 | InputFilter.dump=false 75 | InputFilter.dump_filename=../data/input_filter.dat 76 | 77 | 78 | ;######### RESAMPLER CONFIG ############ 79 | Resampler.implementation=Pass_Through 80 | Resampler.dump=false 81 | Resampler.dump_filename=../data/resampler.dat 82 | 83 | 84 | ;######### CHANNELS GLOBAL CONFIG ############ 85 | Channels_1C.count=6 86 | Channels_1B.count=0 87 | Channels.in_acquisition=1 88 | 89 | 90 | ;######### SPECIFIC CHANNELS CONFIG ###### 91 | 92 | ;######### CHANNEL 0 CONFIG ############ 93 | ;Channel0.signal=1C 94 | ;Channel0.satellite=11 95 | 96 | ;######### CHANNEL 1 CONFIG ############ 97 | ;Channel1.signal=1C 98 | ;Channel1.satellite=18 99 | 100 | ;######### ACQUISITION GLOBAL CONFIG ############ 101 | Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition_Fine_Doppler 102 | Acquisition_1C.item_type=gr_complex 103 | Acquisition_1C.coherent_integration_time_ms=1 104 | Acquisition_1C.threshold=2.5 105 | ;Acquisition_1C.pfa=0.0001 106 | Acquisition_1C.doppler_max=50000 107 | Acquisition_1C.doppler_step=500 108 | Acquisition_1C.max_dwells=5 109 | Acquisition_1C.dump=false 110 | Acquisition_1C.dump_filename=./acq_dump.dat 111 | 112 | 113 | ;######### TRACKING GLOBAL CONFIG ############ 114 | Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking 115 | Tracking_1C.item_type=gr_complex 116 | Tracking_1C.pll_bw_hz=45.0; 117 | Tracking_1C.dll_bw_hz=3.0; 118 | Tracking_1C.order=3; 119 | Tracking_1C.dump=false 120 | Tracking_1C.dump_filename=../data/epl_tracking_ch_ 121 | 122 | 123 | ;######### TELEMETRY DECODER GPS CONFIG ############ 124 | TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder 125 | TelemetryDecoder_1C.dump=false 126 | 127 | 128 | ;######### OBSERVABLES CONFIG ############ 129 | Observables.implementation=Hybrid_Observables 130 | Observables.dump=false 131 | Observables.dump_filename=./observables.dat 132 | 133 | 134 | ;######### PVT CONFIG ############ 135 | PVT.implementation=RTKLIB_PVT 136 | PVT.positioning_mode=PPP_Static ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic 137 | PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX 138 | PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad 139 | PVT.AR_GPS=PPP-AR ; options: OFF, Continuous, Instantaneous, Fix-and-Hold, PPP-AR 140 | PVT.output_rate_ms=10 141 | PVT.display_rate_ms=500 142 | PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea 143 | PVT.flag_nmea_tty_port=true 144 | PVT.nmea_dump_devname=/dev/pts/4 145 | PVT.flag_rtcm_server=true 146 | PVT.flag_rtcm_tty_port=false 147 | PVT.rtcm_dump_devname=/dev/pts/1 148 | PVT.dump=false 149 | PVT.dump_filename=./PVT 150 | -------------------------------------------------------------------------------- /gnss/gps/gps-sim-slow-100.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | 3 | # Generate GPS signal, based on: 4 | # https://natronics.github.io/blag/2014/gps-spreading/ 5 | 6 | from math import sin, pi 7 | from matplotlib import pyplot as plt 8 | import cmath 9 | import numpy as np 10 | 11 | f = 154 * 10.23e6 # carrier frequency 12 | f_prn = 1023000/100 #1023000 #10230 #1023000 # PRN frequency 13 | f_s = 8000000/100 #4e6 #80e3 14 | 15 | fs = f_s 16 | f_prn = f_prn 17 | 18 | # PRN assignments 19 | SV = { 20 | 1: [2,6], 21 | 2: [3,7], 22 | 3: [4,8], 23 | 4: [5,9], 24 | 5: [1,9], 25 | 6: [2,10], 26 | 7: [1,8], 27 | 8: [2,9], 28 | 9: [3,10], 29 | 10: [2,3], 30 | 11: [3,4], 31 | 12: [5,6], 32 | 13: [6,7], 33 | 14: [7,8], 34 | 15: [8,9], 35 | 16: [9,10], 36 | 17: [1,4], 37 | 18: [2,5], 38 | 19: [3,6], 39 | 20: [4,7], 40 | 21: [5,8], 41 | 22: [6,9], 42 | 23: [1,3], 43 | 24: [4,6], 44 | 25: [5,7], 45 | 26: [6,8], 46 | 27: [7,9], 47 | 28: [8,10], 48 | 29: [1,6], 49 | 30: [2,7], 50 | 31: [3,8], 51 | 32: [4,9], 52 | } 53 | 54 | # Shift register 55 | def shift(register, feedback, output): 56 | """GPS Shift Register 57 | 58 | :param list feedback: which positions to use as feedback (1 indexed) 59 | :param list output: which positions are output (1 indexed) 60 | :returns output of shift register: 61 | 62 | """ 63 | 64 | # calculate output 65 | out = [register[i-1] for i in output] 66 | if len(out) > 1: 67 | out = sum(out) % 2 68 | else: 69 | out = out[0] 70 | 71 | # modulo 2 add feedback 72 | fb = sum([register[i-1] for i in feedback]) % 2 73 | 74 | # shift to the right 75 | for i in reversed(range(len(register[1:]))): 76 | register[i+1] = register[i] 77 | 78 | # put feedback in position 1 79 | register[0] = fb 80 | 81 | return out 82 | 83 | # Generate C/A code 84 | def PRN(sv): 85 | """Build the CA code (PRN) for a given satellite ID 86 | 87 | :param int sv: satellite code (1-32) 88 | :returns list: ca code for chosen satellite 89 | 90 | """ 91 | 92 | # init registers 93 | G1 = [1 for i in range(10)] 94 | G2 = [1 for i in range(10)] 95 | 96 | ca = [] # stuff output in here 97 | 98 | # create sequence 99 | for i in range(1023): 100 | g1 = shift(G1, [3,10], [10]) 101 | g2 = shift(G2, [2,3,6,8,9,10], SV[sv]) # <- sat chosen here from table 102 | 103 | # modulo 2 add and append to the code 104 | ca.append((g1 + g2) % 2) 105 | 106 | # return C/A code! 107 | return ca 108 | 109 | # find ca code for sat 24, and make 0 into -1 to use in BPSK 110 | sats = [[-1 if x==0 else x for x in PRN(idx)] for idx in range(1,33)] 111 | sats = [sats[0]]+sats 112 | prn = lambda idx, t: sats[idx][int(t*f_prn)%1023] 113 | 114 | # Generate ~1ms of data for a plain carrier, and a GPS signal 115 | def satellite(idx, duration): 116 | signal = [] 117 | for i in range(int(f_s*duration)): 118 | t = i / f_s 119 | signal.append(prn(idx,t)) 120 | 121 | amplitude = 1 122 | # phase = np.array([0 if s == 1 else -np.pi for s in signal]) 123 | 124 | output = [cmath.rect(amplitude, 0 if s == 1 else -np.pi) for s in signal] 125 | output = np.array(output, dtype=np.complex64) 126 | return output 127 | 128 | duration = 100 129 | satellites = [25] 130 | output = satellite(satellites[0], duration) 131 | for idx in satellites[1:]: 132 | output += satellite(idx, duration) 133 | output = output / len(satellites) 134 | output.tofile("/tmp/time") 135 | -------------------------------------------------------------------------------- /gnss/gps/receive.sh: -------------------------------------------------------------------------------- 1 | gnss-sdr --alsologtostderr --config-file gnss-sdr.conf --signal_source $1 2 | -------------------------------------------------------------------------------- /offline-noise-sdr/generate/rf-pwm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | 3 | # Giovanni Camurati 4 | 5 | import numpy as np 6 | import click 7 | from matplotlib import pyplot as plt 8 | from scipy.interpolate import interp1d 9 | 10 | @click.group() 11 | def cli(): 12 | """ 13 | """ 14 | 15 | @cli.command() 16 | @click.option("--input-file", default="/tmp/time", 17 | show_default=True, 18 | type=click.Path(dir_okay=False), 19 | help="File with baseband IQ data (gr-complex format).") 20 | @click.option("--output-file", default="/tmp/rfpwm", 21 | show_default=True, 22 | type=click.Path(dir_okay=False), 23 | help="File with RF-PWM timings.") 24 | @click.option("--fs-in", default=48e3, show_default=True, 25 | help="Sampling frequency of the IQ file.") 26 | @click.option("--fs-out", default=4.8e6, show_default=True, 27 | help="Sampling frequency of the IQ file.") 28 | @click.option("--f-if", default=5e3, show_default=True, 29 | help="Intermediate frequency.") 30 | @click.option("--plot/--no-plot", default=False, show_default=True, 31 | help="Visualize data (use only with small files/frequencies).") 32 | @click.option("--normalize/--no-normalize", default=False, show_default=True, 33 | help="Normalize amplitude.") 34 | def generate(input_file, output_file, fs_in, fs_out, f_if, plot, normalize): 35 | """ 36 | Generate RF-PWM square wave timings starting from IQ baseband 37 | """ 38 | print("Opening IQ file") 39 | with open(input_file) as f: 40 | data = np.fromfile(f, dtype=np.complex64) 41 | 42 | print("Starting RF-PWM conversion") 43 | print("Amplitude and phase") 44 | a = np.absolute(data) 45 | phi = np.angle(data) 46 | 47 | if(normalize): 48 | print("Normalization") 49 | a = (a - np.min(a)) / np.ptp(a) 50 | 51 | print("Pre-distortion") 52 | a2 = np.arcsin(a) / np.pi 53 | 54 | print("Resampling fs-in to fs-out") 55 | Nsa = len(a2)*int(fs_out/fs_in) 56 | x = np.linspace(0,len(a2),len(a2)) 57 | xresampled = np.linspace(0,len(a2),len(a2)*int(fs_out/fs_in)) 58 | 59 | fa2 = interp1d(x, a2, kind='cubic') 60 | fphi2 = interp1d(x, phi, kind='cubic') 61 | a2_resampled = fa2(xresampled) 62 | phi_resampled = fphi2(xresampled) 63 | 64 | # a2_resampled = a2.repeat(int(fs_out/fs_in)) 65 | # phi_resampled = phi.repeat(int(fs_out/fs_in)) 66 | 67 | print("Generating IF carrier") 68 | # lambda function to rf-pwm modulate a square wave 69 | modulate = lambda phi, i : np.sign(np.cos(2*np.pi*f_if*i/fs_out + 70 | + phi)) 71 | time = np.linspace(0, Nsa, Nsa) 72 | y = modulate(phi_resampled, time) 73 | 74 | print("Generating pulse timings") 75 | th = [] 76 | t = [] 77 | i = 0 78 | if(y[i] < 0): 79 | while y[i] < 0: 80 | i = i + 1 81 | while(i < len(y)): 82 | j = 0 83 | while i+j < len(y) and y[i+j] > 0: 84 | j = j + 1 85 | while i+j < len(y) and y[i+j] < 0: 86 | j = j + 1 87 | t.append(j) 88 | th.append(a2_resampled[i] * j) 89 | i = i + j 90 | 91 | th = np.array(th) 92 | t = np.array(t) 93 | 94 | print("Saving output file with timings") 95 | with open(output_file, "w") as f: 96 | for x,q in zip(th,t): 97 | Th_ns = 1e9 * x / fs_out 98 | T_ns = 1e9 * q / fs_out 99 | # print("%d %d"%(Th_ns, T_ns)) 100 | f.write("%d %d\n"%(Th_ns, T_ns)) 101 | 102 | if(plot): 103 | time = [i/fs_in for i in range(len(data))] 104 | time2 = [i/fs_out for i in range(len(y))] 105 | 106 | plt.subplots_adjust(hspace = 1) 107 | 108 | plt.subplot(5, 1, 1) 109 | plt.title("Spectrogram") 110 | plt.xlabel("Time (s)") 111 | plt.ylabel("Frequency (Hz)") 112 | plt.specgram(data, Fs=fs_in) 113 | 114 | plt.subplot(5, 1, 2) 115 | plt.title("IQ data") 116 | plt.xlabel("Time (s)") 117 | plt.ylabel("I(t), Q(t)") 118 | plt.plot(time, data.real, label="I(t)") 119 | plt.plot(time, data.imag, label="Q(t)") 120 | plt.legend() 121 | 122 | plt.subplot(5, 1, 3) 123 | plt.title("Amplitude and pre-distorted amplitude") 124 | plt.xlabel("Time (s)") 125 | plt.ylabel("Amplitude(t)") 126 | plt.plot(time, a, label="Original") 127 | plt.plot(time, a2, label="Pre-distorted") 128 | plt.legend() 129 | 130 | plt.subplot(5, 1, 4) 131 | plt.title("Phase") 132 | plt.xlabel("Time (s)") 133 | plt.ylabel("Phase(t) (rad)") 134 | plt.plot(time, phi) 135 | 136 | plt.subplot(5, 1, 5) 137 | plt.title("RF-PWM") 138 | plt.xlabel("Time (s)") 139 | plt.ylabel("RF-PWM(t)") 140 | plt.plot(time2, y) 141 | plt.show() 142 | 143 | if __name__ == "__main__": 144 | cli() 145 | -------------------------------------------------------------------------------- /offline-noise-sdr/transmit/Makefile: -------------------------------------------------------------------------------- 1 | # Giovanni Camurati 2 | # NDK android-ndk-r21d for Arm-V7A and Arm-V8A 3 | # Clang 3.6.2 for x86 4 | # minggw-x64 for windows 5 | # toolchain-mips_34kc_gcc-5.3.0_musl-1.1.14 for MIPS 6 | # Makefile inpired from https://spin.atomicobject.com/2016/08/26/makefile-c-projects/ 7 | # and drammer https://github.com/vusec/drammer 8 | 9 | ARCH ?= v8 10 | OP ?= CIVAC 11 | DEBUG ?= false 12 | OS ?= linux 13 | 14 | ifeq ($(strip $(ARCH)),v8) 15 | 16 | TARGET_ARCH=aarch64-linux-android 17 | LEAKY_OP=-DLEAKY_OP_$(OP) 18 | API=21 19 | TOOLCHAIN=${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${TARGET_ARCH}${API}- 20 | SRC_DIRS=./src/noise-sdr ./src/libion 21 | LDDFLAGS = -lstdc++ --static 22 | CC=${TOOLCHAIN}clang 23 | CXX=${TOOLCHAIN}clang++ 24 | LD=${TOOLCHAIN}llvm-link 25 | INSTALL=adb push $(BUILD_DIR)/$(TARGET_EXEC) /data/local/tmp/ 26 | 27 | else ifeq ($(strip $(ARCH)),v7) 28 | 29 | TARGET_ARCH=armv7a-linux-androideabi 30 | OP=ION 31 | LEAKY_OP=-DLEAKY_OP_$(OP) 32 | API=21 33 | TOOLCHAIN=${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/${TARGET_ARCH}${API}- 34 | SRC_DIRS=./src/noise-sdr ./src/libion 35 | LDDFLAGS = -lstdc++ --static 36 | CC=${TOOLCHAIN}clang 37 | CXX=${TOOLCHAIN}clang++ 38 | LD=${TOOLCHAIN}llvm-link 39 | INSTALL=adb push $(BUILD_DIR)/$(TARGET_EXEC) /data/local/tmp/ 40 | 41 | else ifeq ($(strip $(ARCH)),x86) 42 | 43 | ifeq ($(strip $(OS)),linux) 44 | OP=STREAM 45 | LEAKY_OP=-DLEAKY_OP_$(OP) 46 | TOOLCHAIN= 47 | SRC_DIRS=./src/noise-sdr 48 | LDDFLAGS = -lstdc++ --static -lpthread 49 | CC=${TOOLCHAIN}clang 50 | CXX=${TOOLCHAIN}clang++ 51 | LD=${TOOLCHAIN}llvm-link 52 | INSTALL= 53 | else ifeq ($(strip $(OS)),windows) 54 | OP=STREAM 55 | LEAKY_OP=-DLEAKY_OP_$(OP) 56 | TOOLCHAIN= 57 | SRC_DIRS=./src/noise-sdr 58 | LDDFLAGS = -lstdc++ --static -lpthread 59 | CC=x86_64-w64-mingw32-gcc-posix 60 | CXX=x86_64-w64-mingw32-g++-posix 61 | LD=x86_64-w64-mingw32-ld 62 | INSTALL= 63 | endif 64 | 65 | else ifeq ($(strip $(ARCH)),mips) 66 | 67 | TARGET_ARCH=mips-openwrt-linux 68 | #OP=CNT 69 | OP=CNT 70 | LEAKY_OP=-DLEAKY_OP_$(OP) 71 | SMALL=-DSMALL 72 | TOOLCHAIN=${TOOLCHAIN_MIPS}/bin/${TARGET_ARCH}- 73 | SRC_DIRS=./src/noise-sdr 74 | LDDFLAGS = -lstdc++ -lgcc_pic --static 75 | CC=${TOOLCHAIN}gcc 76 | CXX=${TOOLCHAIN}g++ 77 | LD=${TOOLCHAIN}ld 78 | INSTALL=scp $(BUILD_DIR)/$(TARGET_EXEC) carambola:/home/carambola/ 79 | ARCHFLAGS=-march=mips32r2 80 | 81 | endif 82 | 83 | ifeq ($(strip $(OS)),windows) 84 | TARGET_EXEC=offline-noise-sdr-$(ARCH)-$(OP).exe 85 | else 86 | TARGET_EXEC=offline-noise-sdr-$(ARCH)-$(OP) 87 | endif 88 | 89 | BUILD_DIR ?= ./build 90 | 91 | SRCS := $(shell find $(SRC_DIRS) -name *.cxx -or -name *.c -or -name *.s) 92 | OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) 93 | DEPS := $(OBJS:.o=.d) 94 | 95 | INC_DIRS := $(shell find $(SRC_DIRS) -type d) 96 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) 97 | 98 | HAVE = -DHAVE_STRCASESTR -DHAVE_SETENV 99 | CFLAGS ?= -O3 -Wall $(ARCHFLAGS) $(HAVE) $(LEAKY_OP) $(SMALL) $(INC_FLAGS) -MMD -MP 100 | CXXFLAGS ?= -std=c++11 $(CFLAGS) 101 | 102 | ifeq ($(strip $(DEBUG)),true) 103 | CFLAGS += -ggdb3 104 | CXXFLAGS += -ggdb3 105 | endif 106 | 107 | # https://stackoverflow.com/questions/51602926/how-to-rebuild-when-the-recipe-has-changed 108 | ALLFLAGS=$(ARCH)$(OS)$(OP)$(API)$(CFLAGS)$(CXXFLAGS)$(ASFLAGS)$(LDDFLAGS) 109 | BUILT_MARKER := $(BUILD_DIR)/$(shell echo $(ALLFLAGS) | md5sum | head -c 32).built 110 | 111 | $(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) 112 | @echo $(INC_DIRS) 113 | $(CXX) $(OBJS) -o $@ $(LDDFLAGS) 114 | 115 | $(BUILT_MARKER): 116 | @echo $(BUILT_MARKER) 117 | @mkdir -p $(BUILD_DIR) 118 | @-rm -f $(BUILD_DIR)/*.built 119 | @touch $(BUILT_MARKER) 120 | 121 | # assembly 122 | $(BUILD_DIR)/%.s.o: %.s $(BUILT_MARKER) 123 | $(MKDIR_P) $(dir $@) 124 | $(AS) $(ASFLAGS) -c $< -o $@ 125 | 126 | # c source 127 | $(BUILD_DIR)/%.c.o: %.c $(BUILT_MARKER) 128 | $(MKDIR_P) $(dir $@) 129 | $(CC) $(CFLAGS) -c $< -o $@ 130 | 131 | # c++ source 132 | $(BUILD_DIR)/%.cxx.o: %.cxx $(BUILT_MARKER) 133 | $(MKDIR_P) $(dir $@) 134 | $(CXX) $(CXXFLAGS) -c $< -o $@ 135 | 136 | .PHONY: clean install 137 | 138 | install: $(BUILD_DIR)/$(TARGET_EXEC) $(BUILT_MARKER) 139 | $(INSTALL) 140 | #adb push $(BUILD_DIR)/$(TARGET_EXEC) /data/local/tmp/ 141 | 142 | clean: 143 | $(RM) -r $(BUILD_DIR) 144 | 145 | -include $(DEPS) 146 | 147 | MKDIR_P ?= mkdir -p 148 | -------------------------------------------------------------------------------- /offline-noise-sdr/transmit/src/libion/chipset.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define ALOGE(...) fprintf(stderr, __VA_ARGS__); 5 | 6 | #define CHIPSET_MSM -1 7 | #define CHIPSET_MEDIATEK 1 8 | #define CHIPSET_EXYNOS 4 9 | #define CHIPSET_MAKO 25 10 | #define CHIPSET_TEGRA 2 11 | #define CHIPSET_UNIVERSAL 1 12 | #define CHIPSET_KIRIN 1 13 | #define CHIPSET_SPREADTRUM 2 14 | #define CHIPSET_QCT 22 15 | 16 | int ion_magic_number(int fd, int len) { 17 | // inspired/taken from drammer 18 | int chipset = -1; 19 | int err = -1; 20 | ion_user_handle_t ion_handle; 21 | 22 | // attempt to guess ID from processor type 23 | chipset = CHIPSET_MSM; 24 | std::ifstream cpuinfo("/proc/cpuinfo"); 25 | for (std::string line; getline(cpuinfo, line);) { 26 | if (line.find("Qualcomm") != std::string::npos) { 27 | printf("Detected chipset: Qualcomm\n"); 28 | chipset = CHIPSET_MSM; 29 | break; 30 | } 31 | if (line.find("Exynos") != std::string::npos) { 32 | printf("Detected chipset: Exynos\n"); 33 | chipset = CHIPSET_EXYNOS; 34 | break; 35 | } 36 | if (line.find(": 0x53") != std::string::npos) { 37 | printf("Detected chipset: Exynos\n"); // S7, S7 Edge, but probably more :( 38 | chipset = CHIPSET_EXYNOS; 39 | break; 40 | } 41 | if (line.find(": sc") != std::string::npos) { 42 | // Hardware : sc8830 43 | printf("Detected chipset: Spreadtrum\n"); 44 | chipset = CHIPSET_SPREADTRUM; 45 | break; 46 | } 47 | if (line.find("EXYNOS") != std::string::npos) { 48 | // Samsung EXYNOS5433 49 | printf("Detected chipset: Exynos\n"); 50 | chipset = CHIPSET_EXYNOS; 51 | break; 52 | } 53 | if (line.find("UNIVERSAL") != std::string::npos) { 54 | printf("Detected chipset: UNIVERSAL\n"); 55 | chipset = CHIPSET_UNIVERSAL; 56 | break; 57 | } 58 | if (line.find("MAKO") != std::string::npos) { 59 | printf("Detected chipset: Mako\n"); 60 | chipset = CHIPSET_MAKO; 61 | break; 62 | } 63 | if (line.find("Flounder") != std::string::npos) { 64 | printf("Detected chipset: Tegra\n"); 65 | chipset = CHIPSET_TEGRA; 66 | break; 67 | } 68 | if (line.find(": MT") != std::string::npos) { 69 | printf("Detected chipset: Mediatek\n"); 70 | chipset = CHIPSET_MEDIATEK; 71 | break; 72 | } 73 | if (line.find(": hi") != std::string::npos) { 74 | printf("Detected chipset Kirin\n"); 75 | chipset = CHIPSET_KIRIN; 76 | break; 77 | } 78 | if (line.find("Kirin") != std::string::npos) { 79 | printf("Detected chipset Kirin\n"); 80 | chipset = CHIPSET_KIRIN; 81 | break; 82 | } 83 | if (line.find("MSM8627") != std::string::npos) { 84 | printf("Detected cihpset MSM8627\n"); 85 | chipset = CHIPSET_QCT; 86 | } 87 | } 88 | 89 | // chipset found 90 | if (chipset != -1) { 91 | // try anyhow before returning 92 | printf("Trying chipset %d\n", chipset); 93 | err = ion_alloc(fd, len, 0, (0x1 << chipset), 0, &ion_handle); 94 | if (err == 0) { 95 | // chipset found 96 | ion_free(fd, ion_handle); 97 | printf("Detected chipset %d\n", chipset); 98 | return chipset; 99 | } 100 | } 101 | 102 | // chipset not found, "bruteforcing" 103 | chipset = -1; 104 | while (chipset++ < 1000) { 105 | printf("Trying chipset %d\n", chipset); 106 | err = ion_alloc(fd, len, 0, (0x1 << chipset), 0, &ion_handle); 107 | if (err == 0) { 108 | // chipset found 109 | ion_free(fd, ion_handle); 110 | printf("Detected chipset %d\n", chipset); 111 | return chipset; 112 | } 113 | } 114 | 115 | // chipset not found 116 | return -1; 117 | } 118 | -------------------------------------------------------------------------------- /offline-noise-sdr/transmit/src/libion/include/ion/ion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ion.c 3 | * 4 | * Memory Allocator functions for ion 5 | * 6 | * Copyright 2011 Google, Inc 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #ifndef __SYS_CORE_ION_H 22 | #define __SYS_CORE_ION_H 23 | 24 | #include 25 | #include 26 | 27 | __BEGIN_DECLS 28 | 29 | struct ion_handle; 30 | 31 | int ion_open(); 32 | int ion_close(int fd); 33 | int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, 34 | unsigned int flags, ion_user_handle_t *handle); 35 | int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, 36 | unsigned int flags, int *handle_fd); 37 | int ion_sync_fd(int fd, int handle_fd); 38 | int ion_free(int fd, ion_user_handle_t handle); 39 | int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, 40 | int flags, off_t offset, unsigned char **ptr, int *map_fd); 41 | int ion_share(int fd, ion_user_handle_t handle, int *share_fd); 42 | int ion_import(int fd, int share_fd, ion_user_handle_t *handle); 43 | 44 | int ion_magic_number(int fd, int len); 45 | 46 | __END_DECLS 47 | 48 | #endif /* __SYS_CORE_ION_H */ 49 | -------------------------------------------------------------------------------- /offline-noise-sdr/transmit/src/libion/ion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ion.c 3 | * 4 | * Memory Allocator functions for ion 5 | * 6 | * Copyright 2011 Google, Inc 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | #define LOG_TAG "ion" 21 | 22 | /*#include */ 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #define ALOGE(...) fprintf(stderr, __VA_ARGS__); 34 | 35 | int ion_open() 36 | { 37 | int fd = open("/dev/ion", O_RDONLY); 38 | if (fd < 0) 39 | ALOGE("open /dev/ion failed!\n"); 40 | return fd; 41 | } 42 | 43 | int ion_close(int fd) 44 | { 45 | int ret = close(fd); 46 | if (ret < 0) 47 | return -errno; 48 | return ret; 49 | } 50 | 51 | static int ion_ioctl(int fd, int req, void *arg) 52 | { 53 | int ret = ioctl(fd, req, arg); 54 | if (ret < 0) { 55 | ALOGE("ioctl %x failed with code %d: %s\n", req, 56 | ret, strerror(errno)); 57 | return -errno; 58 | } 59 | return ret; 60 | } 61 | 62 | int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, 63 | unsigned int flags, ion_user_handle_t *handle) 64 | { 65 | int ret; 66 | struct ion_allocation_data data = { 67 | .len = len, 68 | .align = align, 69 | .heap_id_mask = heap_mask, 70 | .flags = flags, 71 | }; 72 | 73 | if (handle == NULL) 74 | return -EINVAL; 75 | 76 | ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); 77 | if (ret < 0) 78 | return ret; 79 | *handle = data.handle; 80 | return ret; 81 | } 82 | 83 | int ion_free(int fd, ion_user_handle_t handle) 84 | { 85 | struct ion_handle_data data = { 86 | .handle = handle, 87 | }; 88 | return ion_ioctl(fd, ION_IOC_FREE, &data); 89 | } 90 | 91 | int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, 92 | int flags, off_t offset, unsigned char **ptr, int *map_fd) 93 | { 94 | int ret; 95 | unsigned char *tmp_ptr; 96 | struct ion_fd_data data = { 97 | .handle = handle, 98 | }; 99 | 100 | if (map_fd == NULL) 101 | return -EINVAL; 102 | if (ptr == NULL) 103 | return -EINVAL; 104 | 105 | ret = ion_ioctl(fd, ION_IOC_MAP, &data); 106 | if (ret < 0) 107 | return ret; 108 | if (data.fd < 0) { 109 | ALOGE("map ioctl returned negative fd\n"); 110 | return -EINVAL; 111 | } 112 | tmp_ptr = mmap(NULL, length, prot, flags, data.fd, offset); 113 | if (tmp_ptr == MAP_FAILED) { 114 | ALOGE("mmap failed: %s\n", strerror(errno)); 115 | return -errno; 116 | } 117 | *map_fd = data.fd; 118 | *ptr = tmp_ptr; 119 | return ret; 120 | } 121 | 122 | int ion_share(int fd, ion_user_handle_t handle, int *share_fd) 123 | { 124 | int ret; 125 | struct ion_fd_data data = { 126 | .handle = handle, 127 | }; 128 | 129 | if (share_fd == NULL) 130 | return -EINVAL; 131 | 132 | ret = ion_ioctl(fd, ION_IOC_SHARE, &data); 133 | if (ret < 0) 134 | return ret; 135 | if (data.fd < 0) { 136 | ALOGE("share ioctl returned negative fd\n"); 137 | return -EINVAL; 138 | } 139 | *share_fd = data.fd; 140 | return ret; 141 | } 142 | 143 | int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, 144 | unsigned int flags, int *handle_fd) { 145 | ion_user_handle_t handle; 146 | int ret; 147 | 148 | ret = ion_alloc(fd, len, align, heap_mask, flags, &handle); 149 | if (ret < 0) 150 | return ret; 151 | ret = ion_share(fd, handle, handle_fd); 152 | ion_free(fd, handle); 153 | return ret; 154 | } 155 | 156 | int ion_import(int fd, int share_fd, ion_user_handle_t *handle) 157 | { 158 | int ret; 159 | struct ion_fd_data data = { 160 | .fd = share_fd, 161 | }; 162 | 163 | if (handle == NULL) 164 | return -EINVAL; 165 | 166 | ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); 167 | if (ret < 0) 168 | return ret; 169 | *handle = data.handle; 170 | return ret; 171 | } 172 | 173 | int ion_sync_fd(int fd, int handle_fd) 174 | { 175 | struct ion_fd_data data = { 176 | .fd = handle_fd, 177 | }; 178 | return ion_ioctl(fd, ION_IOC_SYNC, &data); 179 | } 180 | -------------------------------------------------------------------------------- /offline-noise-sdr/transmit/src/libion/kernel-headers/linux/ion.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_LINUX_ION_H 20 | #define _UAPI_LINUX_ION_H 21 | #include 22 | #include 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | typedef int ion_user_handle_t; 25 | enum ion_heap_type { 26 | ION_HEAP_TYPE_SYSTEM, 27 | ION_HEAP_TYPE_SYSTEM_CONTIG, 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | ION_HEAP_TYPE_CARVEOUT, 30 | ION_HEAP_TYPE_CHUNK, 31 | ION_HEAP_TYPE_DMA, 32 | ION_HEAP_TYPE_CUSTOM, 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | ION_NUM_HEAPS = 16, 35 | }; 36 | #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) 37 | #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) 40 | #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) 41 | #define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 42 | #define ION_FLAG_CACHED 1 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | #define ION_FLAG_CACHED_NEEDS_SYNC 2 45 | struct ion_allocation_data { 46 | size_t len; 47 | size_t align; 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | unsigned int heap_id_mask; 50 | unsigned int flags; 51 | ion_user_handle_t handle; 52 | }; 53 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 | struct ion_fd_data { 55 | ion_user_handle_t handle; 56 | int fd; 57 | }; 58 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 | struct ion_handle_data { 60 | ion_user_handle_t handle; 61 | }; 62 | struct ion_custom_data { 63 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 | unsigned int cmd; 65 | unsigned long arg; 66 | }; 67 | #define ION_IOC_MAGIC 'I' 68 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 | #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data) 70 | #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) 71 | #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data) 72 | #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) 73 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 74 | #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data) 75 | #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data) 76 | #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data) 77 | #endif 78 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 79 | -------------------------------------------------------------------------------- /scripts/fig12.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | 3 | import pandas as pd 4 | import numpy as np 5 | from matplotlib import pyplot as plt 6 | from tabulate import tabulate 7 | 8 | df = pd.read_csv("data/ft4-turing-2020-08-12-log.csv") 9 | df.columns = ["distance", "side", "usrpgain", "sent", "time", "snr", "timeoffset", 10 | "freqoffset", "", "m1", "m2", "m3"] 11 | 12 | correct = df["m1"] == "IU7GTP" 13 | df['correct'] = correct 14 | 15 | print(df) 16 | 17 | # tab = df.groupby(["distance", "side"]).agg({ 18 | tab = df.groupby(["distance"]).agg({ 19 | "" : ["count"], 20 | "correct" : ["mean"], 21 | "snr": ["mean", "std"] 22 | # "freqoffset": ["mean", "std"] 23 | }) 24 | 25 | print(tab) 26 | 27 | # names = ["d (m) and side", "rx (40 tx)", "avg(snr)", "std(snr)", "\% correct"] 28 | names = ["d (m)", "rx (160 tx)", "avg(snr)", "std(snr)", "\% correct"] 29 | print(tabulate(tab, headers=names, tablefmt="latex_raw", floatfmt=".2f")) 30 | 31 | # print(tabulate(list(zip(*table)), tablefmt="latex_raw", floatfmt=".2f")) 32 | 33 | df = df[df['correct']==True] 34 | 35 | up = df[df['side']=='Up'].groupby(["distance"]).agg({ 36 | "" : ["count"], 37 | "correct" : ["mean"], 38 | "snr": ["mean", "std"] 39 | # "freqoffset": ["mean", "std"] 40 | }) 41 | 42 | right = df[df['side']=='Right'].groupby(["distance"]).agg({ 43 | "" : ["count"], 44 | "correct" : ["mean"], 45 | "snr": ["mean", "std"] 46 | # "freqoffset": ["mean", "std"] 47 | }) 48 | 49 | down = df[df['side']=='Down'].groupby(["distance"]).agg({ 50 | "" : ["count"], 51 | "correct" : ["mean"], 52 | "snr": ["mean", "std"] 53 | # "freqoffset": ["mean", "std"] 54 | }) 55 | 56 | left = df[df['side']=='Left'].groupby(["distance"]).agg({ 57 | "" : ["count"], 58 | "correct" : ["mean"], 59 | "snr": ["mean", "std"] 60 | # "freqoffset": ["mean", "std"] 61 | }) 62 | 63 | SMALL_SIZE = 8*3 64 | MEDIUM_SIZE = 10*3 65 | BIGGER_SIZE = 12*3 66 | 67 | plt.rc('font', size=SMALL_SIZE) # controls default text sizes 68 | plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title 69 | plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels 70 | plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels 71 | plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels 72 | plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize 73 | plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title 74 | 75 | plt.subplots_adjust(hspace = 1) 76 | # plt.subplots_adjust(left = 0.4) 77 | 78 | plt.subplot(2, 2, 1) 79 | 80 | plt.ylabel('SNR (dB)') 81 | plt.xlabel('distance (m)') 82 | plt.plot(up['snr']['mean']) 83 | plt.plot(right['snr']['mean']) 84 | plt.plot(down['snr']['mean']) 85 | plt.plot(left['snr']['mean']) 86 | 87 | plt.subplot(2, 2, 2) 88 | 89 | plt.ylabel("% rx") 90 | plt.xlabel('distance (m)') 91 | plt.plot(100 * up['']['count'] / 40.0, label='Up') 92 | plt.plot(100 * right['']['count'] / 40.0, label='Right') 93 | plt.plot(100 * down['']['count'] / 40.0, label='Down') 94 | plt.plot(100 * left['']['count'] / 40.0, label='Left') 95 | plt.legend() 96 | plt.show() 97 | 98 | # import IPython; IPython.embed() 99 | -------------------------------------------------------------------------------- /scripts/fig15.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | 3 | import numpy as np 4 | from matplotlib import pyplot as plt 5 | 6 | SMALL_SIZE = 8*3 7 | MEDIUM_SIZE = 10*3 8 | BIGGER_SIZE = 12*3 9 | 10 | plt.rc('font', size=SMALL_SIZE) # controls default text sizes 11 | # plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title 12 | # plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels 13 | # plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels 14 | # plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels 15 | # plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize 16 | # plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title 17 | 18 | ovsr = 8 19 | f_if = 10e3 20 | f_s = 80e3 21 | f_ovs = f_s*ovsr 22 | n_periods = 2 23 | 24 | time_ms = np.array([i/1000 for i in range(n_periods*int(f_ovs/f_if))]) 25 | x_if = np.array([np.sin(2*np.pi*f_if*i/f_ovs) for i in 26 | range(n_periods*int(f_ovs/f_if))]) 27 | 28 | x_rfpwm = np.sign(x_if) 29 | 30 | x_if = (x_if+1)/2 31 | x_rfpwm = (x_rfpwm+1)/2 32 | bb = np.array([0.5 for i in range(n_periods*int(f_ovs/f_if))]) 33 | 34 | x_pwm = [] 35 | for i in range(0, n_periods*int(f_ovs/f_if), ovsr): 36 | for j in range(ovsr): 37 | if j < int(x_if[i]*ovsr): 38 | x_pwm.append(1) 39 | else: 40 | x_pwm.append(0) 41 | 42 | 43 | plt.subplots_adjust(hspace = 1) 44 | # plt.subplots_adjust(wspace = 1) 45 | # plt.subplot(2,2,1) 46 | # plt.plot(time_ms, x_pwm, 'b') 47 | # plt.plot(time_ms, x_if,'r--') 48 | 49 | # plt.subplot(2,2,2) 50 | # plt.plot(time_ms, x_if,'r') 51 | 52 | # plt.subplot(2,2,3) 53 | # plt.plot(time_ms, x_rfpwm, 'b') 54 | # plt.plot(time_ms, (2/np.pi)*(x_if-0.5), 'r--') 55 | 56 | # plt.subplot(2,2,4) 57 | # plt.plot(time_ms, (2/np.pi)*(x_if-0.5),'r') 58 | 59 | plt.subplot(2,1,1) 60 | plt.plot(time_ms, x_pwm, label="PWM") 61 | plt.plot(time_ms, x_if,'--', label="cos") 62 | # plt.ylabel("x(t)") 63 | # plt.xlabel("t (ms)") 64 | # plt.legend() 65 | 66 | plt.subplot(2,1,2) 67 | plt.plot(time_ms, x_rfpwm, label="RF-PWM") 68 | plt.plot(time_ms, (2/np.pi)*(x_if-0.5), '--', label="cos") 69 | # plt.xlabel("t (ms)") 70 | # plt.ylabel("x(t)") 71 | # plt.legend() 72 | 73 | plt.show() 74 | -------------------------------------------------------------------------------- /scripts/fig3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | 3 | import numpy as np 4 | from matplotlib import pyplot as plt 5 | 6 | # Run ./build/fldigi-noise-sdr-x86-STREAM -d "Hello" -m MODE_3X_PSK250R -o 7 | # buffer.txt -w data/rfpwm.txt -c 4000 8 | # to generate the waveforms 9 | 10 | SMALL_SIZE = 8*3 11 | MEDIUM_SIZE = 10*3 12 | BIGGER_SIZE = 12*3 13 | 14 | plt.rc('font', size=SMALL_SIZE) # controls default text sizes 15 | # plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title 16 | # plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels 17 | # plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels 18 | # plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels 19 | # plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize 20 | # plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title 21 | 22 | Fs=80000 23 | Fc = 4000 24 | B = 700 25 | 26 | x = np.loadtxt("data/buffer.txt") 27 | z = np.loadtxt("data/rfpwm.txt") 28 | 29 | y = [] 30 | for t in z: 31 | th = int(1e-9*t[0]*Fs) 32 | tl = int(1e-9*t[1]*Fs) - th 33 | for i in range(th): 34 | y.append(1) 35 | for i in range(tl): 36 | y.append(0) 37 | 38 | plt.subplots_adjust(hspace = 1) 39 | plt.subplot(2,1,1) 40 | 41 | plt.plot(y[250:700]) 42 | plt.plot(x[250:700]) 43 | # plt.show() 44 | 45 | plt.subplot(2,1,2) 46 | plt.psd(y, Fs=Fs, NFFT=4096*2) 47 | plt.psd(x, Fs=Fs, NFFT=4096*2) 48 | plt.axvline(x=Fc-B, color='g') 49 | plt.axvline(x=Fc+B, color='g') 50 | plt.show() 51 | 52 | 53 | # plt.subplots_adjust(left = 0.4) 54 | 55 | # plt.subplot(6, 1, 1) 56 | # plt.plot(a) 57 | # plt.ylabel("a(t) ", rotation="horizontal",ha='right',va='center') 58 | 59 | # plt.subplot(6, 1, 2) 60 | # plt.plot(phi) 61 | # plt.ylabel("\u03B8(t) ", rotation="horizontal",ha='right',va='center') 62 | 63 | # plt.subplot(6, 1, 3) 64 | # # plt.plot(y) 65 | # plt.plot(rfpwm) 66 | # plt.ylabel("x(t) ", rotation="horizontal",ha='right',va='center') 67 | 68 | # plt.subplot(6, 1, 4) 69 | # # plt.plot(y) 70 | # plt.plot(a) 71 | # plt.ylabel("\u03B4(t) ", rotation="horizontal",ha='right',va='center') 72 | 73 | # plt.subplot(6, 1, 5) 74 | # # plt.plot(y) 75 | # plt.plot(fundamental, 'r') 76 | # plt.ylabel("k=1 ", rotation="horizontal",ha='right',va='center') 77 | 78 | # plt.subplot(6, 1, 6) 79 | # # plt.plot(y) 80 | # plt.plot(harmonic) 81 | # plt.ylabel("k=2", rotation="horizontal",ha='right',va='center') 82 | 83 | # plt.xlabel("Samples") 84 | # plt.show() 85 | 86 | # plt.plot(rfpwm); plt.show() 87 | # plt.plot(fundamental); plt.show() 88 | # plt.plot(harmonic); plt.show() 89 | -------------------------------------------------------------------------------- /vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure("2") do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://vagrantcloud.com/search. 15 | config.vm.box = "ubuntu/bionic64" 16 | 17 | # Disable automatic box update checking. If you disable this, then 18 | # boxes will only be checked for updates when the user runs 19 | # `vagrant box outdated`. This is not recommended. 20 | # config.vm.box_check_update = false 21 | 22 | # Create a forwarded port mapping which allows access to a specific port 23 | # within the machine from a port on the host machine. In the example below, 24 | # accessing "localhost:8080" will access port 80 on the guest machine. 25 | # NOTE: This will enable public access to the opened port 26 | # config.vm.network "forwarded_port", guest: 80, host: 8080 27 | 28 | # Create a forwarded port mapping which allows access to a specific port 29 | # within the machine from a port on the host machine and only allow access 30 | # via 127.0.0.1 to disable public access 31 | # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" 32 | 33 | # Create a private network, which allows host-only access to the machine 34 | # using a specific IP. 35 | # config.vm.network "private_network", ip: "192.168.33.10" 36 | 37 | # Create a public network, which generally matched to bridged network. 38 | # Bridged networks make the machine appear as another physical device on 39 | # your network. 40 | # config.vm.network "public_network" 41 | 42 | # Share an additional folder to the guest VM. The first argument is 43 | # the path on the host to the actual folder. The second argument is 44 | # the path on the guest to mount the folder. And the optional third 45 | # argument is a set of non-required options. 46 | #config.vm.synced_folder "../data", "/vagrant_data" 47 | 48 | # X forwarding 49 | config.ssh.forward_x11 = true 50 | 51 | # Agent forwarding 52 | config.ssh.forward_agent = true 53 | 54 | # Provider-specific configuration so you can fine-tune various 55 | # backing providers for Vagrant. These expose provider-specific options. 56 | # Example for VirtualBox: 57 | # 58 | config.vm.provider "virtualbox" do |vb| 59 | # Display the VirtualBox GUI when booting the machine 60 | #vb.gui = true 61 | 62 | # Customize the amount of memory on the VM: 63 | vb.memory = "2048" 64 | 65 | # Disk size, requires: 66 | # vagrant plugin install vagrant-disksize 67 | config.disksize.size = '20GB' 68 | 69 | # Audio (Linux) 70 | vb.customize ["modifyvm", :id, "--ioapic", "on", '--audio', 'pulse', '--audiocontroller', 'ac97'] 71 | #vb.customize ["modifyvm", :id, "--ioapic", "on", '--audio', 'alsa', '--audiocontroller', 'hda'] 72 | # Audio (Windows) # Not tested 73 | #vb.customize ["modifyvm", :id, "--ioapic", "on", '--audio', 'dsound', '--audiocontroller', 'hda'] 74 | # Audio (MAC) # Not tested 75 | #vb.customize ["modifyvm", :id, "--ioapic", "on", '--audio', 'coreaudio', '--audiocontroller', 'hda'] 76 | vb.customize ["modifyvm", :id, "--audioin", "off"] 77 | vb.customize ["modifyvm", :id, "--audioout", "on"] 78 | 79 | # USB 3.0 80 | vb.customize ["modifyvm", :id, "--usb", "on"] 81 | vb.customize ["modifyvm", :id, "--usbxhci", "on"] 82 | 83 | # Note 84 | # Add the devices you want here. Run lsusb to get the vendor/product ids. 85 | # You can also run virtualbox, click "show" on this vagrant machine, and then 86 | # use the GUI to add/remove USB devices (valid in general for any setting). 87 | 88 | # SDRs 89 | vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'RTL2838 DVB-T', '--vendorid', '0x0bda', '--productid', '0x2838'] 90 | vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'USPR B210', '--vendorid', '0x2500', '--productid', '0x0020'] 91 | vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'HackRF', '--vendorid', '0x1d50', '--productid', '0x6089'] 92 | 93 | # Phones 94 | #vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'Samsung Galaxy Mini S5', '--vendorid', '0x04e8', '--productid', '0x6860'] 95 | end 96 | 97 | # 98 | # View the documentation for the provider you are using for more 99 | # information on available options. 100 | 101 | # Enable provisioning with a shell script. Additional provisioners such as 102 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 103 | # documentation for more information about their specific syntax and use. 104 | # config.vm.provision "shell", inline: <<-SHELL 105 | # apt-get update 106 | # apt-get install -y apache2 107 | # SHELL 108 | config.vm.provision :shell, path: "./bootstrap.sh", privileged: false 109 | end 110 | -------------------------------------------------------------------------------- /vagrant/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # update 4 | sudo apt-get update 5 | 6 | mkdir -p /home/vagrant/tools 7 | 8 | # utils 9 | sudo apt-get install -y \ 10 | firefox \ 11 | tmux \ 12 | tig \ 13 | python-pip \ 14 | python3-pip \ 15 | gtk+3.0 \ 16 | pavucontrol \ 17 | alsa \ 18 | alsa-utils \ 19 | adb \ 20 | cmake \ 21 | swig 22 | 23 | pip3 install \ 24 | numpy==1.19.5 \ 25 | matplotlib==3.3.4 \ 26 | PyQt5==5.9.2 \ 27 | pandas==1.1.5 \ 28 | tabulate==0.8.9 \ 29 | tqdm==4.48.0 \ 30 | click==7.1.2 31 | 32 | 33 | # sdr tools 34 | sudo apt-get install -y \ 35 | gnuradio \ 36 | qsstv \ 37 | fldigi \ 38 | gqrx-sdr \ 39 | 40 | 41 | sudo apt-get install -y build-essential cmake git pkg-config libboost-dev \ 42 | libboost-date-time-dev libboost-system-dev libboost-filesystem-dev \ 43 | libboost-thread-dev libboost-chrono-dev libboost-serialization-dev \ 44 | libboost-program-options-dev libboost-test-dev liblog4cpp5-dev \ 45 | libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev \ 46 | libarmadillo-dev libgflags-dev libgoogle-glog-dev libhdf5-dev \ 47 | libgnutls-openssl-dev libmatio-dev libpugixml-dev libpcap-dev \ 48 | libprotobuf-dev protobuf-compiler libgtest-dev googletest \ 49 | python3-mako python3-six 50 | 51 | cd /home/vagrant/tools/ 52 | git clone https://github.com/gnss-sdr/gnss-sdr 53 | cd gnss-sdr/build 54 | git checkout 66a908fc42debcb7157acd773bccc056233bdc9a 55 | cmake .. 56 | make 57 | sudo make install 58 | sudo ldconfig 59 | 60 | 61 | cd /home/vagrant/tools/ 62 | git clone https://github.com/gnss-sdr/gnss-sdr 63 | sudo apt-get install -y gfortran libgfortran5 libqt5widgets5 libqt5network5 \ 64 | libqt5printsupport5 libqt5multimedia5-plugins qtmultimedia5-dev libqt5serialport5-dev \ 65 | libqt5sql5-sqlite libfftw3-single3 libgomp1 libboost-all-dev \ 66 | libusb-1.0-0-dev qtbase5-dev qttools5-dev libudev-dev 67 | wget https://physics.princeton.edu/pulsar/k1jt/wsjtx-2.4.0.tgz 68 | tar -xvzf wsjtx-2.4.0.tgz 69 | cd wsjtx-2.4.0/ 70 | mkdir build 71 | cd build 72 | cmake -DWSJT_SKIP_MANPAGES=ON -DWSJT_GENERATE_DOCS=OFF ../ 73 | cmake --build . 74 | sudo cmake --build . --target install 75 | 76 | # sdr dongles 77 | sudo apt-get install -y \ 78 | hackrf \ 79 | uhd-host \ 80 | rtl-sdr 81 | 82 | sudo uhd_images_downloader 83 | 84 | cd /etc/udev/rules.d 85 | sudo wget https://raw.githubusercontent.com/keenerd/rtl-sdr/master/rtl-sdr.rules 86 | sudo wget https://raw.githubusercontent.com/EttusResearch/uhd/master/host/utils/uhd-usrp.rules 87 | sudo wget https://raw.githubusercontent.com/mossmann/hackrf/master/host/libhackrf/53-hackrf.rules 88 | sudo udevadm control --reload-rules 89 | sudo usermod -a -G plugdev vagrant 90 | 91 | 92 | # toolchains 93 | sudo apt-get install -y \ 94 | clang \ 95 | mingw-w64 96 | 97 | cd /home/vagrant/tools 98 | wget https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip 99 | unzip android-ndk-r21d-linux-x86_64.zip 100 | echo "export NDK=/home/vagrant/tools/android-ndk-r21d" >> /home/vagrant/.profile 101 | source /home/vagrant/.profile 102 | 103 | 104 | 105 | cd /home/vagrant/tools 106 | wget https://pkg.8devices.com/carambola2/v2.9/OpenWrt-8devices-Toolchain-v2.9-ar71xx-generic_gcc-5.3.0_musl-1.1.14.Linux-x86_64.tar.bz2 107 | tar -xf OpenWrt-8devices-Toolchain-v2.9-ar71xx-generic_gcc-5.3.0_musl-1.1.14.Linux-x86_64.tar.bz2 108 | echo "export TOOLCHAIN_MIPS=/home/vagrant/tools/OpenWrt-8devices-Toolchain-v2.9-ar71xx-generic_gcc-5.3.0_musl-1.1.14.Linux-x86_64/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.14/" >> /home/vagrant/.profile 109 | source /home/vagrant/.profile 110 | 111 | # noise-sdr 112 | cd /home/vagrant/ 113 | ssh-keyscan -H github.com > ~/.ssh/known_hosts 114 | git clone git@github.com:eurecom-s3/noise-sdr.git 115 | cd noise-sdr 116 | #git checkout release 117 | 118 | mkdir -p /vagrant/bin/ 119 | 120 | cd /home/vagrant/noise-sdr/fldigi-noise-sdr 121 | make ARCH=x86 122 | make ARCH=x86 OS=windows 123 | make ARCH=v8 OP=CIVAC 124 | make ARCH=v8 OP=ION 125 | make ARCH=v7 126 | make ARCH=mips 127 | cp build/fldigi-* /vagrant/bin 128 | 129 | cd /home/vagrant/noise-sdr/offline-noise-sdr/transmit 130 | make ARCH=x86 131 | make ARCH=x86 OS=windows 132 | make ARCH=v8 OP=CIVAC 133 | make ARCH=v8 OP=ION 134 | make ARCH=v7 135 | make ARCH=mips 136 | cp build/offline-* /vagrant/bin 137 | 138 | cd /home/vagrant/noise-sdr/gnuradio/ 139 | git clone git@github.com:eurecom-s3/gr-lora_sdr-noise-sdr.git 140 | cd /home/vagrant/noise-sdr/gnuradio/gr-lora_sdr-noise-sdr 141 | mkdir build 142 | cd build 143 | cmake ../ 144 | make 145 | sudo make install 146 | sudo ldconfig 147 | echo 'export PYTHONPATH=$PYTHONPATH:/home/vagrant/lora_sdr/lib/python2.7/dist-packages/' >> /home/vagrant/.profile 148 | echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/vagrant/lora_sdr/lib/' >> /home/vagrant/.profile 149 | echo 'export GRC_BLOCKS_PATH=$GRC_BLOCKS_PATH:/home/vagrant/noise-sdr/gnuradio/gr-lora_sdr-noise-sdr/grc' >> /home/vagrant/.profile 150 | source /home/vagrant/.profile 151 | pip install pandas==0.24.2 unidecode==1.2.0 152 | 153 | ## Create null sink 154 | pulseaudio --start 155 | pacmd load-module module-null-sink sink_name=MySink 156 | 157 | ## Copy some configs 158 | cd /home/vagrant/noise-sdr/ 159 | mkdir -p /home/vagrant/.config/gqrx/ 160 | mkdir -p /home/vagrant/.fldigi/ 161 | cp configs/gqrx-example-b210.conf /home/vagrant/.config/gqrx/ 162 | cp configs/fldigi_def_example.xml /home/vagrant/.fldigi/fldigi_def.xml 163 | cp configs/WSJT-X-example.ini /home/vagrant/.config/WSJT-X.ini 164 | --------------------------------------------------------------------------------