unittest - unit test source code
voicing - hand-estimated voicing files, used for development
wav - speech files in wave file format
+ win32 - Support for building Windows DLL version of Codec 2 and FDMDV libraries
TODO
----
\*---------------------------------------------------------------------------*/
-struct CODEC2 *codec2_create(int mode)
+struct CODEC2 * WIN32SUPPORT codec2_create(int mode)
{
struct CODEC2 *c2;
int i,l;
\*---------------------------------------------------------------------------*/
-void codec2_destroy(struct CODEC2 *c2)
+void WIN32SUPPORT codec2_destroy(struct CODEC2 *c2)
{
assert(c2 != NULL);
nlp_destroy(c2->nlp);
\*---------------------------------------------------------------------------*/
-int codec2_bits_per_frame(struct CODEC2 *c2) {
+int WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *c2) {
if (c2->mode == CODEC2_MODE_2400)
return 48;
if (c2->mode == CODEC2_MODE_1400)
\*---------------------------------------------------------------------------*/
-int codec2_samples_per_frame(struct CODEC2 *c2) {
+int WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *c2) {
if (c2->mode == CODEC2_MODE_2400)
return 160;
if (c2->mode == CODEC2_MODE_1400)
return 0; /* shouldnt get here */
}
-void codec2_encode(struct CODEC2 *c2, unsigned char *bits, short speech[])
+void WIN32SUPPORT codec2_encode(struct CODEC2 *c2, unsigned char *bits, short speech[])
{
assert(c2 != NULL);
assert(
codec2_encode_1200(c2, bits, speech);
}
-void codec2_decode(struct CODEC2 *c2, short speech[], const unsigned char *bits)
+void WIN32SUPPORT codec2_decode(struct CODEC2 *c2, short speech[], const unsigned char *bits)
{
assert(c2 != NULL);
assert(
FILE........: codec2.h
AUTHOR......: David Rowe
- DATE CREATED: 21/8/2010
+ DATE CREATED: 21 August 2010
- Codec2 fully quantised encoder and decoder functions. If you want use
- codec2, these are the functions you need to call.
+ Codec 2 fully quantised encoder and decoder functions. If you want use
+ Codec 2, these are the functions you need to call.
\*---------------------------------------------------------------------------*/
*/
#ifdef __cplusplus
-extern "C" {
+ extern "C" {
#endif
+
#ifndef __CODEC2__
#define __CODEC2__
+#ifdef __WIN32__
+#ifdef __BUILDING_DLL__
+#define WIN32SUPPORT __declspec(dllexport) __stdcall
+#else
+#define WIN32SUPPORT __declspec(dllimport) __stdcall
+#endif
+#else
+#define WIN32SUPPORT
+#endif
+
#define CODEC2_MODE_2400 0
#define CODEC2_MODE_1400 1
#define CODEC2_MODE_1200 2
struct CODEC2;
-struct CODEC2 *codec2_create(int mode);
-void codec2_destroy(struct CODEC2 *codec2_state);
-void codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]);
-void codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits);
-int codec2_samples_per_frame(struct CODEC2 *codec2_state);
-int codec2_bits_per_frame(struct CODEC2 *codec2_state);
+struct CODEC2 * WIN32SUPPORT codec2_create(int mode);
+void WIN32SUPPORT codec2_destroy(struct CODEC2 *codec2_state);
+void WIN32SUPPORT codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]);
+void WIN32SUPPORT codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits);
+int WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *codec2_state);
+int WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *codec2_state);
#endif
\*---------------------------------------------------------------------------*/
-struct FDMDV *fdmdv_create(void)
+struct FDMDV * WIN32SUPPORT fdmdv_create(void)
{
struct FDMDV *f;
int c, i, k;
\*---------------------------------------------------------------------------*/
-void fdmdv_destroy(struct FDMDV *fdmdv)
+void WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv)
{
assert(fdmdv != NULL);
free(fdmdv);
\*---------------------------------------------------------------------------*/
-void fdmdv_get_test_bits(struct FDMDV *f, int tx_bits[])
+void WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *f, int tx_bits[])
{
int i;
\*---------------------------------------------------------------------------*/
-void fdmdv_mod(struct FDMDV *fdmdv, COMP tx_fdm[], int tx_bits[], int *sync_bit)
+void WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv, COMP tx_fdm[], int tx_bits[], int *sync_bit)
{
COMP tx_symbols[NC+1];
COMP tx_baseband[NC+1][M];
\*---------------------------------------------------------------------------*/
-void fdmdv_put_test_bits(struct FDMDV *f, int *sync, int *bit_errors, int *ntest_bits, int rx_bits[])
+void WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, int *bit_errors, int *ntest_bits, int rx_bits[])
{
int i,j;
float ber;
\*---------------------------------------------------------------------------*/
-void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[], int *sync_bit, float rx_fdm[], int *nin)
+void WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[], int *sync_bit, float rx_fdm[], int *nin)
{
float foff_coarse, foff_fine;
COMP rx_fdm_fcorr[M+M/P];
\*---------------------------------------------------------------------------*/
-void fdmdv_get_demod_stats(struct FDMDV *fdmdv, struct FDMDV_STATS *fdmdv_stats)
+void WIN32SUPPORT fdmdv_get_demod_stats(struct FDMDV *fdmdv, struct FDMDV_STATS *fdmdv_stats)
{
int c;
\*---------------------------------------------------------------------------*/
-void fdmdv_8_to_48(float out48k[], float in8k[], int n)
+void WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n)
{
int i,j,k,l;
\*---------------------------------------------------------------------------*/
-void fdmdv_48_to_8(float out8k[], float in48k[], int n)
+void WIN32SUPPORT fdmdv_48_to_8(float out8k[], float in48k[], int n)
{
int i,j;
extern "C" {
#endif
+#ifdef __WIN32__
+#ifdef __BUILDING_DLL__
+#define WIN32SUPPORT __declspec(dllexport) __stdcall
+#else
+#define WIN32SUPPORT __declspec(dllimport) __stdcall
+#endif
+#else
+#define WIN32SUPPORT
+#endif
+
#include "comp.h"
#define FDMDV_BITS_PER_FRAME 28 /* 20ms frames, 1400 bit/s */
float clock_offset; /* Estimated tx/rx sample clock offset in ppm */
};
-struct FDMDV *fdmdv_create(void);
-void fdmdv_destroy(struct FDMDV *fdmdv_state);
+struct FDMDV * WIN32SUPPORT fdmdv_create(void);
+void WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state);
-void fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit);
-void fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *sync_bit, float rx_fdm[], int *nin);
+void WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit);
+void WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *sync_bit, float rx_fdm[], int *nin);
-void fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]);
-void fdmdv_put_test_bits(struct FDMDV *f, int *sync, int *bit_errors, int *ntest_bits, int rx_bits[]);
+void WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]);
+void WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, int *bit_errors, int *ntest_bits, int rx_bits[]);
-void fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats);
-void fdmdv_get_waterfall_line(struct FDMDV *fdmdv_state, float magnitudes[], int *magnitude_points);
+void WIN32SUPPORT fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats);
+void WIN32SUPPORT fdmdv_get_waterfall_line(struct FDMDV *fdmdv_state, float magnitudes[], int *magnitude_points);
-void fdmdv_8_to_48(float out48k[], float in8k[], int n);
-void fdmdv_48_to_8(float out8k[], float in48k[], int n);
+void WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n);
+void WIN32SUPPORT fdmdv_48_to_8(float out8k[], float in48k[], int n);
#endif
--- /dev/null
+# Win32 Makefile derived from the fine work of Peter Lawrence:\r
+# http://code.google.com/p/codec2demo/\r
+#\r
+# David Rowe June 2012\r
+#\r
+# This makefile assumes the Linux version has been compiled first to generate\r
+# the machine-generated codebook source files. It is designed to be cross compiled on\r
+# Linux. \r
+# \r
+# TODO - get this integarted into Automake system, such that if i586-mingw32msvc exists\r
+# the Win32 code gets automatically built.\r
+\r
+# uncomment under Windows\r
+#CC_PREFIX = \r
+# uncomment under Linux (to cross-compile for Windows)\r
+CC_PREFIX = i586-mingw32msvc-\r
+\r
+DLLNAME = codec2.dll\r
+LIBNAME = codec2.lib\r
+\r
+CFLAGS = -O2 -Wall -D__WIN32__\r
+\r
+HDRS = ../src/codec2.h ../src/fdmdv.h\r
+\r
+OBJS = dump.o lpc.o nlp.o postfilter.o sine.o codec2.o fdmdv.o fft.o kiss_fft.o interp.o lsp.o phase.o quantise.o pack.o codebook.o codebookd.o codebookvq.o codebookjnd.o codebookjvm.o codebookdt.o codebookge.o\r
+\r
+all: $(DLLNAME) c2demo.exe c2enc.exe c2dec.exe fdmdv_get_test_bits.exe fdmdv_mod.exe fdmdv_demod.exe fdmdv_put_test_bits.exe\r
+\r
+$(DLLNAME): $(OBJS)\r
+ $(CC_PREFIX)gcc -shared -o $(DLLNAME) $(OBJS) -Wl,--out-implib,$(LIBNAME)\r
+\r
+%.o: ../src/%.c $(HDRS) Makefile\r
+ $(CC_PREFIX)gcc $(CFLAGS) -D__BUILDING_DLL__ -c $< -o $@\r
+\r
+c2demo.exe: ../src/c2demo.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< -o $@ $(LIBNAME)\r
+\r
+c2enc.exe: ../src/c2enc.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< -o $@ $(LIBNAME)\r
+\r
+c2dec.exe: ../src/c2dec.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< -o $@ $(LIBNAME)\r
+\r
+fdmdv_get_test_bits.exe: ../src/fdmdv_get_test_bits.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< -o $@ $(LIBNAME)\r
+\r
+fdmdv_mod.exe: ../src/fdmdv_mod.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< -o $@ $(LIBNAME)\r
+\r
+fdmdv_demod.exe: ../src/fdmdv_demod.c ../src/octave.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< ../src/octave.c -o $@ $(LIBNAME)\r
+\r
+fdmdv_put_test_bits.exe: ../src/fdmdv_put_test_bits.c $(DLLNAME) $(LIBNAME)\r
+ $(CC_PREFIX)gcc $(CFLAGS) $< -o $@ $(LIBNAME)\r
+\r
+clean:\r
+ rm -f $(DLLNAME) $(LIBNAME)\r
+ rm -f *.o *.exe\r
+\r