[ ] maybe in ascii art
[ ] blog posts(s)
[ ] Codec 2 web page update
+[ ] examples of various combinations of fdmdv demos
+ $ ./fdmdv_get_test_bits test.c2 1400
+ $ ./fdmdv_mod test.c2 test.raw
+ $ play -r 8000 -s -2 test.raw
+
+ Two seconds of test frame data out of sound device:
+ $ ./fdmdv_get_test_bits - 2800 | ./fdmdv_mod - - | play -t raw -r 8000 -s -2 -
+
+[ ] PAPR idea
+ + automatically weak phases to reduce PAPR, e.g. slow variations in freq...
Tests
library_includedir = $(prefix)/include
library_include_HEADERS = codec2.h
-bin_PROGRAMS = c2demo c2enc c2dec c2sim fdmdv_mod fdmdv_demod
+bin_PROGRAMS = c2demo c2enc c2dec c2sim fdmdv_get_test_bits fdmdv_mod fdmdv_demod
c2demo_SOURCES = c2demo.c
c2demo_LDADD = $(lib_LTLIBRARIES)
c2sim_LDADD = $(lib_LTLIBRARIES)
c2sim_LDFLAGS = $(LIBS)
+fdmdv_get_test_bits_SOURCES = fdmdv_get_test_bits.c fdmdv.c fft.c kiss_fft.c
+fdmdv_get_test_bits_LDFLAGS = $(LIBS)
+
fdmdv_mod_SOURCES = fdmdv_mod.c fdmdv.c fft.c kiss_fft.c
fdmdv_mod_LDFLAGS = $(LIBS)
host_triplet = @host@
noinst_PROGRAMS = generate_codebook$(EXEEXT) genlspdtcb$(EXEEXT)
bin_PROGRAMS = c2demo$(EXEEXT) c2enc$(EXEEXT) c2dec$(EXEEXT) \
- c2sim$(EXEEXT) fdmdv_mod$(EXEEXT) fdmdv_demod$(EXEEXT)
+ c2sim$(EXEEXT) fdmdv_get_test_bits$(EXEEXT) fdmdv_mod$(EXEEXT) \
+ fdmdv_demod$(EXEEXT)
subdir = src
DIST_COMMON = $(library_include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
fft.$(OBJEXT) kiss_fft.$(OBJEXT) octave.$(OBJEXT)
fdmdv_demod_OBJECTS = $(am_fdmdv_demod_OBJECTS)
fdmdv_demod_LDADD = $(LDADD)
+am_fdmdv_get_test_bits_OBJECTS = fdmdv_get_test_bits.$(OBJEXT) \
+ fdmdv.$(OBJEXT) fft.$(OBJEXT) kiss_fft.$(OBJEXT)
+fdmdv_get_test_bits_OBJECTS = $(am_fdmdv_get_test_bits_OBJECTS)
+fdmdv_get_test_bits_LDADD = $(LDADD)
am_fdmdv_mod_OBJECTS = fdmdv_mod.$(OBJEXT) fdmdv.$(OBJEXT) \
fft.$(OBJEXT) kiss_fft.$(OBJEXT)
fdmdv_mod_OBJECTS = $(am_fdmdv_mod_OBJECTS)
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libcodec2_la_SOURCES) $(c2dec_SOURCES) $(c2demo_SOURCES) \
$(c2enc_SOURCES) $(c2sim_SOURCES) $(fdmdv_demod_SOURCES) \
- $(fdmdv_mod_SOURCES) generate_codebook.c genlspdtcb.c
+ $(fdmdv_get_test_bits_SOURCES) $(fdmdv_mod_SOURCES) \
+ generate_codebook.c genlspdtcb.c
DIST_SOURCES = $(libcodec2_la_SOURCES) $(c2dec_SOURCES) \
$(c2demo_SOURCES) $(c2enc_SOURCES) $(c2sim_SOURCES) \
- $(fdmdv_demod_SOURCES) $(fdmdv_mod_SOURCES) \
- generate_codebook.c genlspdtcb.c
+ $(fdmdv_demod_SOURCES) $(fdmdv_get_test_bits_SOURCES) \
+ $(fdmdv_mod_SOURCES) generate_codebook.c genlspdtcb.c
library_includeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(library_include_HEADERS)
ETAGS = etags
c2sim_SOURCES = c2sim.c
c2sim_LDADD = $(lib_LTLIBRARIES)
c2sim_LDFLAGS = $(LIBS)
+fdmdv_get_test_bits_SOURCES = fdmdv_get_test_bits.c fdmdv.c fft.c kiss_fft.c
+fdmdv_get_test_bits_LDFLAGS = $(LIBS)
fdmdv_mod_SOURCES = fdmdv_mod.c fdmdv.c fft.c kiss_fft.c
fdmdv_mod_LDFLAGS = $(LIBS)
fdmdv_demod_SOURCES = fdmdv_demod.c fdmdv.c fft.c kiss_fft.c octave.c
fdmdv_demod$(EXEEXT): $(fdmdv_demod_OBJECTS) $(fdmdv_demod_DEPENDENCIES)
@rm -f fdmdv_demod$(EXEEXT)
$(LINK) $(fdmdv_demod_LDFLAGS) $(fdmdv_demod_OBJECTS) $(fdmdv_demod_LDADD) $(LIBS)
+fdmdv_get_test_bits$(EXEEXT): $(fdmdv_get_test_bits_OBJECTS) $(fdmdv_get_test_bits_DEPENDENCIES)
+ @rm -f fdmdv_get_test_bits$(EXEEXT)
+ $(LINK) $(fdmdv_get_test_bits_LDFLAGS) $(fdmdv_get_test_bits_OBJECTS) $(fdmdv_get_test_bits_LDADD) $(LIBS)
fdmdv_mod$(EXEEXT): $(fdmdv_mod_OBJECTS) $(fdmdv_mod_DEPENDENCIES)
@rm -f fdmdv_mod$(EXEEXT)
$(LINK) $(fdmdv_mod_LDFLAGS) $(fdmdv_mod_OBJECTS) $(fdmdv_mod_LDADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c2sim.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdmdv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdmdv_demod.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdmdv_get_test_bits.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdmdv_mod.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fft.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generate_codebook.Po@am__quote@
FDMDV modulator, take a frame of FDMDV_BITS_PER_FRAME bits and
generates a frame of FDMDV_SAMPLES_PER_FRAME modulated symbols.
- Sync bit is returned to aid alignment of your next frame.
+ Sync bit is returned to aid alignment of your next frame. It is the
+ sync_bit (pilot bit) value that will be used for the next frame of
+ mosulatedsamples.
\*---------------------------------------------------------------------------*/
#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
-/* lof of information we want to sump to Octave */
+/* lof of information we want to dump to Octave */
-#define MAX_FRAMES 50*60
+#define MAX_FRAMES 50*60 /* 1 minute at 50 symbols/s */
void dump_to_octave(struct FDMDV *fdmdv, FILE *f);
--- /dev/null
+/*---------------------------------------------------------------------------*\
+
+ FILE........: fdmdv_get_test_bits.c
+ AUTHOR......: David Rowe
+ DATE CREATED: 1 May 2012
+
+ Generates a file of packed test bits, useful for input to fdmdv_mod.
+
+\*---------------------------------------------------------------------------*/
+
+
+/*
+ Copyright (C) 2012 David Rowe
+
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 2, as
+ published by the Free Software Foundation. This program is
+ distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <errno.h>
+
+#include "fdmdv.h"
+
+#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
+#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
+
+int main(int argc, char *argv[])
+{
+ FILE *fout;
+ struct FDMDV *fdmdv;
+ char packed_bits[BYTES_PER_CODEC_FRAME];
+ int tx_bits[2*FDMDV_BITS_PER_FRAME];
+ int n, i, bit, byte;
+ int numBits, nCodecFrames;
+
+ if (argc < 3) {
+ printf("usage: %s OutputBitFile numBits\n", argv[0]);
+ printf("e.g %s test.c2 1400\n", argv[0]);
+ exit(1);
+ }
+
+ if (strcmp(argv[1], "-") == 0) fout = stdout;
+ else if ( (fout = fopen(argv[1],"wb")) == NULL ) {
+ fprintf(stderr, "Error opening output bit file: %s: %s.\n",
+ argv[1], strerror(errno));
+ exit(1);
+ }
+
+ numBits = atoi(argv[2]);
+ nCodecFrames = numBits/BITS_PER_CODEC_FRAME;
+
+ fdmdv = fdmdv_create();
+
+ for(n=0; n<nCodecFrames; n++) {
+
+ fdmdv_get_test_bits(fdmdv, tx_bits);
+ fdmdv_get_test_bits(fdmdv, &tx_bits[FDMDV_BITS_PER_FRAME]);
+
+ /* pack bits, MSB received first */
+
+ bit = 7; byte = 0;
+ memset(packed_bits, 0, BYTES_PER_CODEC_FRAME);
+ for(i=0; i<BITS_PER_CODEC_FRAME; i++) {
+ packed_bits[byte] |= (tx_bits[i] << bit);
+ bit--;
+ if (bit < 0) {
+ bit = 7;
+ byte++;
+ }
+ }
+ assert(byte == BYTES_PER_CODEC_FRAME);
+
+ fwrite(packed_bits, sizeof(char), BYTES_PER_CODEC_FRAME, fout);
+
+ /* if this is in a pipeline, we probably don't want the usual
+ buffering to occur */
+
+ if (fout == stdout) fflush(stdout);
+ }
+
+ fclose(fout);
+ fdmdv_destroy(fdmdv);
+
+ return 0;
+}
+
/* modulate even and odd frames */
fdmdv_mod(fdmdv, tx_fdm, tx_bits, &sync_bit);
- assert(sync_bit == 0);
+ assert(sync_bit == 1);
fdmdv_mod(fdmdv, &tx_fdm[FDMDV_SAMPLES_PER_FRAME], &tx_bits[FDMDV_BITS_PER_FRAME], &sync_bit);
- assert(sync_bit == 1);
+ assert(sync_bit == 0);
/* scale and save to disk as shorts */