use git-submodule for libraries #2

Open
laforge wants to merge 4 commits from laforge/osmocom-analog:laforge/submodule into master
272 changed files with 929 additions and 55188 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/lib"]
path = src/lib
url = https://gitea.osmocom.org/cellular-infrastructure/osmocom-analog-libraries.git

View File

@ -61,38 +61,38 @@ AS_IF([test "x$with_alsa" != "xyes" -a "x$with_sdr" != "xyes"],[AC_MSG_NOTICE( W
SOAPY_CFLAGS="$soapy_0_8_0_or_higher"
AC_OUTPUT(
src/liboptions/Makefile
src/libdebug/Makefile
src/libmobile/Makefile
src/libdisplay/Makefile
src/libimage/Makefile
src/libsendevolumenregler/Makefile
src/libcompandor/Makefile
src/libgoertzel/Makefile
src/libjitter/Makefile
src/libsquelch/Makefile
src/libhagelbarger/Makefile
src/libdtmf/Makefile
src/libtimer/Makefile
src/libsamplerate/Makefile
src/libscrambler/Makefile
src/libemphasis/Makefile
src/libfsk/Makefile
src/libam/Makefile
src/libfm/Makefile
src/libfilter/Makefile
src/libwave/Makefile
src/libfft/Makefile
src/libsound/Makefile
src/libsdr/Makefile
src/libsample/Makefile
src/libclipper/Makefile
src/libserial/Makefile
src/libv27/Makefile
src/libmtp/Makefile
src/libosmocc/Makefile
src/libg711/Makefile
src/libaaimage/Makefile
src/lib/liboptions/Makefile
src/lib/libdebug/Makefile
src/lib/libmobile/Makefile
src/lib/libdisplay/Makefile
src/lib/libimage/Makefile
src/lib/libsendevolumenregler/Makefile
src/lib/libcompandor/Makefile
src/lib/libgoertzel/Makefile
src/lib/libjitter/Makefile
src/lib/libsquelch/Makefile
src/lib/libhagelbarger/Makefile
src/lib/libdtmf/Makefile
src/lib/libtimer/Makefile
src/lib/libsamplerate/Makefile
src/lib/libscrambler/Makefile
src/lib/libemphasis/Makefile
src/lib/libfsk/Makefile
src/lib/libam/Makefile
src/lib/libfm/Makefile
src/lib/libfilter/Makefile
src/lib/libwave/Makefile
src/lib/libfft/Makefile
src/lib/libsound/Makefile
src/lib/libsdr/Makefile
src/lib/libsample/Makefile
src/lib/libclipper/Makefile
src/lib/libserial/Makefile
src/lib/libv27/Makefile
src/lib/libmtp/Makefile
src/lib/libosmocc/Makefile
src/lib/libg711/Makefile
src/lib/libaaimage/Makefile
src/anetz/Makefile
src/bnetz/Makefile
src/cnetz/Makefile

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../src/lib
bin_PROGRAMS = \
cnetz_memory_card_generator
@ -7,6 +7,6 @@ cnetz_memory_card_generator_SOURCES = \
main.c
cnetz_memory_card_generator_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/liboptions/liboptions.a
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/liboptions/liboptions.a

View File

@ -22,8 +22,8 @@
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <../src/libdebug/debug.h>
#include <../src/liboptions/options.h>
#include <libdebug/debug.h>
#include <liboptions/options.h>
int num_kanal = 1;
static uint8_t magic1 = 0x1e;

View File

@ -1,45 +1,45 @@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = \
liboptions \
libdebug \
libmobile \
libdisplay \
libsample \
libimage \
libsendevolumenregler \
libcompandor \
libgoertzel \
libjitter \
libsquelch \
libhagelbarger \
libdtmf \
libtimer \
libsamplerate \
libscrambler \
libemphasis \
libfsk \
libam \
libfm \
libfilter \
libwave \
libfft \
libclipper \
libserial \
libv27 \
libmtp \
libosmocc \
libg711 \
libaaimage
lib/liboptions \
lib/libdebug \
lib/libmobile \
lib/libdisplay \
lib/libsample \
lib/libimage \
lib/libsendevolumenregler \
lib/libcompandor \
lib/libgoertzel \
lib/libjitter \
lib/libsquelch \
lib/libhagelbarger \
lib/libdtmf \
lib/libtimer \
lib/libsamplerate \
lib/libscrambler \
lib/libemphasis \
lib/libfsk \
lib/libam \
lib/libfm \
lib/libfilter \
lib/libwave \
lib/libfft \
lib/libclipper \
lib/libserial \
lib/libv27 \
lib/libmtp \
lib/libosmocc \
lib/libg711 \
lib/libaaimage
if HAVE_ALSA
SUBDIRS += \
libsound
lib/libsound
endif
if HAVE_SDR
SUBDIRS += \
libsdr
lib/libsdr
endif
SUBDIRS += \

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
amps
@ -29,36 +29,36 @@ amps_LDADD = \
$(COMMON_LA) \
libamps.a \
libusatone.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libcompandor/libcompandor.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libcompandor/libcompandor.a \
$(top_builddir)/src/lib/libgoertzel/libgoertzel.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
amps_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
amps_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -42,11 +42,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "amps.h"
#include "dsp.h"
#include "frame.h"

View File

@ -1,7 +1,7 @@
#include "../libgoertzel/goertzel.h"
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include "../libcompandor/compandor.h"
#include <libgoertzel/goertzel.h>
#include <libmobile/sender.h>
#include <libtimer/timer.h>
#include <libcompandor/compandor.h>
typedef struct amps amps_t;
#include "sysinfo.h"
#include "transaction.h"

View File

@ -22,12 +22,12 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../liboptions/options.h"
#include "../libfm/fm.h"
#include <libsample/sample.h>
#include <libmobile/main_mobile.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <liboptions/options.h>
#include <libfm/fm.h>
#include "amps.h"
#include "dsp.h"
#include "frame.h"

View File

@ -81,9 +81,9 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include "amps.h"
#include "frame.h"
#include "dsp.h"

View File

@ -26,8 +26,8 @@
#include <errno.h>
#include <math.h>
#include <inttypes.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include "amps.h"
#include "dsp.h"
#include "frame.h"

View File

@ -3,7 +3,7 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "../libsample/sample.h"
#include <libsample/sample.h>
#include "amps.h"
#include "frame.h"
#include "main.h"

View File

@ -20,10 +20,10 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include "amps.h"
//#include "database.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
anetz
@ -18,36 +18,36 @@ anetz_SOURCES = \
anetz_LDADD = \
$(COMMON_LA) \
libgermanton.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libgoertzel/libgoertzel.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libsquelch/libsquelch.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
anetz_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
anetz_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -24,12 +24,12 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "anetz.h"
#include "dsp.h"

View File

@ -1,6 +1,6 @@
#include "../libsquelch/squelch.h"
#include "../libgoertzel/goertzel.h"
#include "../libmobile/sender.h"
#include <libsquelch/squelch.h>
#include <libgoertzel/goertzel.h>
#include <libmobile/sender.h>
enum dsp_mode {
DSP_MODE_SILENCE, /* send silence to transmitter, block audio from receiver */

View File

@ -25,10 +25,10 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include "anetz.h"
#include "dsp.h"

View File

@ -23,13 +23,13 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include "../liboptions/options.h"
#include "../libfm/fm.h"
#include <libsample/sample.h>
#include <libmobile/main_mobile.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include <liboptions/options.h>
#include <libfm/fm.h>
#include "freiton.h"
#include "besetztton.h"
#include "anetz.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
bnetz \
@ -15,23 +15,23 @@ bnetz_SOURCES = \
bnetz_LDADD = \
$(COMMON_LA) \
../anetz/libgermanton.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfsk/libfsk.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libsquelch/libsquelch.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfsk/libfsk.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
bnetz_dialer_SOURCES = \
@ -39,31 +39,31 @@ bnetz_dialer_SOURCES = \
dialer.c
bnetz_dialer_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libfsk/libfsk.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libfsk/libfsk.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(ALSA_LIBS)
-lm
if HAVE_ALSA
bnetz_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
bnetz_dialer_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
bnetz_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -24,11 +24,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "bnetz.h"
#include "telegramm.h"
#include "dsp.h"

View File

@ -1,7 +1,7 @@
#include "../libsquelch/squelch.h"
#include "../libfsk/fsk.h"
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include <libsquelch/squelch.h>
#include <libfsk/fsk.h>
#include <libmobile/sender.h>
#include <libtimer/timer.h>
/* fsk modes of transmission */
enum dsp_mode {

View File

@ -23,14 +23,14 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libfsk/fsk.h"
#include "../libwave/wave.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libfsk/fsk.h>
#include <libwave/wave.h>
#include <libdebug/debug.h>
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#include <libsound/sound.h>
#endif
#include "../liboptions/options.h"
#include <liboptions/options.h>
#include "telegramm.h"
#define MAX_PAUSE 0.5 /* pause before and after dialing sequence */

View File

@ -25,9 +25,9 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include "bnetz.h"
#include "dsp.h"

View File

@ -23,13 +23,13 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/main_mobile.h>
#include "../anetz/freiton.h"
#include "../anetz/besetztton.h"
#include "../liboptions/options.h"
#include <liboptions/options.h>
#include "bnetz.h"
#include "dsp.h"
#include "stations.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
cnetz
@ -23,36 +23,36 @@ cnetz_LDADD = \
$(COMMON_LA) \
../anetz/libgermanton.a \
libcnetztones.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libcompandor/libcompandor.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libscrambler/libscrambler.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libcompandor/libcompandor.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libscrambler/libscrambler.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
cnetz_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
cnetz_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -142,11 +142,11 @@
#include <errno.h>
#include <math.h>
#include <inttypes.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "cnetz.h"
#include "database.h"
#include "sysinfo.h"

View File

@ -1,7 +1,7 @@
#include "../libcompandor/compandor.h"
#include "../libtimer/timer.h"
#include "../libmobile/sender.h"
#include "../libscrambler/scrambler.h"
#include <libcompandor/compandor.h>
#include <libtimer/timer.h>
#include <libmobile/sender.h>
#include <libscrambler/scrambler.h>
typedef struct cnetz cnetz_t;
#include "fsk_demod.h"
#include "transaction.h"

View File

@ -21,8 +21,8 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include "cnetz.h"
#include "database.h"

View File

@ -25,9 +25,9 @@
#include <string.h>
#include <math.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include "cnetz.h"
#include "sysinfo.h"
#include "telegramm.h"

View File

@ -128,8 +128,8 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include "cnetz.h"
#include "dsp.h"
#include "telegramm.h"

View File

@ -22,14 +22,14 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libmobile/main_mobile.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include "../anetz/freiton.h"
#include "../anetz/besetztton.h"
#include "../liboptions/options.h"
#include "../libfm/fm.h"
#include <liboptions/options.h>
#include <libfm/fm.h>
#include "cnetz.h"
#include "database.h"
#include "sysinfo.h"

View File

@ -26,8 +26,8 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include "cnetz.h"
#include "dsp.h"
#include "sysinfo.h"

View File

@ -20,10 +20,10 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include "cnetz.h"
#include "telegramm.h"
#include "database.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
eurosignal
@ -15,36 +15,36 @@ eurosignal_SOURCES = \
eurosignal_LDADD = \
$(COMMON_LA) \
../anetz/libgermanton.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfsk/libfsk.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfsk/libfsk.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
eurosignal_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
eurosignal_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -25,8 +25,8 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include "eurosignal.h"
#include "dsp.h"

View File

@ -25,11 +25,11 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "eurosignal.h"
#include "dsp.h"

View File

@ -1,6 +1,6 @@
#include "../libfm/fm.h"
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include <libfm/fm.h>
#include <libmobile/sender.h>
#include <libtimer/timer.h>
/* current state of transmitter */
enum euro_health_state {

View File

@ -22,11 +22,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/main_mobile.h>
#include <liboptions/options.h>
#include "eurosignal.h"
#include "dsp.h"
#include "../anetz/besetztton.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
5-ton-folge
@ -11,36 +11,36 @@ bin_PROGRAMS = \
5_ton_folge_LDADD = \
$(COMMON_LA) \
../anetz/libgermanton.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libgoertzel/libgoertzel.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
5_ton_folge_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
5_ton_folge_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -25,9 +25,9 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include "fuenf.h"
#include "dsp.h"

View File

@ -25,12 +25,12 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include "../liboptions/options.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include <liboptions/options.h>
#include "fuenf.h"
#include "dsp.h"

View File

@ -1,6 +1,6 @@
#include "../libmobile/sender.h"
#include "../libgoertzel/goertzel.h"
#include "../libfm/fm.h"
#include <libmobile/sender.h>
#include <libgoertzel/goertzel.h>
#include <libfm/fm.h>
enum fuenf_state {
FUENF_STATE_IDLE = 0,

View File

@ -26,11 +26,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/main_mobile.h>
#include <liboptions/options.h>
#include "../anetz/besetztton.h"
#include "fuenf.h"
#include "dsp.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
if HAVE_ALSA
bin_PROGRAMS = \
@ -14,26 +14,26 @@ fuvst_LDADD = \
$(COMMON_LA) \
../anetz/libgermanton.a \
../cnetz/libcnetztones.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libcompandor/libcompandor.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libscrambler/libscrambler.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libv27/libv27.a \
$(top_builddir)/src/libmtp/libmtp.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libcompandor/libcompandor.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libscrambler/libscrambler.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libv27/libv27.a \
$(top_builddir)/src/lib/libmtp/libmtp.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
$(ALSA_LIBS) \
-lm
@ -41,41 +41,41 @@ fuvst_sniffer_SOURCES = \
sniffer.c
fuvst_sniffer_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libcompandor/libcompandor.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libscrambler/libscrambler.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libv27/libv27.a \
$(top_builddir)/src/libmtp/libmtp.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libcompandor/libcompandor.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libscrambler/libscrambler.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libv27/libv27.a \
$(top_builddir)/src/lib/libmtp/libmtp.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
$(ALSA_LIBS) \
-lm
if HAVE_SDR
fuvst_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
fuvst_sniffer_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -34,13 +34,13 @@
#include <math.h>
#include <time.h>
#include <inttypes.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liboptions/options.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libtimer/timer.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <liboptions/options.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libtimer/timer.h>
#include <libosmocc/message.h>
#include "fuvst.h"
/* digital loopback test */

View File

@ -1,7 +1,7 @@
#include "../libmobile/sender.h"
#include "../libscrambler/scrambler.h"
#include "../libv27/modem.h"
#include "../libmtp/mtp.h"
#include <libmobile/sender.h>
#include <libscrambler/scrambler.h>
#include <libv27/modem.h>
#include <libmtp/mtp.h>
#include "mup.h"
enum fuvst_chan_type {

View File

@ -22,13 +22,13 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../libtimer/timer.h"
#include "../liboptions/options.h"
#include "../libfm/fm.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/main_mobile.h>
#include <libtimer/timer.h>
#include <liboptions/options.h>
#include <libfm/fm.h>
#include "../anetz/freiton.h"
#include "../anetz/besetztton.h"
#include "../cnetz/ansage.h"

View File

@ -23,7 +23,7 @@
#include <string.h>
#include <time.h>
#include <inttypes.h>
#include "../libdebug/debug.h"
#include <libdebug/debug.h>
#include "mup.h"
#include "systemmeldungen.h"

View File

@ -22,16 +22,16 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libtimer/timer.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
#include "../libmobile/sender.h"
#include "../libv27/modem.h"
#include "../libmtp/mtp.h"
#include "../libfm/fm.h"
#include <libsample/sample.h>
#include <libtimer/timer.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include <libmobile/main_mobile.h>
#include <liboptions/options.h>
#include <libmobile/sender.h>
#include <libv27/modem.h>
#include <libmtp/mtp.h>
#include <libfm/fm.h>
typedef struct sniffer {
sender_t sender;

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <inttypes.h>
#include "../libdebug/debug.h"
#include <libdebug/debug.h>
#include "systemmeldungen.h"
static struct systemmeldungen {

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
imts \
@ -12,22 +12,22 @@ imts_SOURCES = \
imts_LDADD = \
$(COMMON_LA) \
../amps/libusatone.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libsquelch/libsquelch.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
imts_dialer_SOURCES = \
@ -35,27 +35,27 @@ imts_dialer_SOURCES = \
imts_dialer_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
-lm
if HAVE_ALSA
imts_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
imts_dialer_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
imts_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -24,13 +24,13 @@
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libwave/wave.h"
#include "../libdebug/debug.h"
#include <libsample/sample.h>
#include <libwave/wave.h>
#include <libdebug/debug.h>
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#include <libsound/sound.h>
#endif
#include "../liboptions/options.h"
#include <liboptions/options.h>
/* presets */
const char *station_id = "6681739";

View File

@ -25,10 +25,10 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include "imts.h"
#include "dsp.h"

View File

@ -38,12 +38,12 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "imts.h"
#include "dsp.h"

View File

@ -1,6 +1,6 @@
#include "../libsquelch/squelch.h"
#include "../libfm/fm.h"
#include "../libmobile/sender.h"
#include <libsquelch/squelch.h>
#include <libfm/fm.h>
#include <libmobile/sender.h>
enum dsp_mode {
DSP_MODE_OFF = 0, /* transmitter off */

View File

@ -23,12 +23,12 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include "../liboptions/options.h"
#include <libsample/sample.h>
#include <libmobile/main_mobile.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include <liboptions/options.h>
#include "../amps/tones.h"
#include "../amps/outoforder.h"
#include "../amps/noanswer.h"

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../lib
bin_PROGRAMS = \
jollycom
@ -11,36 +11,36 @@ jollycom_SOURCES = \
jollycom_LDADD = \
$(COMMON_LA) \
../anetz/libgermanton.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libdtmf/libdtmf.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libsquelch/libsquelch.a \
$(top_builddir)/src/lib/libdtmf/libdtmf.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
jollycom_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
jollycom_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

View File

@ -26,10 +26,10 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libtimer/timer.h"
#include "../libdebug/debug.h"
#include "../libmobile/call.h"
#include <libsample/sample.h>
#include <libtimer/timer.h>
#include <libdebug/debug.h>
#include <libmobile/call.h>
#include "jolly.h"
#include "dsp.h"
#include "voice.h"

View File

@ -133,12 +133,12 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <libsample/sample.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include <libmobile/call.h>
#include <libmobile/cause.h>
#include <libosmocc/message.h>
#include "jolly.h"
#include "dsp.h"
#include "voice.h"

View File

@ -1,6 +1,6 @@
#include "../libsquelch/squelch.h"
#include "../libmobile/sender.h"
#include "../libdtmf/dtmf_decode.h"
#include <libsquelch/squelch.h>
#include <libmobile/sender.h>
#include <libdtmf/dtmf_decode.h>
enum jolly_state {
STATE_NULL = 0,

View File

@ -27,13 +27,13 @@
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include <libsample/sample.h>
#include <libmobile/main_mobile.h>
#include <libdebug/debug.h>
#include <libtimer/timer.h>
#include "../anetz/freiton.h"
#include "../anetz/besetztton.h"
#include "../liboptions/options.h"
#include <liboptions/options.h>
#include "jolly.h"
#include "dsp.h"
#include "voice.h"

View File

@ -1,8 +1,8 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libsamplerate/samplerate.h"
#include <libsample/sample.h>
#include <libsamplerate/samplerate.h>
#include "voice.h"
static int16_t digit_0[] = {

View File

@ -12,36 +12,36 @@ jtacs_SOURCES = \
jtacs_LDADD = \
$(COMMON_LA) \
../amps/libamps.a \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libmobile/libmobile.a \
$(top_builddir)/src/libosmocc/libosmocc.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libcompandor/libcompandor.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/lib/liboptions/liboptions.a \
$(top_builddir)/src/lib/libdebug/libdebug.a \
$(top_builddir)/src/lib/libmobile/libmobile.a \
$(top_builddir)/src/lib/libosmocc/libosmocc.a \
$(top_builddir)/src/lib/libdisplay/libdisplay.a \
$(top_builddir)/src/lib/libcompandor/libcompandor.a \
$(top_builddir)/src/lib/libgoertzel/libgoertzel.a \
$(top_builddir)/src/lib/libjitter/libjitter.a \
$(top_builddir)/src/lib/libtimer/libtimer.a \
$(top_builddir)/src/lib/libsamplerate/libsamplerate.a \
$(top_builddir)/src/lib/libemphasis/libemphasis.a \
$(top_builddir)/src/lib/libfm/libfm.a \
$(top_builddir)/src/lib/libfilter/libfilter.a \
$(top_builddir)/src/lib/libwave/libwave.a \
$(top_builddir)/src/lib/libsample/libsample.a \
$(top_builddir)/src/lib/libg711/libg711.a \
$(top_builddir)/src/lib/libaaimage/libaaimage.a \
-lm
if HAVE_ALSA
jtacs_LDADD += \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/lib/libsound/libsound.a \
$(ALSA_LIBS)
endif
if HAVE_SDR
jtacs_LDADD += \
$(top_builddir)/src/libsdr/libsdr.a \
$(top_builddir)/src/libam/libam.a \
$(top_builddir)/src/libfft/libfft.a \
$(top_builddir)/src/lib/libsdr/libsdr.a \
$(top_builddir)/src/lib/libam/libam.a \
$(top_builddir)/src/lib/libfft/libfft.a \
$(UHD_LIBS) \
$(SOAPY_LIBS)
endif

1
src/lib Submodule

@ -0,0 +1 @@
Subproject commit 6a0f59412d138f434b97cd7e8dacb59cc61c135d

View File

@ -1,7 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libaaimage.a
libaaimage_a_SOURCES = \
aaimage.c

View File

@ -1,74 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "aaimage.h"
extern const char *aaimage[];
void print_aaimage(void)
{
int i, j;
for (i = 0; aaimage[i]; i++) {
for (j = 0; j < (int)strlen(aaimage[i]); j++) {
if (aaimage[i][j] == '@') {
j++;
switch(aaimage[i][j]) {
case 'k': /* black */
printf("\033[0;30m");
break;
case 'r': /* red */
printf("\033[0;31m");
break;
case 'g': /* green */
printf("\033[0;32m");
break;
case 'y': /* yellow */
printf("\033[0;33m");
break;
case 'b': /* blue */
printf("\033[0;34m");
break;
case 'm': /* magenta */
printf("\033[0;35m");
break;
case 'c': /* cyan */
printf("\033[0;36m");
break;
case 'w': /* white */
printf("\033[0;37m");
break;
case 'K': /* bright black */
printf("This will not work on some terminals, please use 'w'\n");
abort();
case 'R': /* bright red */
printf("\033[1;31m");
break;
case 'G': /* bright green */
printf("\033[1;32m");
break;
case 'Y': /* bright yellow */
printf("\033[1;33m");
break;
case 'B': /* bright blue */
printf("\033[1;34m");
break;
case 'M': /* bright magenta */
printf("\033[1;35m");
break;
case 'C': /* bright cyan */
printf("\033[1;36m");
break;
case 'W': /* bright white */
printf("\033[1;37m");
break;
}
} else
printf("%c", aaimage[i][j]);
}
printf("\n");
}
printf("\033[0;39m");
}

View File

@ -1,3 +0,0 @@
void print_aaimage(void);

View File

@ -1,6 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libam.a
libam_a_SOURCES = \
am.c

View File

@ -1,204 +0,0 @@
/* AM modulation and de-modulation
*
* (C) 2018 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "am.h"
static int has_init = 0;
static int fast_math = 0;
static float *sin_tab = NULL, *cos_tab = NULL;
/* global init */
int am_init(int _fast_math)
{
fast_math = _fast_math;
if (fast_math) {
int i;
sin_tab = calloc(65536+16384, sizeof(*sin_tab));
if (!sin_tab) {
fprintf(stderr, "No mem!\n");
return -ENOMEM;
}
cos_tab = sin_tab + 16384;
/* generate sine and cosine */
for (i = 0; i < 65536+16384; i++)
sin_tab[i] = sin(2.0 * M_PI * (double)i / 65536.0);
}
has_init = 1;
return 0;
}
/* global exit */
void am_exit(void)
{
if (sin_tab) {
free(sin_tab);
sin_tab = cos_tab = NULL;
}
has_init = 0;
}
#define CARRIER_FILTER 30.0
/* Amplitude modulation in SDR:
* Just use the base band (audio signal) as real value, and 0.0 as imaginary
* value. The you have two side bands. Be sure to have a DC level, so you
* have a carrier.
*/
int am_mod_init(am_mod_t *mod, double samplerate, double offset, double gain, double bias)
{
memset(mod, 0, sizeof(*mod));
mod->gain = gain;
mod->bias = bias;
if (fast_math)
mod->rot = 65536.0 * offset / samplerate;
else
mod->rot = 2.0 * M_PI * offset / samplerate;
return 0;
}
void am_mod_exit(am_mod_t __attribute__((unused)) *mod)
{
}
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, uint8_t *power, int num, float *baseband)
{
int s;
double vector;
double rot = mod->rot;
double phase = mod->phase;
double gain = mod->gain;
double bias = mod->bias;
for (s = 0; s < num; s++) {
if (*power++)
vector = *amplitude++ * gain + bias;
else
vector = 0.0;
if (fast_math) {
*baseband++ += cos_tab[(uint16_t)phase] * vector;
*baseband++ += sin_tab[(uint16_t)phase] * vector;
phase += rot;
if (phase < 0.0)
phase += 65536.0;
else if (phase >= 65536.0)
phase -= 65536.0;
} else {
*baseband++ += cos(phase) * vector;
*baseband++ += sin(phase) * vector;
phase += rot;
if (phase < 0.0)
phase += 2.0 * M_PI;
else if (phase >= 2.0 * M_PI)
phase -= 2.0 * M_PI;
}
}
mod->phase = phase;
}
/* init AM demodulator */
int am_demod_init(am_demod_t *demod, double samplerate, double offset, double bandwidth, double gain)
{
memset(demod, 0, sizeof(*demod));
demod->gain = gain;
if (fast_math)
demod->rot = 65536.0 * -offset / samplerate;
else
demod->rot = 2 * M_PI * -offset / samplerate;
/* use fourth order (2 iter) filter, since it is as fast as second order (1 iter) filter */
iir_lowpass_init(&demod->lp[0], bandwidth, samplerate, 2);
iir_lowpass_init(&demod->lp[1], bandwidth, samplerate, 2);
/* filter carrier */
iir_lowpass_init(&demod->lp[2], CARRIER_FILTER, samplerate, 1);
return 0;
}
void am_demod_exit(am_demod_t __attribute__((unused)) *demod)
{
}
/* do amplitude demodulation of baseband and write them to samples */
void am_demodulate_complex(am_demod_t *demod, sample_t *amplitude, int length, float *baseband, sample_t *I, sample_t *Q, sample_t *carrier)
{
int s, ss;
double rot = demod->rot;
double phase = demod->phase;
double gain = demod->gain;
double i, q;
double _sin, _cos;
/* rotate spectrum */
for (s = 0, ss = 0; s < length; s++) {
i = baseband[ss++];
q = baseband[ss++];
phase += rot;
if (fast_math) {
if (phase < 0.0)
phase += 65536.0;
else if (phase >= 65536.0)
phase -= 65536.0;
_sin = sin_tab[(uint16_t)phase];
_cos = cos_tab[(uint16_t)phase];
} else {
if (phase < 0.0)
phase += 2.0 * M_PI;
else if (phase >= 2.0 * M_PI)
phase -= 2.0 * M_PI;
_sin = sin(phase);
_cos = cos(phase);
}
I[s] = i * _cos - q * _sin;
Q[s] = i * _sin + q * _cos;
}
demod->phase = phase;
/* filter bandwidth */
iir_process(&demod->lp[0], I, length);
iir_process(&demod->lp[1], Q, length);
/* demod */
for (s = 0; s < length; s++)
amplitude[s] = carrier[s] = sqrt(I[s] * I[s] + Q[s] * Q[s]);
/* filter carrier */
iir_process(&demod->lp[2], carrier, length);
/* normalize */
for (s = 0; s < length; s++)
amplitude[s] = (amplitude[s] - carrier[s]) / carrier[s] * gain;
}

View File

@ -1,28 +0,0 @@
#include "../libfilter/iir_filter.h"
int am_init(int fast_math);
void am_exit(void);
typedef struct am_mod {
double rot; /* angle to rotate vector per sample */
double phase; /* current phase */
double gain; /* gain to be multiplied to amplitude */
double bias; /* DC offset to add (carrier amplitude) */
} am_mod_t;
int am_mod_init(am_mod_t *mod, double samplerate, double offset, double gain, double bias);
void am_mod_exit(am_mod_t *mod);
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, uint8_t *power, int num, float *baseband);
typedef struct am_demod {
double rot; /* angle to rotate vector per sample */
double phase; /* current rotation phase (used to shift) */
iir_filter_t lp[3]; /* filters received IQ signal/carrier */
double gain; /* gain to be expected from amplitude */
double bias; /* DC offset to be expected (carrier amplitude) */
} am_demod_t;
int am_demod_init(am_demod_t *demod, double samplerate, double offset, double gain, double bias);
void am_demod_exit(am_demod_t *demod);
void am_demodulate_complex(am_demod_t *demod, sample_t *amplitude, int length, float *baseband, sample_t *I, sample_t *Q, sample_t *carrier);

View File

@ -1,6 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libclipper.a
libclipper_a_SOURCES = \
clipper.c

View File

@ -1,81 +0,0 @@
/* Clipper implementation, based on code by Jonathan Olds
*
* (C) 2017 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "clipper.h"
static double clipper_lut[6000];
static double clipper_point = NAN;
void clipper_init(double point)
{
double a;
int i;
if (point > 0.99)
point = 0.99;
if (point < 0.01)
point = 0.01;
clipper_point = point;
a = M_PI / (2.0 * (1.0 - clipper_point));
for (i = 0; i < 6000; i++)
clipper_lut[i] = clipper_point + atan(a * i / 1000.0) / a;
}
void clipper_process(sample_t *samples, int length)
{
int i;
double val, inv, shiftmultval;
int n, q;
if (isnan(clipper_point)) {
fprintf(stderr, "Clipper not initialized, aborting!\n");
abort();
}
for (i = 0; i < length; i++) {
val = samples[i];
if (val < 0) {
inv = -1.0;
val = -val;
} else
inv = 1.0;
shiftmultval = (val - clipper_point) * 1000.0;
/* no clipping up to clipping point */
if (shiftmultval <= 0.0)
continue;
n = (int)shiftmultval;
q = n + 1;
if (q >= 6000) {
samples[i] = inv;
continue;
}
/* get clipped value from lut, interpolate between table entries */
val = clipper_lut[n] + (shiftmultval - (double)n) * (clipper_lut[q] - clipper_lut[n]);
samples[i] = val * inv;
}
}

View File

@ -1,4 +0,0 @@
void clipper_init(double point);
void clipper_process(sample_t *samples, int length);

View File

@ -1,6 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libcompandor.a
libcompandor_a_SOURCES = \
compandor.c

View File

@ -1,141 +0,0 @@
/* Compandor to use various networks like C-Netz / NMT / AMPS / TACS
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "compandor.h"
//#define db2level(db) pow(10, (double)db / 20.0)
/* factor is the gain (raise and fall) after given attack/recovery time */
#define COMPRESS_ATTACK_FACTOR 1.83 /* about 1.5 after 12 dB step up */
#define COMPRESS_RECOVERY_FACTOR 0.44 /* about 0.75 after 12 dB step down */
#define EXPAND_ATTACK_FACTOR 1.145 /* about 0.57 after 6 dB step up */
#define EXPAND_RECOVERY_FACTOR 0.753 /* about 1.51 after 6 dB step down */
/* Minimum level value to keep state (-60 dB) */
#define ENVELOPE_MIN 0.001
/* Maximum level, to prevent sqrt_tab to overflow */
#define ENVELOPE_MAX 9.990
static double sqrt_tab[10000];
/*
* Init compandor according to ITU-T G.162 specification
*
* Hopefully this is correct
*
*/
void init_compandor(compandor_t *state, double samplerate, double attack_ms, double recovery_ms)
{
int i;
memset(state, 0, sizeof(*state));
state->c.peak = 1.0;
state->c.envelope = 1.0;
state->e.peak = 1.0;
state->e.envelope = 1.0;
state->c.step_up = pow(COMPRESS_ATTACK_FACTOR, 1000.0 / attack_ms / samplerate);
state->c.step_down = pow(COMPRESS_RECOVERY_FACTOR, 1000.0 / recovery_ms / samplerate);
state->e.step_up = pow(EXPAND_ATTACK_FACTOR, 1000.0 / attack_ms / samplerate);
state->e.step_down = pow(EXPAND_RECOVERY_FACTOR, 1000.0 / recovery_ms / samplerate);
// FIXME: make global, not at instance
for (i = 0; i < 10000; i++)
sqrt_tab[i] = sqrt(i * 0.001);
}
void compress_audio(compandor_t *state, sample_t *samples, int num)
{
double value, peak, envelope, step_up, step_down;
int i;
step_up = state->c.step_up;
step_down = state->c.step_down;
peak = state->c.peak;
envelope = state->c.envelope;
// printf("envelope=%.4f\n", envelope);
for (i = 0; i < num; i++) {
value = *samples;
/* 'peak' is the level that raises directly with the signal
* level, but falls with specified recovery rate. */
if (fabs(value) > peak)
peak = fabs(value);
else
peak *= step_down;
/* 'evelope' is the level that raises with the specified attack
* rate to 'peak', but falls with specified recovery rate. */
if (peak > envelope)
envelope *= step_up;
else
envelope = peak;
if (envelope < ENVELOPE_MIN)
envelope = ENVELOPE_MIN;
if (envelope > ENVELOPE_MAX)
envelope = ENVELOPE_MAX;
*samples++ = value / sqrt_tab[(int)(envelope / 0.001)];
//if (i > 47000.0 && i < 48144)
//printf("time=%.4f envelope=%.4fdb, value=%.4f\n", (double)i/48000.0, 20*log10(envelope), value);
}
//exit(0);
state->c.envelope = envelope;
state->c.peak = peak;
}
void expand_audio(compandor_t *state, sample_t *samples, int num)
{
double value, peak, envelope, step_up, step_down;
int i;
step_up = state->e.step_up;
step_down = state->e.step_down;
peak = state->e.peak;
envelope = state->e.envelope;
for (i = 0; i < num; i++) {
value = *samples;
/* for comments: see compress_audio() */
if (fabs(value) > peak)
peak = fabs(value);
else
peak *= step_down;
if (peak > envelope)
envelope *= step_up;
else
envelope = peak;
if (envelope < ENVELOPE_MIN)
envelope = ENVELOPE_MIN;
*samples++ = value * envelope;
}
state->e.envelope = envelope;
state->e.peak = peak;
}

View File

@ -1,20 +0,0 @@
typedef struct compandor {
struct {
double step_up;
double step_down;
double peak;
double envelope;
} c;
struct {
double step_up;
double step_down;
double peak;
double envelope;
} e;
} compandor_t;
void init_compandor(compandor_t *state, double samplerate, double attack_ms, double recovery_ms);
void compress_audio(compandor_t *state, sample_t *samples, int num);
void expand_audio(compandor_t *state, sample_t *samples, int num);

View File

@ -1,7 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libdebug.a
libdebug_a_SOURCES = \
debug.c

View File

@ -1,325 +0,0 @@
/* Simple debug functions for level and category filtering
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <math.h>
#include <time.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include "debug.h"
const char *debug_level[] = {
"debug ",
"info ",
"notice ",
"error ",
NULL,
};
struct debug_cat {
const char *name;
const char *color;
} debug_cat[] = {
{ "options", "\033[0;33m" },
{ "sender", "\033[1;33m" },
{ "sound", "\033[0;35m" },
{ "dsp", "\033[0;31m" },
{ "anetz", "\033[1;34m" },
{ "bnetz", "\033[1;34m" },
{ "cnetz", "\033[1;34m" },
{ "nmt", "\033[1;34m" },
{ "amps", "\033[1;34m" },
{ "r2000", "\033[1;34m" },
{ "imts", "\033[1;34m" },
{ "mpt1327", "\033[1;34m" },
{ "jollycom", "\033[1;34m" },
{ "eurosignal", "\033[1;34m" },
{ "pocsag", "\033[1;34m" },
{ "5-ton-folge", "\033[1;34m" },
{ "frame", "\033[0;36m" },
{ "call", "\033[0;37m" },
{ "cc", "\033[1;32m" },
{ "database", "\033[0;33m" },
{ "transaction", "\033[0;32m" },
{ "dms", "\033[0;33m" },
{ "sms", "\033[1;37m" },
{ "sdr", "\033[1;31m" },
{ "uhd", "\033[1;35m" },
{ "soapy", "\033[1;35m" },
{ "wave", "\033[1;33m" },
{ "radio", "\033[1;34m" },
{ "am791x", "\033[0;31m" },
{ "uart", "\033[0;32m" },
{ "device", "\033[0;33m" },
{ "datenklo", "\033[1;34m" },
{ "zeit", "\033[1;34m" },
{ "sim layer 1", "\033[0;31m" },
{ "sim layer 2", "\033[0;33m" },
{ "sim ICL layer", "\033[0;36m" },
{ "sim layer 7", "\033[0;37m" },
{ "mtp layer 2", "\033[1;33m" },
{ "mtp layer 3", "\033[1;36m" },
{ "MuP", "\033[1;37m" },
{ "router", "\033[1;35m" },
{ "stderr", "\033[1;37m" },
{ "ss5", "\033[1;34m" },
{ "isdn", "\033[1;35m" },
{ "misdn", "\033[0;34m" },
{ "dss1", "\033[1;34m" },
{ "sip", "\033[1;35m" },
{ "telephone", "\033[1;34m" },
{ NULL, NULL }
};
int debuglevel = DEBUG_INFO;
int debug_date = 0;
uint64_t debug_mask = ~0;
extern int num_kanal;
void (*clear_console_text)(void) = NULL;
void (*print_console_text)(void) = NULL;
int debug_limit_scroll = 0;
static int lock_initialized = 0;
static pthread_mutex_t debug_mutex;
void lock_debug(void)
{
int rc;
if (!lock_initialized) {
rc = pthread_mutex_init(&debug_mutex, NULL);
if (rc == 0)
lock_initialized = 1;
}
if (lock_initialized)
pthread_mutex_lock(&debug_mutex);
}
void unlock_debug(void)
{
if (lock_initialized)
pthread_mutex_unlock(&debug_mutex);
}
void get_win_size(int *w, int *h)
{
struct winsize win;
int rc;
rc = ioctl(0, TIOCGWINSZ, &win);
if (rc) {
*w = 80;
*h = 25;
return;
}
*h = win.ws_row;
*w = win.ws_col;
}
void _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, const char *kanal, const char *fmt, ...)
{
char buffer[4096], *b = buffer;
int s = sizeof(buffer) - 1;
const char *p;
va_list args;
int w, h;
if (debuglevel > level)
return;
if (!(debug_mask & ((uint64_t)1 << cat)))
return;
lock_debug();
buffer[sizeof(buffer) - 1] = '\0';
/* if kanal is used, prefix the channel number */
if (num_kanal > 1 && kanal) {
sprintf(buffer, "(chan %s) ", kanal);
b = strchr(buffer, '\0');
s -= strlen(buffer);
}
va_start(args, fmt);
vsnprintf(b, s, fmt, args);
va_end(args);
while ((p = strchr(file, '/')))
file = p + 1;
if (clear_console_text)
clear_console_text();
if (debug_limit_scroll) {
get_win_size(&w, &h);
printf("\0337\033[%d;%dr\0338", debug_limit_scroll + 1, h);
}
if (debug_date) {
struct timeval tv;
struct tm *tm;
gettimeofday(&tv, NULL);
tm = localtime(&tv.tv_sec);
printf("%04d-%02d-%02d %02d:%02d:%02d.%03d ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 10000.0));
}
printf("%s%s:%4d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
if (debug_limit_scroll)
printf("\0337\033[%d;%dr\0338", 1, h);
if (print_console_text)
print_console_text();
fflush(stdout);
unlock_debug();
}
const char *debug_amplitude(double level)
{
static char text[42];
strcpy(text, " : ");
if (level > 1.0)
level = 1.0;
if (level < -1.0)
level = -1.0;
text[20 + (int)(level * 20)] = '*';
return text;
}
#define level2db(level) (20 * log10(level))
const char *debug_db(double level_db)
{
static char text[128];
int l;
strcpy(text, ": . : . : . : . : . : . : . : . | . : . : . : . : . : . : . : . :");
if (level_db <= 0.0)
return text;
l = (int)round(level2db(level_db));
if (l > 48)
return text;
if (l < -48)
return text;
text[l + 48] = '*';
return text;
}
void debug_print_help(void)
{
printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n");
printf(" Use 'list' to get a list of all levels and categories\n");
printf(" Verbose level: digit of debug level (default = '%d')\n", debuglevel);
printf(" Verbose level+category: level digit followed by one or more categories\n");
printf(" -> If no category is specified, all categories are selected\n");
printf(" -v --verbose date\n");
printf(" Show date with debug output\n");
}
void debug_list_cat(void)
{
int i;
printf("Give number of debug level:\n");
for (i = 0; debug_level[i]; i++)
printf(" %d = %s\n", i, debug_level[i]);
printf("\n");
printf("Give name(s) of debug category:\n");
for (i = 0; debug_cat[i].name; i++)
printf(" %s%s\033[0;39m\n", debug_cat[i].color, debug_cat[i].name);
printf("\n");
}
int parse_debug_opt(const char *optarg)
{
int i, max_level = 0;
char *dup, *dstring, *p;
if (!strcasecmp(optarg, "date")) {
debug_date = 1;
return 0;
}
for (i = 0; debug_level[i]; i++)
max_level = i;
dup = dstring = strdup(optarg);
p = strsep(&dstring, ",");
for (i = 0; i < p[i]; i++) {
if (p[i] < '0' || p[i] > '9') {
fprintf(stderr, "Only digits are allowed for debug level!\n");
free(dup);
return -EINVAL;
}
}
debuglevel = atoi(p);
if (debuglevel > max_level) {
fprintf(stderr, "Debug level too high, use 'list' to show available levels!\n");
free(dup);
return -EINVAL;
}
if (dstring)
debug_mask = 0;
while((p = strsep(&dstring, ","))) {
for (i = 0; debug_cat[i].name; i++) {
if (!strcasecmp(p, debug_cat[i].name))
break;
}
if (!debug_cat[i].name) {
fprintf(stderr, "Given debug category '%s' unknown, use 'list' to show available categories!\n", p);
free(dup);
return -EINVAL;
}
debug_mask |= ((uint64_t)1 << i);
}
free(dup);
return 0;
}
const char *debug_hex(const uint8_t *data, int len)
{
static char *text = NULL;
char *p;
int i;
if (text)
free(text);
p = text = calloc(1, len * 3 + 1);
for (i = 0; i < len; i++) {
sprintf(p, "%02x ", *data++);
p += 3;
}
if (text[0])
p[-1] = '\0';
return text;
}

View File

@ -1,80 +0,0 @@
#define DEBUG_DEBUG 0 /* debug info, not for normal use */
#define DEBUG_INFO 1 /* all info about process */
#define DEBUG_NOTICE 2 /* something unexpected happens */
#define DEBUG_ERROR 3 /* there is an error with this software */
#define DOPTIONS 0
#define DSENDER 1
#define DSOUND 2
#define DDSP 3
#define DANETZ 4
#define DBNETZ 5
#define DCNETZ 6
#define DNMT 7
#define DAMPS 8
#define DR2000 9
#define DIMTS 10
#define DMPT1327 11
#define DJOLLY 12
#define DEURO 13
#define DPOCSAG 14
#define DFUENF 15
#define DFRAME 16
#define DCALL 17
#define DCC 18
#define DDB 19
#define DTRANS 20
#define DDMS 21
#define DSMS 22
#define DSDR 23
#define DUHD 24
#define DSOAPY 25
#define DWAVE 26
#define DRADIO 27
#define DAM791X 28
#define DUART 29
#define DDEVICE 30
#define DDATENKLO 31
#define DZEIT 32
#define DSIM1 33
#define DSIM2 34
#define DSIMI 35
#define DSIM7 36
#define DMTP2 37
#define DMTP3 38
#define DMUP 39
#define DROUTER 40
#define DSTDERR 41
#define DSS5 42
#define DISDN 43
#define DMISDN 44
#define DDSS1 45
#define DSIP 46
#define DTEL 47
void lock_debug(void);
void unlock_debug(void);
void get_win_size(int *w, int *h);
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, NULL, fmt, ## arg)
#define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg)
void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *chan_str, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8)));
const char *debug_amplitude(double level);
const char *debug_db(double level_db);
void debug_print_help(void);
void debug_list_cat(void);
int parse_debug_opt(const char *opt);
extern int debuglevel;
extern void (*clear_console_text)(void);
extern void (*print_console_text)(void);
extern int debug_limit_scroll;
const char *debug_hex(const uint8_t *data, int len);

View File

@ -1,19 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libdisplay.a
libdisplay_a_SOURCES = \
display_status.c \
display_wave.c \
display_measurements.c
if HAVE_SDR
libdisplay_a_SOURCES += \
display_iq.c \
display_spectrum.c
endif
if HAVE_SDR
AM_CPPFLAGS += -DHAVE_SDR
endif

View File

@ -1,103 +0,0 @@
#define DISPLAY_MEAS_INTERVAL 0.1 /* time (in seconds) for each measurement values interval */
#define DISPLAY_INTERVAL 0.04 /* time (in seconds) for each other interval */
#define DISPLAY_PARAM_HISTORIES 10 /* number of intervals (should result in one seconds) */
#define MAX_DISPLAY_WIDTH 1024
typedef struct display_wave {
const char *kanal;
int interval_pos;
int interval_max;
int offset;
sample_t buffer[MAX_DISPLAY_WIDTH];
} dispwav_t;
enum display_measurements_type {
DISPLAY_MEAS_LAST, /* display last value */
DISPLAY_MEAS_PEAK, /* display peak value */
DISPLAY_MEAS_PEAK2PEAK, /* display peak value of min..max range */
DISPLAY_MEAS_AVG, /* display average value */
};
enum display_measurements_bar {
DISPLAY_MEAS_LEFT, /* bar graph from left */
DISPLAY_MEAS_CENTER, /* bar graph from center */
};
typedef struct display_measurements_param {
struct display_measurements_param *next;
char name[32]; /* parameter name (e.g. 'Deviation') */
char format[32]; /* unit name (e.g. "%.2f KHz") */
enum display_measurements_type type;
enum display_measurements_bar bar;
double min; /* minimum value */
double max; /* maximum value */
double mark; /* mark (target) value */
double value; /* current value (peak, sum...) */
double value2; /* max value for min..max range */
double last; /* last valid value (used for DISPLAY_MEAS_LAST) */
int value_count; /* count number of values of one interval */
double value_history[DISPLAY_PARAM_HISTORIES]; /* history of values of last second */
double value2_history[DISPLAY_PARAM_HISTORIES]; /* stores max for min..max range */
int value_history_pos; /* next history value to write */
} dispmeasparam_t;
typedef struct display_measurements {
struct display_measurements *next;
const char *kanal;
dispmeasparam_t *param;
} dispmeas_t;
#define MAX_DISPLAY_IQ 1024
typedef struct display_iq {
int interval_pos;
int interval_max;
float buffer[MAX_DISPLAY_IQ * 2];
} dispiq_t;
#define MAX_DISPLAY_SPECTRUM 1024
typedef struct display_spectrum_mark {
struct display_spectrum_mark *next;
const char *kanal;
double frequency;
} dispspectrum_mark_t;
typedef struct display_spectrum {
int interval_pos;
int interval_max;
double buffer_I[MAX_DISPLAY_SPECTRUM];
double buffer_Q[MAX_DISPLAY_SPECTRUM];
dispspectrum_mark_t *mark;
} dispspectrum_t;
#define MAX_HEIGHT_STATUS 32
void display_wave_init(dispwav_t *disp, int samplerate, const char *kanal);
void display_wave_on(int on);
void display_wave(dispwav_t *disp, sample_t *samples, int length, double range);
void display_status_on(int on);
void display_status_start(void);
void display_status_channel(const char *kanal, const char *type, const char *state);
void display_status_subscriber(const char *number, const char *state);
void display_status_end(void);
void display_measurements_init(dispmeas_t *disp, int samplerate, const char *kanal);
void display_measurements_exit(dispmeas_t *disp);
void display_measurements_on(int on);
dispmeasparam_t *display_measurements_add(dispmeas_t *disp, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark);
void display_measurements_update(dispmeasparam_t *param, double value, double value2);
void display_measurements(double elapsed);
void display_iq_init(int samplerate);
void display_iq_on(int on);
void display_iq(float *samples, int length);
void display_spectrum_init(int samplerate, double center_frequency);
void display_spectrum_add_mark(const char *kanal, double frequency);
void display_spectrum_exit(void);
void display_spectrum_on(int on);
void display_spectrum(float *samples, int length);

View File

@ -1,282 +0,0 @@
/* display IQ data form functions
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <pthread.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libdisplay/display.h"
/* must be odd value! */
#define SIZE 23
static char screen[SIZE][MAX_DISPLAY_WIDTH];
static uint8_t screen_color[SIZE][MAX_DISPLAY_WIDTH];
static uint8_t screen_history[SIZE * 2][MAX_DISPLAY_WIDTH];
static int iq_on = 0;
static double db = 80;
static dispiq_t disp;
void display_iq_init(int samplerate)
{
memset(&disp, 0, sizeof(disp));
memset(&screen_history, 0, sizeof(screen_history));
disp.interval_max = (double)samplerate * DISPLAY_INTERVAL + 0.5;
/* should not happen due to low interval */
if (disp.interval_max < MAX_DISPLAY_IQ - 1)
disp.interval_max = MAX_DISPLAY_IQ - 1;
}
void display_iq_on(int on)
{
int j;
int w, h;
get_win_size(&w, &h);
if (w > MAX_DISPLAY_WIDTH - 1)
w = MAX_DISPLAY_WIDTH - 1;
if (iq_on) {
memset(&screen, ' ', sizeof(screen));
memset(&screen_history, 0, sizeof(screen_history));
lock_debug();
printf("\0337\033[H");
for (j = 0; j < SIZE; j++) {
screen[j][w] = '\0';
puts(screen[j]);
}
printf("\0338"); fflush(stdout);
unlock_debug();
}
if (on < 0) {
if (++iq_on == 3)
iq_on = 0;
} else
iq_on = on;
if (iq_on)
debug_limit_scroll = SIZE;
else
debug_limit_scroll = 0;
}
/*
* plot IQ data:
*
* theoretical example: SIZE = 3 allows 6 steps plotted as dots
*
* Line 0: :
* Line 1: :
* Line 2: :
*
* The level of -1.0 .. 1.0 is scaled to -3 and 3.
*
* The lowest of the upper 3 dots ranges from 0.0 .. <1.5.
* The upper most dot ranges from 2.5 .. <3.5.
* The highest of the lower 3 dots ranges from <0.0 .. >-1.5;
* The lower most dot ranges from -2.5 .. >-3.5.
*
* The center column ranges from -0.5 .. <0.5.
* The columns about the center from -1.5 .. <1.5.
*/
void display_iq(float *samples, int length)
{
int pos, max;
float *buffer;
int i, j, k;
int color = 9; /* default color */
int x_center, y_center;
double I, Q, L, l, s;
int x, y;
int v, r;
int width, h;
if (!iq_on)
return;
lock_debug();
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
/* at what line we draw our zero-line and what character we use */
x_center = width >> 1;
y_center = (SIZE - 1) >> 1;
pos = disp.interval_pos;
max = disp.interval_max;
buffer = disp.buffer;
for (i = 0; i < length; i++) {
if (pos >= MAX_DISPLAY_IQ) {
if (++pos == max)
pos = 0;
continue;
}
buffer[pos * 2] = samples[i * 2];
buffer[pos * 2 + 1] = samples[i * 2 + 1];
pos++;
if (pos == MAX_DISPLAY_IQ) {
memset(&screen, ' ', sizeof(screen));
memset(&screen_color, 7, sizeof(screen_color));
/* render screen history to screen */
for (y = 0; y < SIZE * 2; y++) {
for (x = 0; x < width; x++) {
v = screen_history[y][x];
v -= 8;
if (v < 0)
v = 0;
screen_history[y][x] = v;
r = random() & 0x3f;
if (r >= v)
continue;
if (screen[y/2][x] == ':')
continue;
if (screen[y/2][x] == '.') {
if ((y & 1) == 0)
screen[y/2][x] = ':';
continue;
}
if (screen[y/2][x] == '\'') {
if ((y & 1))
screen[y/2][x] = ':';
continue;
}
if ((y & 1) == 0)
screen[y/2][x] = '\'';
else
screen[y/2][x] = '.';
screen_color[y/2][x] = 4;
}
}
/* plot current IQ date */
for (j = 0; j < MAX_DISPLAY_IQ; j++) {
I = buffer[j * 2];
Q = buffer[j * 2 + 1];
L = I*I + Q*Q;
if (iq_on > 1) {
/* logarithmic scale */
l = sqrt(L);
s = log10(l) * 20 + db;
if (s < 0)
s = 0;
I = (I / l) * (s / db);
Q = (Q / l) * (s / db);
}
x = x_center + (int)(I * (double)SIZE + (double)width + 0.5) - width;
if (x < 0)
continue;
if (x > width - 1)
continue;
if (Q >= 0)
y = SIZE - 1 - (int)(Q * (double)SIZE - 0.5);
else
y = SIZE - (int)(Q * (double)SIZE + 0.5);
if (y < 0)
continue;
if (y > SIZE * 2 - 1)
continue;
if (screen[y/2][x] == ':' && screen_color[y/2][x] >= 10)
goto cont;
if (screen[y/2][x] == '.' && screen_color[y/2][x] >= 10) {
if ((y & 1) == 0)
screen[y/2][x] = ':';
goto cont;
}
if (screen[y/2][x] == '\'' && screen_color[y/2][x] >= 10) {
if ((y & 1))
screen[y/2][x] = ':';
goto cont;
}
if ((y & 1) == 0)
screen[y/2][x] = '\'';
else
screen[y/2][x] = '.';
cont:
screen_history[y][x] = 255;
/* overdrive:
* red = close to -1..1 or above
* yellow = close to -0.5..0.5 or above
* Note: L is square of vector length,
* so we compare with square values.
*/
if (L > 0.9 * 0.9)
screen_color[y/2][x] = 11;
else if (L > 0.45 * 0.45 && screen_color[y/2][x] != 11)
screen_color[y/2][x] = 13;
else if (screen_color[y/2][x] < 10)
screen_color[y/2][x] = 12;
}
if (iq_on == 1)
sprintf(screen[0], "(IQ linear");
else
sprintf(screen[0], "(IQ log %.0f dB", db);
*strchr(screen[0], '\0') = ')';
printf("\0337\033[H");
for (j = 0; j < SIZE; j++) {
for (k = 0; k < width; k++) {
if ((j == y_center || k == x_center) && screen[j][k] == ' ') {
/* cross */
if (color != 4) {
color = 4;
printf("\033[0;34m");
}
if (j == y_center) {
if (k == x_center)
putchar('o');
else if (k == x_center - SIZE)
putchar('+');
else if (k == x_center + SIZE)
putchar('+');
else
putchar('-');
} else {
if (j == 0 || j == SIZE - 1)
putchar('+');
else
putchar('|');
}
} else {
if (screen_color[j][k] != color) {
color = screen_color[j][k];
printf("\033[%d;3%dm", color / 10, color % 10);
}
putchar(screen[j][k]);
}
}
printf("\n");
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
}
}
disp.interval_pos = pos;
unlock_debug();
}

View File

@ -1,360 +0,0 @@
/* display measurements functions
*
* (C) 2017 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libdisplay/display.h"
#define MAX_NAME_LEN 16
#define MAX_UNIT_LEN 16
static int has_init = 0;
static int measurements_on = 0;
double time_elapsed = 0.0;
static int lines_total = 0;
static char line[MAX_DISPLAY_WIDTH];
static char line_color[MAX_DISPLAY_WIDTH];
dispmeas_t *meas_head = NULL;
void display_measurements_init(dispmeas_t *disp, int __attribute__((unused)) samplerate, const char *kanal)
{
dispmeas_t **disp_p;
memset(disp, 0, sizeof(*disp));
disp->kanal = kanal;
has_init = 1;
lines_total = 0;
time_elapsed = 0.0;
disp_p = &meas_head;
while (*disp_p)
disp_p = &((*disp_p)->next);
*disp_p = disp;
}
void display_measurements_exit(dispmeas_t *disp)
{
dispmeasparam_t *param = disp->param, *temp;
while (param) {
temp = param;
param = param->next;
free(temp);
}
disp->param = NULL;
has_init = 0;
}
static int color;
static void display_line(int on, int w)
{
int j;
if (on) {
for (j = 0; j < w; j++) {
if (line_color[j] != color && line[j] != ' ') {
color = line_color[j];
printf("\033[%d;3%dm", color / 10, color % 10);
}
putchar(line[j]);
}
} else {
for (j = 0; j < w; j++)
putchar(' ');
}
putchar('\n');
lines_total++;
}
static void print_measurements(int on)
{
dispmeas_t *disp;
dispmeasparam_t *param;
int i, j;
int width, h;
char text[128];
double value = 0.0, value2 = 0.0, hold, hold2;
int bar_width, bar_left, bar_right, bar_hold, bar_mark;
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
/* no display, if bar graph is less than one character */
bar_width = width - MAX_NAME_LEN - MAX_UNIT_LEN;
if (bar_width < 1)
return;
lock_debug();
lines_total = 0;
color = -1;
printf("\0337\033[H");
for (disp = meas_head; disp; disp = disp->next) {
memset(line, ' ', width);
memset(line_color, 7, width);
sprintf(line, "(chan %s", disp->kanal);
*strchr(line, '\0') = ')';
display_line(on, width);
for (param = disp->param; param; param = param->next) {
memset(line, ' ', width);
memset(line_color, 7, width);
memset(line_color, 3, MAX_NAME_LEN); /* yellow */
switch (param->type) {
case DISPLAY_MEAS_LAST:
value = param->value;
param->value = -NAN;
break;
case DISPLAY_MEAS_PEAK:
/* peak value */
value = param->value;
param->value = -NAN;
param->value_count = 0;
break;
case DISPLAY_MEAS_PEAK2PEAK:
/* peak to peak value */
value = param->value;
value2 = param->value2;
param->value = -NAN;
param->value2 = -NAN;
param->value_count = 0;
break;
case DISPLAY_MEAS_AVG:
/* average value */
if (param->value_count)
value = param->value / (double)param->value_count;
else
value = -NAN;
param->value = 0.0;
param->value_count = 0;
break;
}
/* add current value to history */
param->value_history[param->value_history_pos] = value;
param->value2_history[param->value_history_pos] = value2;
param->value_history_pos = param->value_history_pos % DISPLAY_PARAM_HISTORIES;
/* calculate hold values */
hold = -NAN;
hold2 = -NAN;
switch (param->type) {
case DISPLAY_MEAS_LAST:
/* if we have valid value, we update 'last' */
if (!isnan(value)) {
param->last = value;
hold = value;
} else
hold = param->last;
break;
case DISPLAY_MEAS_PEAK:
for (i = 0; i < DISPLAY_PARAM_HISTORIES; i++) {
if (isnan(param->value_history[i]))
continue;
if (isnan(hold) || param->value_history[i] > hold)
hold = param->value_history[i];
}
break;
case DISPLAY_MEAS_PEAK2PEAK:
for (i = 0; i < DISPLAY_PARAM_HISTORIES; i++) {
if (isnan(param->value_history[i]))
continue;
if (isnan(hold) || param->value_history[i] < hold)
hold = param->value_history[i];
if (isnan(hold2) || param->value2_history[i] > hold2)
hold2 = param->value2_history[i];
}
if (!isnan(hold))
hold = hold2 - hold;
if (!isnan(value))
value = value2 - value;
break;
case DISPLAY_MEAS_AVG:
for (i = 0, j = 0; i < DISPLAY_PARAM_HISTORIES; i++) {
if (isnan(param->value_history[i]))
continue;
if (j == 0)
hold = 0.0;
hold += param->value_history[i];
j++;
}
if (j)
hold /= j;
break;
}
/* "Deviation ::::::::::............ 4.5 KHz" */
memcpy(line, param->name, (strlen(param->name) < MAX_NAME_LEN) ? strlen(param->name) : MAX_NAME_LEN);
if (isinf(value) || isnan(value)) {
bar_left = -1;
bar_right = -1;
} else if (param->bar == DISPLAY_MEAS_CENTER) {
if (value >= 0.0) {
bar_left = (-param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
bar_right = (value - param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
} else {
bar_left = (value - param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
bar_right = (-param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
}
} else {
bar_left = -1;
bar_right = (value - param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
}
if (isinf(hold) || isnan(hold))
bar_hold = -1;
else
bar_hold = (hold - param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
if (isinf(param->mark))
bar_mark = -1;
else
bar_mark = (param->mark - param->min) / (param->max - param->min) * ((double)bar_width - 1.0);
for (i = 0; i < bar_width; i++) {
line[i + MAX_NAME_LEN] = ':';
if (i == bar_hold)
line_color[i + MAX_NAME_LEN] = 13;
else if (i == bar_mark)
line_color[i + MAX_NAME_LEN] = 14;
else if (i >= bar_left && i <= bar_right)
line_color[i + MAX_NAME_LEN] = 2;
else
line_color[i + MAX_NAME_LEN] = 4;
}
sprintf(text, param->format, hold);
if (isnan(hold))
memset(line_color + width - MAX_UNIT_LEN, 4, MAX_UNIT_LEN); /* blue */
else
memset(line_color + width - MAX_UNIT_LEN, 3, MAX_UNIT_LEN); /* yellow */
strncpy(line + width - MAX_UNIT_LEN + 1, text, (strlen(text) < MAX_UNIT_LEN) ? strlen(text) : MAX_UNIT_LEN);
display_line(on, width);
}
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
debug_limit_scroll = lines_total;
unlock_debug();
}
void display_measurements_on(int on)
{
if (measurements_on)
print_measurements(0);
if (on < 0)
measurements_on = 1 - measurements_on;
else
measurements_on = on;
debug_limit_scroll = 0;
}
/* add new parameter on startup to the list of measurements */
dispmeasparam_t *display_measurements_add(dispmeas_t *disp, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark)
{
dispmeasparam_t *param, **param_p = &disp->param;
int i;
if (!has_init) {
fprintf(stderr, "Not initialized prior adding measurement, please fix!\n");
abort();
}
while (*param_p)
param_p = &((*param_p)->next);
*param_p = calloc(sizeof(dispmeasparam_t), 1);
if (!*param_p)
return NULL;
param = *param_p;
strncpy(param->name, name, sizeof(param->name) - 1);
strncpy(param->format, format, sizeof(param->format) - 1);
param->type = type;
param->bar = bar;
param->min = min;
param->max = max;
param->mark = mark;
param->value = -NAN;
param->value2 = -NAN;
param->last = -NAN;
for (i = 0; i < DISPLAY_PARAM_HISTORIES; i++)
param->value_history[i] = -NAN;
param->value_count = 0;
return param;
}
void display_measurements_update(dispmeasparam_t *param, double value, double value2)
{
/* special case where we do not have an instance of the parameter */
if (!param)
return;
if (!has_init) {
fprintf(stderr, "Not initialized prior updating measurement value, please fix!\n");
abort();
}
switch (param->type) {
case DISPLAY_MEAS_LAST:
param->value = value;
break;
case DISPLAY_MEAS_PEAK:
if (isnan(param->value) || value > param->value)
param->value = value;
break;
case DISPLAY_MEAS_PEAK2PEAK:
if (param->value_count == 0 || value < param->value)
param->value = value;
if (param->value_count == 0 || value2 > param->value2)
param->value2 = value2;
param->value_count++;
break;
case DISPLAY_MEAS_AVG:
param->value += value;
param->value_count++;
break;
default:
fprintf(stderr, "Parameter '%s' has unknown type %d, please fix!\n", param->name, param->type);
abort();
}
}
void display_measurements(double elapsed)
{
if (!measurements_on)
return;
if (!has_init)
return;
/* count and check if we need to display this time */
time_elapsed += elapsed;
if (time_elapsed < DISPLAY_MEAS_INTERVAL)
return;
time_elapsed = fmod(time_elapsed, DISPLAY_MEAS_INTERVAL);
print_measurements(1);
}

View File

@ -1,414 +0,0 @@
/* display spectrum of IQ data
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libfft/fft.h"
#include "../libdebug/debug.h"
#include "../libdisplay/display.h"
#define HEIGHT 20
static int has_init = 0;
static double buffer_delay[MAX_DISPLAY_SPECTRUM];
static double buffer_hold[MAX_DISPLAY_SPECTRUM];
static char screen[HEIGHT][MAX_DISPLAY_WIDTH];
static uint8_t screen_color[HEIGHT][MAX_DISPLAY_WIDTH];
static int spectrum_on = 0;
static double db = 120;
static double center_frequency, frequency_range;
static dispspectrum_t disp;
void display_spectrum_init(int samplerate, double _center_frequency)
{
memset(&disp, 0, sizeof(disp));
disp.interval_max = (double)samplerate * DISPLAY_INTERVAL + 0.5;
/* should not happen due to low interval */
if (disp.interval_max < MAX_DISPLAY_SPECTRUM - 1)
disp.interval_max = MAX_DISPLAY_SPECTRUM - 1;
memset(buffer_delay, 0, sizeof(buffer_delay));
center_frequency = _center_frequency;
frequency_range = (double)samplerate;
has_init = 1;
}
void display_spectrum_add_mark(const char *kanal, double frequency)
{
dispspectrum_mark_t *mark, **mark_p;
if (!has_init)
return;
mark = calloc(1, sizeof(*mark));
if (!mark) {
fprintf(stderr, "no mem!");
abort();
}
mark->kanal = kanal;
mark->frequency = frequency;
mark_p = &disp.mark;
while (*mark_p)
mark_p = &((*mark_p)->next);
*mark_p = mark;
}
void display_spectrum_exit(void)
{
dispspectrum_mark_t *mark = disp.mark, *temp;
while (mark) {
temp = mark;
mark = mark->next;
free(temp);
}
disp.mark = NULL;
has_init = 0;
}
void display_spectrum_on(int on)
{
int j;
int w, h;
get_win_size(&w, &h);
if (w > MAX_DISPLAY_WIDTH - 1)
w = MAX_DISPLAY_WIDTH - 1;
if (spectrum_on) {
memset(&screen, ' ', sizeof(screen));
memset(&buffer_hold, 0, sizeof(buffer_hold));
lock_debug();
printf("\0337\033[H");
for (j = 0; j < HEIGHT; j++) {
screen[j][w] = '\0';
puts(screen[j]);
}
printf("\0338"); fflush(stdout);
unlock_debug();
}
if (on < 0) {
if (++spectrum_on == 3)
spectrum_on = 0;
} else
spectrum_on = on;
if (spectrum_on)
debug_limit_scroll = HEIGHT;
else
debug_limit_scroll = 0;
}
/*
* plot spectrum data:
*
*/
void display_spectrum(float *samples, int length)
{
dispspectrum_mark_t *mark;
char print_channel[32], print_frequency[32];
int width, h;
int pos, max;
double *buffer_I, *buffer_Q;
int color = 9; /* default color */
int i, j, k, o;
double I, Q, v;
int s, e, l, n;
if (!spectrum_on)
return;
lock_debug();
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
/* calculate size of FFT */
int m, fft_size = 0, fft_taps = 0;
for (m = 0; m < 16; m++) {
if ((1 << m) > MAX_DISPLAY_SPECTRUM)
break;
if ((1 << m) <= width) {
fft_taps = m;
fft_size = 1 << m;
}
}
if (m == 16) {
fprintf(stderr, "Size of spectrum is not a power of 2, please fix!\n");
abort();
}
int hold[fft_size], delay[fft_size], current[fft_size];
pos = disp.interval_pos;
max = disp.interval_max;
buffer_I = disp.buffer_I;
buffer_Q = disp.buffer_Q;
for (i = 0; i < length; i++) {
if (pos >= fft_size) {
if (++pos == max)
pos = 0;
continue;
}
buffer_I[pos] = samples[i * 2];
buffer_Q[pos] = samples[i * 2 + 1];
pos++;
if (pos == fft_size) {
fft_process(1, fft_taps, buffer_I, buffer_Q);
k = 0;
for (j = 0; j < fft_size; j++) {
/* scale result vertically */
I = buffer_I[(j + fft_size / 2) % fft_size];
Q = buffer_Q[(j + fft_size / 2) % fft_size];
v = sqrt(I*I + Q*Q);
v = log10(v) * 20 + db;
if (v < 0)
v = 0;
v /= db;
/* delayed */
buffer_delay[j] -= DISPLAY_INTERVAL / 10.0;
if (v > buffer_delay[j])
buffer_delay[j] = v;
delay[j] = (double)(HEIGHT * 2 - 1) * (1.0 - buffer_delay[j]);
if (delay[j] < 0)
delay[j] = 0;
if (delay[j] >= (HEIGHT * 2))
delay[j] = (HEIGHT * 2) - 1;
/* hold */
if (spectrum_on == 2) {
if (v > buffer_hold[j])
buffer_hold[j] = v;
hold[j] = (double)(HEIGHT * 2 - 1) * (1.0 - buffer_hold[j]);
if (hold[j] < 0)
hold[j] = 0;
if (hold[j] >= (HEIGHT * 2))
hold[j] = (HEIGHT * 2) - 1;
}
/* current */
current[j] = (double)(HEIGHT * 2 - 1) * (1.0 - v);
if (current[j] < 0)
current[j] = 0;
if (current[j] >= (HEIGHT * 2))
current[j] = (HEIGHT * 2) - 1;
}
/* plot scaled buffer */
memset(&screen, ' ', sizeof(screen));
memset(&screen_color, 7, sizeof(screen_color)); /* all white */
sprintf(screen[0], "(spectrum log %.0f dB%s", db, (spectrum_on == 2) ? " HOLD" : "");
*strchr(screen[0], '\0') = ')';
for (j = 2; j < HEIGHT; j += 2) {
memset(screen_color[j], 4, 7); /* blue */
sprintf(screen[j], "%4.0f dB", -(double)(j+1) * db / (double)(HEIGHT - 1));
screen[j][7] = ' ';
}
o = (width - fft_size) / 2; /* offset from left border */
for (j = 0; j < fft_size; j++) {
/* show current spectrum in yellow */
s = l = n = current[j];
/* get last and next value */
if (j > 0)
l = (current[j - 1] + s) / 2;
if (j < fft_size - 1)
n = (current[j + 1] + s) / 2;
if (s > l && s > n) {
/* current value is a minimum */
e = s;
s = (l < n) ? (l + 1) : (n + 1);
} else if (s < l && s < n) {
/* current value is a maximum */
e = (l > n) ? l : n;
} else if (l < n) {
/* last value is higher, next value is lower */
s = l + 1;
e = n;
} else if (l > n) {
/* last value is lower, next value is higher */
s = n + 1;
e = l;
} else {
/* current, last and next values are equal */
e = s;
}
if (s == e) {
if ((s & 1) == 0)
screen[s >> 1][j + o] = '\'';
else
screen[s >> 1][j + o] = '.';
screen_color[s >> 1][j + o] = 13;
} else {
if ((s & 1) == 0)
screen[s >> 1][j + o] = '|';
else
screen[s >> 1][j + o] = '.';
screen_color[s >> 1][j + o] = 13;
if ((e & 1) == 0)
screen[e >> 1][j + o] = '\'';
else
screen[e >> 1][j + o] = '|';
screen_color[e >> 1][j + o] = 13;
for (k = (s >> 1) + 1; k < (e >> 1); k++) {
screen[k][j + o] = '|';
screen_color[k][j + o] = 13;
}
}
/* show delayed spectrum in blue */
e = s;
s = delay[j];
if ((s >> 1) < (e >> 1)) {
if ((s & 1) == 0)
screen[s >> 1][j + o] = '|';
else
screen[s >> 1][j + o] = '.';
screen_color[s >> 1][j + o] = 4;
for (k = (s >> 1) + 1; k < (e >> 1); k++) {
screen[k][j + o] = '|';
screen_color[k][j + o] = 4;
}
}
if (spectrum_on == 2) {
/* show hold spectrum in white */
s = l = n = hold[j];
/* get last and next value */
if (j > 0)
l = (hold[j - 1] + s) / 2;
if (j < fft_size - 1)
n = (hold[j + 1] + s) / 2;
if (s > l && s > n) {
/* hold value is a minimum */
e = s;
s = (l < n) ? (l + 1) : (n + 1);
} else if (s < l && s < n) {
/* hold value is a maximum */
e = (l > n) ? l : n;
} else if (l < n) {
/* last value is higher, next value is lower */
s = l + 1;
e = n;
} else if (l > n) {
/* last value is lower, next value is higher */
s = n + 1;
e = l;
} else {
/* hold, last and next values are equal */
e = s;
}
if (s == e) {
if ((s & 1) == 0)
screen[s >> 1][j + o] = '\'';
else
screen[s >> 1][j + o] = '.';
screen_color[s >> 1][j + o] = 17;
} else {
if ((s & 1) == 0)
screen[s >> 1][j + o] = '|';
else
screen[s >> 1][j + o] = '.';
screen_color[s >> 1][j + o] = 17;
if ((e & 1) == 0)
screen[e >> 1][j + o] = '\'';
else
screen[e >> 1][j + o] = '|';
screen_color[e >> 1][j + o] = 17;
for (k = (s >> 1) + 1; k < (e >> 1); k++) {
screen[k][j + o] = '|';
screen_color[k][j + o] = 17;
}
}
}
}
/* add channel positions in spectrum */
for (mark = disp.mark; mark; mark = mark->next) {
j = (int)((mark->frequency - center_frequency) / frequency_range * (double) fft_size + width / 2 + 0.5);
if (j < 0 || j >= width) /* check out-of-range, should not happen */
continue;
for (k = 0; k < HEIGHT; k++) {
/* skip yellow/white graph */
if (screen_color[k][j] == 13 || screen_color[k][j] == 17)
continue;
screen[k][j] = ':';
screen_color[k][j] = 12;
}
sprintf(print_channel, "Ch%s", mark->kanal);
for (o = 0; o < (int)strlen(print_channel); o++) {
s = j - strlen(print_channel) + o;
if (s >= 0 && s < width) {
screen[HEIGHT - 1][s] = print_channel[o];
screen_color[HEIGHT - 1][s] = 7;
}
}
if (fmod(mark->frequency, 1000.0))
sprintf(print_frequency, "%.4f", mark->frequency / 1e6);
else
sprintf(print_frequency, "%.3f", mark->frequency / 1e6);
for (o = 0; o < (int)strlen(print_frequency); o++) {
s = j + o + 1;
if (s >= 0 && s < width) {
screen[HEIGHT - 1][s] = print_frequency[o];
screen_color[HEIGHT - 1][s] = 7;
}
}
}
/* add center (DC line) to spectrum */
j = width / 2 + 0.5;
if (j < 1 || j >= width-1) /* check out-of-range, should not happen */
continue;
for (k = 0; k < HEIGHT; k++) {
/* skip green/yellow/white graph */
if (screen_color[k][j] == 13 || screen_color[k][j] == 17 || screen_color[k][j] == 12)
continue;
screen[k][j] = '.';
screen_color[k][j] = 7;
}
screen[0][j-1] = 'D';
screen[0][j+1] = 'C';
screen_color[0][j-1] = 7;
screen_color[0][j+1] = 7;
/* display buffer */
printf("\0337\033[H");
for (j = 0; j < HEIGHT; j++) {
for (k = 0; k < width; k++) {
if (screen_color[j][k] != color) {
color = screen_color[j][k];
printf("\033[%d;3%dm", color / 10, color % 10);
}
putchar(screen[j][k]);
}
printf("\n");
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
}
}
disp.interval_pos = pos;
unlock_debug();
}

View File

@ -1,145 +0,0 @@
/* display status functions
*
* (C) 2017 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libdisplay/display.h"
static int status_on = 0;
static int line_count = 0;
static int lines_total = 0;
static char screen[MAX_HEIGHT_STATUS][MAX_DISPLAY_WIDTH];
static void print_status(int on)
{
int i, j;
int w, h;
get_win_size(&w, &h);
if (w > MAX_DISPLAY_WIDTH - 1)
w = MAX_DISPLAY_WIDTH - 1;
if (w > MAX_DISPLAY_WIDTH)
w = MAX_DISPLAY_WIDTH;
h--;
if (h > lines_total)
h = lines_total;
lock_debug();
printf("\0337\033[H\033[1;37m");
for (i = 0; i < h; i++) {
j = 0;
if (on) {
for (j = 0; j < w; j++)
putchar(screen[i][j]);
} else {
for (j = 0; j < w; j++)
putchar(' ');
}
putchar('\n');
}
printf("\0338"); fflush(stdout);
unlock_debug();
}
void display_status_on(int on)
{
if (status_on)
print_status(0);
if (on < 0)
status_on = 1 - status_on;
else
status_on = on;
if (status_on)
print_status(1);
if (status_on)
debug_limit_scroll = lines_total;
else
debug_limit_scroll = 0;
}
/* start status display */
void display_status_start(void)
{
memset(screen, ' ', sizeof(screen));
memset(screen[0], '-', sizeof(screen[0]));
memcpy(screen[0] + 4, "Channel Status", 14);
line_count = 1;
}
void display_status_channel(const char *kanal, const char *type, const char *state)
{
char line[MAX_DISPLAY_WIDTH];
/* add empty line after previous channel+subscriber */
if (line_count > 1 && line_count < MAX_HEIGHT_STATUS)
line_count++;
if (line_count == MAX_HEIGHT_STATUS)
return;
if (type)
snprintf(line, sizeof(line), "Channel: %s Type: %s State: %s", kanal, type, state);
else
snprintf(line, sizeof(line), "Channel: %s State: %s", kanal, state);
line[sizeof(line) - 1] = '\0';
memcpy(screen[line_count++], line, strlen(line));
}
void display_status_subscriber(const char *number, const char *state)
{
char line[MAX_DISPLAY_WIDTH];
if (line_count == MAX_HEIGHT_STATUS)
return;
if (state)
snprintf(line, sizeof(line), " Subscriber: %s State: %s", number, state);
else
snprintf(line, sizeof(line), " Subscriber: %s", number);
line[sizeof(line) - 1] = '\0';
memcpy(screen[line_count++], line, strlen(line));
}
void display_status_end(void)
{
if (line_count < MAX_HEIGHT_STATUS) {
memset(screen[line_count], '-', sizeof(screen[line_count]));
line_count++;
}
/* if last total lines exceed current line count, keep it, so removed lines are overwritten with spaces */
if (line_count > lines_total)
lines_total = line_count;
if (status_on)
print_status(1);
/* set new total lines */
lines_total = line_count;
if (status_on)
debug_limit_scroll = lines_total;
}

View File

@ -1,252 +0,0 @@
/* display wave form functions
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <pthread.h>
#include <math.h>
#include <sys/ioctl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../libdisplay/display.h"
#define HEIGHT 11
static int num_sender = 0;
static char screen[HEIGHT][MAX_DISPLAY_WIDTH];
static int wave_on = 0;
void display_wave_init(dispwav_t *disp, int samplerate, const char *kanal)
{
memset(disp, 0, sizeof(*disp));
disp->offset = (num_sender++) * HEIGHT;
disp->interval_max = (double)samplerate * DISPLAY_INTERVAL + 0.5;
disp->kanal = kanal;
}
void display_wave_on(int on)
{
int i, j;
int w, h;
get_win_size(&w, &h);
if (w > MAX_DISPLAY_WIDTH - 1)
w = MAX_DISPLAY_WIDTH - 1;
if (wave_on) {
memset(&screen, ' ', sizeof(screen));
lock_debug();
printf("\0337\033[H");
for (i = 0; i < num_sender; i++) {
for (j = 0; j < HEIGHT; j++) {
screen[j][w] = '\0';
puts(screen[j]);
}
}
printf("\0338"); fflush(stdout);
unlock_debug();
}
if (on < 0)
wave_on = 1 - wave_on;
else
wave_on = on;
if (wave_on)
debug_limit_scroll = HEIGHT * num_sender;
else
debug_limit_scroll = 0;
}
/*
* draw wave form:
*
* theoretical example: HEIGHT = 3 allows 5 steps
*
* Line 0: '.
* Line 1: '.
* Line 2: '
*
* HEIGHT is odd, so the center line's char is ''' (otherwise '.')
* (HEIGHT - 1) / 2 = 1, so the center line is drawn in line 1
*
* y is in range of 0..4, so these are 5 steps, where 2 is the
* center line. this is calculated by (HEIGHT * 2 - 1)
*/
void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
{
int pos, max;
sample_t *buffer;
int i, j, k, s, e;
double last, current, next;
int color = 9; /* default color */
int center_line;
char center_char;
int width, h;
if (!wave_on)
return;
lock_debug();
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
/* at what line we draw our zero-line and what character we use */
center_line = (HEIGHT - 1) >> 1;
center_char = (HEIGHT & 1) ? '\'' : '.';
pos = disp->interval_pos;
max = disp->interval_max;
buffer = disp->buffer;
for (i = 0; i < length; i++) {
if (pos >= width + 2) {
if (++pos == max)
pos = 0;
continue;
}
buffer[pos++] = samples[i];
if (pos == width + 2) {
memset(&screen, ' ', sizeof(screen));
for (j = 0; j < width; j++) {
/* Input value is scaled to range -1 .. 1 and then subtracted from 1,
* so the result ranges from 0 .. 2.
* HEIGHT-1 is multiplied with the range, so a HEIGHT of 3 would allow
* 0..4 (5 steps) and a HEIGHT of 11 would allow 0..20 (21 steps).
* We always use odd number of steps, so there will be a center between
* values.
*/
last = (1.0 - buffer[j] / range) * (double)(HEIGHT - 1);
current = (1.0 - buffer[j + 1] / range) * (double)(HEIGHT - 1);
next = (1.0 - buffer[j + 2] / range) * (double)(HEIGHT - 1);
/* calculate start and end for vertical line
* if the current value is a peak (above or below last AND next point),
* round this peak point to become one end of the vertical line.
* the other end is rounded up or down, so the end of the line will
* not overlap with the ends of the surrounding lines.
*/
if (last > current) {
if (next > current) {
/* current point is a peak up */
s = round(current);
/* use lowest neighbor point and end is half way */
if (last > next)
e = floor((last + current) / 2.0);
else
e = floor((next + current) / 2.0);
/* end point must not be above start point */
if (e < s)
e = s;
} else {
/* current point is a transition upwards */
s = ceil((next + current) / 2.0);
e = floor((last + current) / 2.0);
/* end point must not be above start point */
if (e < s)
s = e = round(current);
}
} else {
if (next <= current) {
/* current point is a peak down */
e = round(current);
/* use heighes neighbor point and start is half way */
if (last <= next)
s = ceil((last + current) / 2.0);
else
s = ceil((next + current) / 2.0);
/* start point must not be below end point */
if (s > e)
s = e;
} else {
/* current point is a transition downwards */
s = ceil((last + current) / 2.0);
e = floor((next + current) / 2.0);
/* start point must not be below end point */
if (s > e)
s = e = round(current);
}
}
/* only draw line, if it is in range */
if (e >= 0 && s < HEIGHT * 2 - 1) {
/* clip */
if (s < 0)
s = 0;
if (e >= HEIGHT * 2 - 1)
e = HEIGHT * 2 - 1;
/* plot start and end point */
if ((s & 1))
screen[s >> 1][j] = '.';
else if (e != s)
screen[s >> 1][j] = '|';
if (!(e & 1))
screen[e >> 1][j] = '\'';
else if (e != s)
screen[e >> 1][j] = '|';
/* plot line between start and end point */
for (k = (s >> 1) + 1; k < (e >> 1); k++)
screen[k][j] = '|';
}
}
sprintf(screen[0], "(chan %s", disp->kanal);
*strchr(screen[0], '\0') = ')';
printf("\0337\033[H");
for (j = 0; j < disp->offset; j++)
puts("");
for (j = 0; j < HEIGHT; j++) {
for (k = 0; k < width; k++) {
if (j == center_line && screen[j][k] == ' ') {
/* blue 0-line */
if (color != 4) {
color = 4;
printf("\033[0;34m");
}
putchar(center_char);
} else if (screen[j][k] == '\'' || screen[j][k] == '.' || screen[j][k] == '|') {
/* green scope curve */
if (color != 2) {
color = 2;
printf("\033[1;32m");
}
putchar(screen[j][k]);
} else if (screen[j][k] != ' ') {
/* white other characters */
if (color != 7) {
color = 7;
printf("\033[1;37m");
}
putchar(screen[j][k]);
} else
putchar(screen[j][k]);
}
printf("\n");
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
}
}
disp->interval_pos = pos;
unlock_debug();
}

View File

@ -1,7 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libdtmf.a
libdtmf_a_SOURCES = \
dtmf_encode.c \
dtmf_decode.c

View File

@ -1,259 +0,0 @@
/* DTMF coder
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "dtmf_decode.h"
//#define DEBUG
#define level2db(level) (20 * log10(level))
#define db2level(db) pow(10, (double)db / 20.0)
#define DTMF_LOW_1 697.0
#define DTMF_LOW_2 770.0
#define DTMF_LOW_3 852.0
#define DTMF_LOW_4 941.0
#define DTMF_HIGH_1 1209.0
#define DTMF_HIGH_2 1336.0
#define DTMF_HIGH_3 1477.0
#define DTMF_HIGH_4 1633.0
static const char dtmf_digit[] = " 123A456B789C*0#D";
#ifdef DEBUG
const char *_debug_amplitude(double level)
{
static char text[42];
strcpy(text, " : ");
if (level > 1.0)
level = 1.0;
if (level < -1.0)
level = -1.0;
text[20 + (int)(level * 20)] = '*';
return text;
}
#endif
int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas), int samplerate, double max_amplitude, double min_amplitude)
{
int rc;
memset(dtmf, 0, sizeof(*dtmf));
dtmf->priv = priv;
dtmf->recv_digit = recv_digit;
dtmf->samplerate = samplerate;
dtmf->freq_margin = 1.03; /* 1.8 .. 3.5 % */
dtmf->max_amplitude = max_amplitude;
dtmf->min_amplitude = min_amplitude;
dtmf->forward_twist = db2level(4.0);
dtmf->reverse_twist = db2level(8.0);
dtmf->time_detect = (int)(0.025 * (double)samplerate);
dtmf->time_meas = (int)(0.015 * (double)samplerate);
dtmf->time_pause = (int)(0.010 * (double)samplerate);
/* init fm demodulator */
rc = fm_demod_init(&dtmf->demod_low, (double)samplerate, (DTMF_LOW_1 + DTMF_LOW_4) / 2.0, DTMF_LOW_4 - DTMF_LOW_1);
if (rc < 0)
goto error;
rc = fm_demod_init(&dtmf->demod_high, (double)samplerate, (DTMF_HIGH_1 + DTMF_HIGH_4) / 2.0, DTMF_HIGH_4 - DTMF_HIGH_1);
if (rc < 0)
goto error;
/* use fourth order (2 iter) filter, since it is as fast as second order (1 iter) filter */
iir_lowpass_init(&dtmf->freq_lp[0], 100.0, samplerate, 2);
iir_lowpass_init(&dtmf->freq_lp[1], 100.0, samplerate, 2);
return 0;
error:
dtmf_decode_exit(dtmf);
return rc;
}
void dtmf_decode_exit(dtmf_dec_t *dtmf)
{
fm_demod_exit(&dtmf->demod_low);
fm_demod_exit(&dtmf->demod_high);
}
void dtmf_decode_filter(dtmf_dec_t *dtmf, sample_t *samples, int length, sample_t *frequency_low, sample_t *frequency_high, sample_t *amplitude_low, sample_t *amplitude_high)
{
sample_t I_low[length], Q_low[length];
sample_t I_high[length], Q_high[length];
int i;
fm_demodulate_real(&dtmf->demod_low, frequency_low, length, samples, I_low, Q_low);
fm_demodulate_real(&dtmf->demod_high, frequency_high, length, samples, I_high, Q_high);
/* peak amplitude is the length of I/Q vector
* since we filter out the unwanted modulation product, the vector is only half of length */
for (i = 0; i < length; i++) {
amplitude_low[i] = sqrt(I_low[i] * I_low[i] + Q_low[i] * Q_low[i]) * 2.0;
amplitude_high[i] = sqrt(I_high[i] * I_high[i] + Q_high[i] * Q_high[i]) * 2.0;
}
iir_process(&dtmf->freq_lp[0], frequency_low, length);
iir_process(&dtmf->freq_lp[1], frequency_high, length);
}
void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length)
{
sample_t frequency_low[length], amplitude_low[length];
sample_t frequency_high[length], amplitude_high[length];
double margin, min_amplitude, max_amplitude, forward_twist, reverse_twist, f1, f2;
int time_detect, time_meas, time_pause;
int low = 0, high = 0;
char detected, digit;
int count;
int amplitude_ok, twist_ok;
int i;
margin = dtmf->freq_margin;
min_amplitude = dtmf->min_amplitude;
max_amplitude = dtmf->max_amplitude;
forward_twist = dtmf->forward_twist;
reverse_twist = dtmf->reverse_twist;
time_detect = dtmf->time_detect;
time_meas = dtmf->time_meas;
time_pause = dtmf->time_pause;
detected = dtmf->detected;
count = dtmf->count;
/* FM/AM demod */
dtmf_decode_filter(dtmf, samples, length, frequency_low, frequency_high, amplitude_low, amplitude_high);
for (i = 0; i < length; i++) {
#ifdef DEBUG
// printf("%s %.5f\n", _debug_amplitude(samples[i]/2.0), samples[i]/2.0);
#endif
/* get frequency of low frequencies, correct amplitude drop at cutoff point */
f1 = frequency_low[i] + (DTMF_LOW_1 + DTMF_LOW_4) / 2.0;
if (f1 >= DTMF_LOW_1 / margin && f1 <= DTMF_LOW_1 * margin) {
/* cutoff point */
amplitude_low[i] /= 0.7071;
low = 1;
f1 -= DTMF_LOW_1;
} else
if (f1 >= DTMF_LOW_2 / margin && f1 <= DTMF_LOW_2 * margin) {
amplitude_low[i] /= 1.0734;
low = 2;
f1 -= DTMF_LOW_2;
} else
if (f1 >= DTMF_LOW_3 / margin && f1 <= DTMF_LOW_3 * margin) {
amplitude_low[i] /= 1.0389;
low = 3;
f1 -= DTMF_LOW_3;
} else
if (f1 >= DTMF_LOW_4 / margin && f1 <= DTMF_LOW_4 * margin) {
/* cutoff point */
amplitude_low[i] /= 0.7071;
low = 4;
f1 -= DTMF_LOW_4;
} else
low = 0;
/* get frequency of high frequencies, correct amplitude drop at cutoff point */
f2 = frequency_high[i] + (DTMF_HIGH_1 + DTMF_HIGH_4) / 2.0;
if (f2 >= DTMF_HIGH_1 / margin && f2 <= DTMF_HIGH_1 * margin) {
/* cutoff point */
amplitude_high[i] /= 0.7071;
high = 1;
f2 -= DTMF_HIGH_1;
} else
if (f2 >= DTMF_HIGH_2 / margin && f2 <= DTMF_HIGH_2 * margin) {
amplitude_high[i] /= 1.0731;
high = 2;
f2 -= DTMF_HIGH_2;
} else
if (f2 >= DTMF_HIGH_3 / margin && f2 <= DTMF_HIGH_3 * margin) {
amplitude_high[i] /= 1.0372;
high = 3;
f2 -= DTMF_HIGH_3;
} else
if (f2 >= DTMF_HIGH_4 / margin && f2 <= DTMF_HIGH_4 * margin) {
/* cutoff point */
amplitude_high[i] /= 0.7071;
high = 4;
f2 -= DTMF_HIGH_4;
} else
high = 0;
digit = 0;
amplitude_ok = 0;
twist_ok = 0;
if (low && high) {
digit = dtmf_digit[low*4+high];
/* check for limits */
if (amplitude_low[i] <= max_amplitude && amplitude_low[i] >= min_amplitude && amplitude_high[i] <= max_amplitude && amplitude_high[i] >= min_amplitude) {
amplitude_ok = 1;
#ifdef DEBUG
printf("%.1f %.1f (limits %.1f .. %.1f) %.1f\n", level2db(amplitude_low[i]), level2db(amplitude_high[i]), level2db(min_amplitude), level2db(max_amplitude), level2db(amplitude_high[i] / amplitude_low[i]));
#endif
if (amplitude_high[i] / amplitude_low[i] <= forward_twist && amplitude_low[i] / amplitude_high[i] <= reverse_twist)
twist_ok = 1;
}
}
if (!detected) {
if (digit && amplitude_ok && twist_ok) {
if (count == 0) {
memset(&dtmf->meas, 0, sizeof(dtmf->meas));
}
if (count >= time_meas) {
dtmf->meas.frequency_low += f1;
dtmf->meas.frequency_high += f2;
dtmf->meas.amplitude_low += amplitude_low[i];
dtmf->meas.amplitude_high += amplitude_high[i];
dtmf->meas.count++;
}
count++;
if (count >= time_detect) {
detected = digit;
dtmf->meas.frequency_low /= dtmf->meas.count;
dtmf->meas.frequency_high /= dtmf->meas.count;
dtmf->meas.amplitude_low /= dtmf->meas.count;
dtmf->meas.amplitude_high /= dtmf->meas.count;
dtmf->meas.count = 1;
dtmf->recv_digit(dtmf->priv, digit, &dtmf->meas);
}
} else
count = 0;
} else {
if (!digit || digit != detected || !amplitude_ok || !twist_ok) {
count++;
if (count >= time_pause) {
detected = 0;
#ifdef DEBUG
printf("lost!\n");
#endif
}
} else
count = 0;
}
#ifdef DEBUG
if (digit)
printf("DTMF tone='%c' diff frequency=%.1f %.1f amplitude=%.1f %.1f dB (%s) twist=%.1f dB (%s)\n", digit, f1, f2, level2db(amplitude_low[i]), level2db(amplitude_high[i]), (amplitude_ok) ? "OK" : "nok", level2db(amplitude_high[i] / amplitude_low[i]), (twist_ok) ? "OK" : "nok");
#endif
dtmf->detected = detected;
dtmf->count = count;
}
}

View File

@ -1,35 +0,0 @@
#include "../libfm/fm.h"
typedef struct ftmf_meas {
double frequency_low;
double frequency_high;
double amplitude_low;
double amplitude_high;
int count;
} dtmf_meas_t;
typedef struct dtmf_dec {
void *priv;
void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas);
int samplerate; /* samplerate */
double freq_margin; /* +- limit of frequency deviation (percent) valid tone*/
double min_amplitude; /* minimum amplitude relative to 0 dBm */
double max_amplitude; /* maximum amplitude relative to 0 dBm */
double forward_twist; /* how much do higher frequencies are louder than lower frequencies */
double reverse_twist; /* how much do lower frequencies are louder than higher frequencies */
int time_detect;
int time_meas;
int time_pause;
fm_demod_t demod_low; /* demodulator for low frequencies */
fm_demod_t demod_high; /* demodulator for high frequencies */
iir_filter_t freq_lp[2]; /* low pass to filter the frequency result */
char detected; /* currently detected DTMF digit or 0 for no detection */
int count; /* counter to count detection or loss (pause) of signal */
dtmf_meas_t meas; /* measurements */
} dtmf_dec_t;
int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas), int samplerate, double max_amplitude, double min_amplitude);
void dtmf_decode_exit(dtmf_dec_t *dtmf);
void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length);
void dtmf_decode_filter(dtmf_dec_t *dtmf, sample_t *samples, int length, sample_t *frequency_low, sample_t *frequency_high, sample_t *amplitude_low, sample_t *amplitude_high);

View File

@ -1,123 +0,0 @@
/* DTMF coder
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "dtmf_encode.h"
#define PI M_PI
#define PEAK_DTMF_LOW 0.2818 /* -11 dBm, relative to 0 dBm level */
#define PEAK_DTMF_HIGH 0.3548 /* -9 dBm, relative to 0 dBm level */
#define DTMF_DURATION 0.100 /* duration in seconds */
static sample_t dsp_sine_dtmf_low[65536];
static sample_t dsp_sine_dtmf_high[65536];
void dtmf_encode_init(dtmf_enc_t *dtmf, int samplerate, double dBm_level)
{
int i;
memset(dtmf, 0, sizeof(*dtmf));
dtmf->samplerate = samplerate;
dtmf->max = (int)((double)samplerate * DTMF_DURATION + 0.5);
// FIXME: do this globally and not per instance */
for (i = 0; i < 65536; i++) {
dsp_sine_dtmf_low[i] = sin((double)i / 65536.0 * 2.0 * PI) * PEAK_DTMF_LOW * dBm_level;
dsp_sine_dtmf_high[i] = sin((double)i / 65536.0 * 2.0 * PI) * PEAK_DTMF_HIGH * dBm_level;
}
}
/* set dtmf tone */
void dtmf_encode_set_tone(dtmf_enc_t *dtmf, char tone)
{
double f1, f2;
switch(tone) {
case '1': f1 = 697.0; f2 = 1209.0; break;
case '2': f1 = 697.0; f2 = 1336.0; break;
case '3': f1 = 697.0; f2 = 1477.0; break;
case'a':case 'A': f1 = 697.0; f2 = 1633.0; break;
case '4': f1 = 770.0; f2 = 1209.0; break;
case '5': f1 = 770.0; f2 = 1336.0; break;
case '6': f1 = 770.0; f2 = 1477.0; break;
case'b':case 'B': f1 = 770.0; f2 = 1633.0; break;
case '7': f1 = 852.0; f2 = 1209.0; break;
case '8': f1 = 852.0; f2 = 1336.0; break;
case '9': f1 = 852.0; f2 = 1477.0; break;
case'c':case 'C': f1 = 852.0; f2 = 1633.0; break;
case '*': f1 = 941.0; f2 = 1209.0; break;
case '0': f1 = 941.0; f2 = 1336.0; break;
case '#': f1 = 941.0; f2 = 1477.0; break;
case'd':case 'D': f1 = 941.0; f2 = 1633.0; break;
default:
dtmf->tone = 0;
return;
}
dtmf->tone = tone;
dtmf->pos = 0;
dtmf->phaseshift65536[0] = 65536.0 / ((double)dtmf->samplerate / f1);
dtmf->phaseshift65536[1] = 65536.0 / ((double)dtmf->samplerate / f2);
}
/* Generate audio stream from DTMF tone. Keep phase for next call of function. */
void dtmf_encode(dtmf_enc_t *dtmf, sample_t *samples, int length)
{
double *phaseshift, *phase;
int i, pos, max;
/* use silence, if no tone */
if (!dtmf->tone) {
memset(samples, 0, length * sizeof(*samples));
return;
}
phaseshift = dtmf->phaseshift65536;
phase = dtmf->phase65536;
pos = dtmf->pos;
max = dtmf->max;
for (i = 0; i < length; i++) {
*samples++ = dsp_sine_dtmf_low[(uint16_t)phase[0]]
+ dsp_sine_dtmf_high[(uint16_t)phase[1]];
phase[0] += phaseshift[0];
if (phase[0] >= 65536)
phase[0] -= 65536;
phase[1] += phaseshift[1];
if (phase[1] >= 65536)
phase[1] -= 65536;
/* tone ends */
if (++pos == max) {
dtmf->tone = 0;
break;
}
}
length -= i;
dtmf->pos = pos;
/* if tone ends, fill rest with silence */
if (length)
memset(samples, 0, length * sizeof(*samples));
}

View File

@ -1,14 +0,0 @@
typedef struct dtmf_enc {
int samplerate; /* samplerate */
char tone; /* current tone to be played */
int pos; /* sample counter for tone */
int max; /* max number of samples for tone duration */
double phaseshift65536[2]; /* how much the phase of sine wave changes per sample */
double phase65536[2]; /* current phase */
} dtmf_enc_t;
void dtmf_encode_init(dtmf_enc_t *dtmf, int samplerate, double dBm_level);
void dtmf_encode_set_tone(dtmf_enc_t *dtmf, char tone);
void dtmf_encode(dtmf_enc_t *dtmf, sample_t *samples, int length);

View File

@ -1,6 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libemphasis.a
libemphasis_a_SOURCES = \
emphasis.c

View File

@ -1,144 +0,0 @@
/* Pre-Emphasis and De-Emphasis implementation
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libfilter/iir_filter.h"
#include "emphasis.h"
#define PI M_PI
static void gen_sine(sample_t *samples, int num, int samplerate, double freq)
{
int i;
for (i = 0; i < num; i++)
samples[i] = cos(2.0 * M_PI * freq / (double)samplerate * (double)i);
}
static double get_level(sample_t *samples, int num)
{
int i;
double envelope = 0;
for (i = num/2; i < num; i++) {
if (samples[i] > envelope)
envelope = samples[i];
}
return envelope;
}
/* calculate cut off from time constant in uS */
double timeconstant2cutoff(double time_constant_us)
{
return 1.0 / (2.0 * PI * time_constant_us / 1e6);
}
int init_emphasis(emphasis_t *state, int samplerate, double cut_off, double cut_off_h, double cut_off_l)
{
double factor;
sample_t test_samples[samplerate / 10];
memset(state, 0, sizeof(*state));
/* exp (-2 * PI * CUT_OFF * delta_t) */
factor = exp(-2.0 * PI * cut_off / (double)samplerate); /* 1/samplerate == delta_t */
// printf("Emphasis factor = %.3f\n", factor);
state->p.factor = factor;
state->p.amp = 1.0;
state->d.factor = factor;
state->d.amp = 1.0;
/* do not de-emphasis below CUT_OFF_H */
iir_highpass_init(&state->d.hp, cut_off_h, samplerate, 1);
/* do not pre-emphasis above CUT_OFF_L
* Mobile network specifications want -18 dB per octave.
* With two iterations we have 24 dB, - 6 dB (from emphasis). */
iir_lowpass_init(&state->p.lp, cut_off_l, samplerate, 2);
/* calibrate amplification to be neutral at 1000 Hz */
gen_sine(test_samples, sizeof(test_samples) / sizeof(test_samples[0]), samplerate, 1000.0);
pre_emphasis(state, test_samples, sizeof(test_samples) / sizeof(test_samples[0]));
state->p.amp = 1.0 / get_level(test_samples, sizeof(test_samples) / sizeof(test_samples[0]));
gen_sine(test_samples, sizeof(test_samples) / sizeof(test_samples[0]), samplerate, 1000.0);
de_emphasis(state, test_samples, sizeof(test_samples) / sizeof(test_samples[0]));
state->d.amp = 1.0 / get_level(test_samples, sizeof(test_samples) / sizeof(test_samples[0]));
return 0;
}
void pre_emphasis(emphasis_t *state, sample_t *samples, int num)
{
double x, y, x_last, factor, amp;
int i;
iir_process(&state->p.lp, samples, num);
x_last = state->p.x_last;
factor = state->p.factor;
amp = state->p.amp;
for (i = 0; i < num; i++) {
x = *samples;
/* pre-emphasis */
y = x - factor * x_last;
x_last = x;
*samples++ = amp * y;
}
state->p.x_last = x_last;
}
void de_emphasis(emphasis_t *state, sample_t *samples, int num)
{
double x, y, y_last, factor, amp;
int i;
y_last = state->d.y_last;
factor = state->d.factor;
amp = state->d.amp;
for (i = 0; i < num; i++) {
x = *samples;
/* de-emphasis */
y = x + factor * y_last;
y_last = y;
*samples++ = amp * y;
}
state->d.y_last = y_last;
}
/* high pass filter to remove DC and low frequencies */
void dc_filter(emphasis_t *state, sample_t *samples, int num)
{
iir_process(&state->d.hp, samples, num);
}

View File

@ -1,28 +0,0 @@
#include "../libfilter/iir_filter.h"
typedef struct emphasis {
struct {
iir_filter_t lp;
double x_last;
double factor;
double amp;
} p;
struct {
iir_filter_t hp;
double y_last;
double factor;
double amp;
} d;
} emphasis_t;
/* refers to NMT specs, cnetz uses different emphasis cutoff */
#define CUT_OFF_EMPHASIS_DEFAULT 300.0
#define CUT_OFF_HIGHPASS_DEFAULT 300.0
#define CUT_OFF_LOWPASS_DEFAULT 3400.0
double timeconstant2cutoff(double time_constant_us);
int init_emphasis(emphasis_t *state, int samplerate, double cut_off, double cut_off_h, double cut_off_l);
void pre_emphasis(emphasis_t *state, sample_t *samples, int num);
void de_emphasis(emphasis_t *state, sample_t *samples, int num);
void dc_filter(emphasis_t *state, sample_t *samples, int num);

View File

@ -1,6 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libfft.a
libfft_a_SOURCES = \
fft.c

View File

@ -1,96 +0,0 @@
/* Fast Fourier Transformation (FFT)
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <math.h>
#include <string.h>
#include "fft.h"
/*
* Code based closely to work by Paul Bourke
*
* This computes an in-place complex-to-complex FFT
* x and y are the real and imaginary arrays of 2^m points.
* dir = 1 gives forward transform
* dir = -1 gives reverse transform
*/
void fft_process(int dir, int m, double *x, double *y)
{
int n, i, i1, j, k, i2, l, l1, l2;
double c1, c2, tx, ty, t1, t2, u1, u2, z;
/* Calculate the number of points */
n = 1 << m;
/* Do the bit reversal */
i2 = n >> 1;
j = 0;
for (i = 0; i < n - 1; i++) {
if (i < j) {
tx = x[i];
ty = y[i];
x[i] = x[j];
y[i] = y[j];
x[j] = tx;
y[j] = ty;
}
k = i2;
while (k <= j) {
j -= k;
k >>= 1;
}
j += k;
}
/* Compute the FFT */
c1 = -1.0;
c2 = 0.0;
l2 = 1;
for (l = 0; l < m; l++) {
l1 = l2;
l2 <<= 1;
u1 = 1.0;
u2 = 0.0;
for (j = 0; j < l1; j++) {
for (i = j; i < n; i += l2) {
i1 = i + l1;
t1 = u1 * x[i1] - u2 * y[i1];
t2 = u1 * y[i1] + u2 * x[i1];
x[i1] = x[i] - t1;
y[i1] = y[i] - t2;
x[i] += t1;
y[i] += t2;
}
z = u1 * c1 - u2 * c2;
u2 = u1 * c2 + u2 * c1;
u1 = z;
}
c2 = sqrt((1.0 - c1) / 2.0);
if (dir == 1)
c2 = -c2;
c1 = sqrt((1.0 + c1) / 2.0);
}
/* Scaling for forward transform */
if (dir == 1) {
for (i = 0; i < n; i++) {
x[i] /= n;
y[i] /= n;
}
}
}

View File

@ -1,3 +0,0 @@
void fft_process(int dir, int m, double *x, double *y);

View File

@ -1,8 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libfilter.a
libfilter_a_SOURCES = \
iir_filter.c \
fir_filter.c

View File

@ -1,197 +0,0 @@
/* FIR filter
*
* (C) 2017 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "../libsample/sample.h"
#include "fir_filter.h"
//#define DEBUG_TAPS
static void kernel(double *taps, int M, double cutoff, int invert)
{
int i;
double sum;
for (i = 0; i <= M; i++) {
/* gen sinc */
if (i == M / 2)
taps[i] = 2.0 * M_PI * cutoff;
else
taps[i] = sin(2.0 * M_PI * cutoff * (double)(i - M / 2))
/ (double)(i - M / 2);
/* blackman window */
taps[i] *= 0.42 - 0.50 * cos(2 * M_PI * (double)(i / M))
+ 0.08 * cos(4 * M_PI * (double)(i / M));
}
/* normalize */
sum = 0;
for (i = 0; i <= M; i++)
sum += taps[i];
for (i = 0; i <= M; i++)
taps[i] /= sum;
/* invert */
if (invert) {
for (i = 0; i <= M; i++)
taps[i] = -taps[i];
taps[M / 2] += 1.0;
}
#ifdef DEBUG_TAPS
puts("start");
for (i = 0; i <= M; i++)
puts(debug_amplitude(taps[i]));
#endif
}
static fir_filter_t *fir_init(double samplerate, double transition_bandwidth)
{
fir_filter_t *fir;
int M;
/* alloc struct */
fir = calloc(1, sizeof(*fir));
if (!fir) {
fprintf(stderr, "No memory creating FIR filter!\n");
return NULL;
}
/* transition bandwidth */
M = ceil(1.0 / (transition_bandwidth / samplerate));
if ((M & 1))
M++;
// printf("cutoff=%.4f\n", cutoff / samplerate);
// printf("tb=%.4f\n", transition_bandwidth / samplerate);
fir->ntaps = M + 1;
fir->delay = M / 2;
/* alloc taps */
fir->taps = calloc(fir->ntaps, sizeof(*fir->taps));
if (!fir->taps) {
fprintf(stderr, "No memory creating FIR filter!\n");
fir_exit(fir);
return NULL;
}
/* alloc ring buffer */
fir->buffer = calloc(fir->ntaps, sizeof(*fir->buffer));
if (!fir->buffer) {
fprintf(stderr, "No memory creating FIR filter!\n");
fir_exit(fir);
return NULL;
}
return fir;
}
fir_filter_t *fir_lowpass_init(double samplerate, double cutoff, double transition_bandwidth)
{
/* calculate kernel */
fir_filter_t *fir = fir_init(samplerate, transition_bandwidth);
if (!fir)
return NULL;
kernel(fir->taps, fir->ntaps - 1, cutoff / samplerate, 0);
return fir;
}
fir_filter_t *fir_highpass_init(double samplerate, double cutoff, double transition_bandwidth)
{
fir_filter_t *fir = fir_init(samplerate, transition_bandwidth);
if (!fir)
return NULL;
kernel(fir->taps, fir->ntaps - 1, cutoff / samplerate, 1);
return fir;
}
fir_filter_t *fir_allpass_init(double samplerate, double transition_bandwidth)
{
fir_filter_t *fir = fir_init(samplerate, transition_bandwidth);
if (!fir)
return NULL;
fir->taps[(fir->ntaps - 1) / 2] = 1.0;
return fir;
}
fir_filter_t *fir_twopass_init(double samplerate, double cutoff_low, double cutoff_high, double transition_bandwidth)
{
int i;
double sum;
fir_filter_t *fir = fir_init(samplerate, transition_bandwidth);
if (!fir)
return NULL;
double lp_taps[fir->ntaps], hp_taps[fir->ntaps];
kernel(lp_taps, fir->ntaps - 1, cutoff_low / samplerate, 0);
kernel(hp_taps, fir->ntaps - 1, cutoff_high / samplerate, 1);
sum = 0;
printf("#warning does not work as expected\n");
abort();
for (i = 0; i < fir->ntaps; i++) {
fir->taps[i] = lp_taps[i] + hp_taps[i];
sum += fir->taps[i];
}
/* hp will die */
// for (i = 0; i < fir->ntaps; i++)
// fir->taps[i] /= sum;
return fir;
}
void fir_exit(fir_filter_t *fir)
{
if (!fir)
return;
free(fir->taps);
free(fir->buffer);
free(fir);
}
void fir_process(fir_filter_t *fir, sample_t *samples, int num)
{
int i, j;
double y;
for (i = 0; i < num; i++) {
/* put sample in ring buffer */
fir->buffer[fir->buffer_pos] = samples[i];
if (++fir->buffer_pos == fir->ntaps)
fir->buffer_pos = 0;
/* convolve samples */
y = 0;
for (j = 0; j < fir->ntaps; j++) {
/* convolve sample from ring buffer, starting with oldest */
y += fir->buffer[fir->buffer_pos] * fir->taps[j];
if (++fir->buffer_pos == fir->ntaps)
fir->buffer_pos = 0;
}
samples[i] = y;
}
}
int fir_get_delay(fir_filter_t *fir)
{
return fir->delay;
}

View File

@ -1,21 +0,0 @@
#ifndef _FIR_FILTER_H
#define _FIR_FILTER_H
typedef struct fir_filter {
int ntaps;
int delay;
double *taps;
double *buffer;
int buffer_pos;
} fir_filter_t;
fir_filter_t *fir_lowpass_init(double samplerate, double cutoff, double transition_bandwidth);
fir_filter_t *fir_highpass_init(double samplerate, double cutoff, double transition_bandwidth);
fir_filter_t *fir_allpass_init(double samplerate, double transition_bandwidth);
fir_filter_t *fir_twopass_init(double samplerate, double cutoff_low, double cutoff_high, double transition_bandwidth);
void fir_exit(fir_filter_t *fir);
void fir_process(fir_filter_t *fir, sample_t *samples, int num);
int fir_get_delay(fir_filter_t *fir);
#endif /* _FIR_FILTER_H */

Some files were not shown because too many files have changed in this diff Show More