From a725bba8188daa41386d384b842fd126402b4123 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Mon, 16 Sep 2013 10:22:38 +0100 Subject: [PATCH 1/4] autotools: add support for disabling Klatt (--without-klatt/--with-klatt=no) --- Makefile.am | 13 +++++++++---- configure.ac | 18 ++++++++++++++++++ src/klatt.cpp | 6 +----- src/spectseq.cpp | 13 ++++++++++++- src/speech.h | 2 +- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9fa12ce4..c0a81b43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,11 +55,11 @@ libespeak_includedir = $(includedir)/espeak libespeak_include_HEADERS = \ src/speak_lib.h +common_FLAGS = common_SOURCE = \ src/compiledict.cpp \ src/dictionary.cpp \ src/intonation.cpp \ - src/klatt.cpp \ src/mbrowrap.cpp \ src/numbers.cpp \ src/readclause.cpp \ @@ -96,6 +96,11 @@ espeakedit_SOURCE = \ src/voicedlg.cpp \ src/vowelchart.cpp +if OPT_KLATT +common_FLAGS += -DINCLUDE_KLATT +common_SOURCE += src/klatt.cpp +endif + if AUDIO_RUNTIME wave_SOURCE = src/wave.cpp src/wave_pulse.cpp wave_LIBS = -lpulse -lpulse-simple -lportaudio @@ -127,7 +132,7 @@ docs/speak_lib.h: src/speak_lib.h lib_LTLIBRARIES += src/libespeak.la src_libespeak_la_LDFLAGS = -version-info $(SHARED_VERSION) $(wave_LIBS) -lpthread -src_libespeak_la_CXXFLAGS = $(wave_FLAGS) \ +src_libespeak_la_CXXFLAGS = $(common_FLAGS) $(wave_FLAGS) \ -fpic -fvisibility=hidden -D LIBRARY \ -pedantic -fno-exceptions -D PATH_ESPEAK_DATA=\"$(DATADIR)\" src_libespeak_la_SOURCES = $(common_SOURCE) $(libespeak_SOURCE) $(wave_SOURCE) @@ -135,7 +140,7 @@ src_libespeak_la_SOURCES = $(common_SOURCE) $(libespeak_SOURCE) $(wave_SOURCE) bin_PROGRAMS += src/speak src_speak_LDFLAGS = $(wave_LIBS) -lpthread -src_speak_CXXFLAGS = $(wave_FLAGS) +src_speak_CXXFLAGS = $(common_FLAGS) $(wave_FLAGS) src_speak_SOURCES = src/speak.cpp $(common_SOURCE) $(wave_SOURCE) bin_PROGRAMS += src/espeak @@ -146,7 +151,7 @@ src_espeak_SOURCES = src/espeak.cpp bin_PROGRAMS += src/espeakedit src_espeakedit_LDFLAGS = $(wave_LIBS) ${WX_LIBS} -src_espeakedit_CXXFLAGS = ${WX_CXXFLAGS} $(wave_FLAGS) \ +src_espeakedit_CXXFLAGS = ${WX_CXXFLAGS} $(common_FLAGS) $(wave_FLAGS) \ -D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT src_espeakedit_SOURCES = $(common_SOURCE) $(libespeak_SOURCE) $(espeakedit_SOURCE) $(wave_SOURCE) diff --git a/configure.ac b/configure.ac index c096ee60..2ef9b69d 100644 --- a/configure.ac +++ b/configure.ac @@ -124,6 +124,22 @@ AM_CONDITIONAL(AUDIO_PULSEAUDIO, [test x"$AUDIO" = xpulseaudio]) AM_CONDITIONAL(AUDIO_PORTAUDIO, [test x"$AUDIO" = xportaudio]) AM_CONDITIONAL(AUDIO_SADA, [test x"$AUDIO" = xsada]) +dnl ================================================================ +dnl Optional compilation checks. +dnl ================================================================ + +AC_ARG_WITH([klatt], + [AS_HELP_STRING([--with-klatt], [enable the Klatt formant synthesizer @<:@default=yes@:>@])], + []) + +if test "$with_klatt" = "no" ; then + have_klatt=no +else + have_klatt=yes +fi + +AM_CONDITIONAL(OPT_KLATT, [test x"$have_klatt" = xyes]) + dnl ================================================================ dnl wxWidgets checks. dnl ================================================================ @@ -161,4 +177,6 @@ AC_MSG_NOTICE([ portaudio: ${have_portaudio} sada: ${have_sada} audio configuration: ${AUDIO} + + Klatt: ${have_klatt} ]) diff --git a/src/klatt.cpp b/src/klatt.cpp index b15f77c2..90f25194 100644 --- a/src/klatt.cpp +++ b/src/klatt.cpp @@ -1,7 +1,7 @@ - /*************************************************************************** * Copyright (C) 2008 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * + * Copyright (C) 2013 Reece H. Dunn * * * * Based on a re-implementation by: * * (c) 1993,94 Jon Iles and Nick Ing-Simmons * @@ -38,8 +38,6 @@ #include "synthesize.h" #include "voice.h" -#ifdef INCLUDE_KLATT // conditional compilation for the whole file - extern unsigned char *out_ptr; // **JSD extern unsigned char *out_start; extern unsigned char *out_end; @@ -1409,5 +1407,3 @@ for(ix=0; ix<256; ix++) kt_frame.AVpdb = 0; kt_frame.Gain0 = 62; // 60 } // end of KlattInit - -#endif // INCLUDE_KLATT diff --git a/src/spectseq.cpp b/src/spectseq.cpp index c74fdcba..c84fab24 100644 --- a/src/spectseq.cpp +++ b/src/spectseq.cpp @@ -1,6 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2007 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * + * Copyright (C) 2013 Reece H. Dunn * * * * 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 * @@ -35,13 +36,15 @@ #define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough +#ifdef INCLUDE_KLATT extern void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v, int control); extern int Wavegen_Klatt(int resume); +extern void KlattReset(int control); +#endif extern void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v); extern int Wavegen(); extern void CloseWaveFile2(); -extern void KlattReset(int control); extern FILE *f_wave; static int frame_width; @@ -115,9 +118,11 @@ void MakeWaveFile(int synthesis_method) out_ptr = out_start = wav_outbuf; out_end = &wav_outbuf[sizeof(wav_outbuf)]; +#ifdef INCLUDE_KLATT if(synthesis_method == 1) result = Wavegen_Klatt(resume); else +#endif result = Wavegen(); if(f_wave != NULL) @@ -972,7 +977,9 @@ static void SetSynth_mS(int length_mS, SpectFrame *sp1, SpectFrame *sp2, peak_t if(voice->klattv[0]) { +#ifdef INCLUDE_KLATT SetSynth_Klatt((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice, control); // convert mS to samples +#endif } else { @@ -1004,7 +1011,9 @@ void SpectSeq::MakeWave(int start, int end, PitchEnvelope &pitch) if(voice->klattv[0]) { synthesizer_type = 1; +#ifdef INCLUDE_KLATT KlattReset(2); +#endif } SpeakNextClause(NULL,NULL,2); // stop speaking file @@ -1120,7 +1129,9 @@ void SpectFrame::MakeWaveF(int control, PitchEnvelope &pitche, int amplitude, in if(voice->klattv[0]) { synthesizer_type = 1; +#ifdef INCLUDE_KLATT KlattReset(2); +#endif } SpeakNextClause(NULL,NULL,2); // stop speaking file diff --git a/src/speech.h b/src/speech.h index 02886ed6..180c8544 100644 --- a/src/speech.h +++ b/src/speech.h @@ -1,6 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2007 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * + * Copyright (C) 2013 Reece H. Dunn * * * * 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 * @@ -23,7 +24,6 @@ #include // conditional compilation options -#define INCLUDE_KLATT #define INCLUDE_MBROLA #define INCLUDE_SONIC From 83df50a40ffd16bf44a6cd1eb8ad2785aa9e529e Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Mon, 16 Sep 2013 10:37:45 +0100 Subject: [PATCH 2/4] autotools: add support for disabling MBROLA (--without-mbrola/--with-mbrola=no) --- Makefile.am | 6 +++++- configure.ac | 14 +++++++++++++- src/mbrowrap.cpp | 4 +--- src/speech.h | 1 - 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index c0a81b43..7d172b38 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,7 +60,6 @@ common_SOURCE = \ src/compiledict.cpp \ src/dictionary.cpp \ src/intonation.cpp \ - src/mbrowrap.cpp \ src/numbers.cpp \ src/readclause.cpp \ src/phonemelist.cpp \ @@ -101,6 +100,11 @@ common_FLAGS += -DINCLUDE_KLATT common_SOURCE += src/klatt.cpp endif +if OPT_MBROLA +common_FLAGS += -DINCLUDE_MBROLA +common_SOURCE += src/mbrowrap.cpp +endif + if AUDIO_RUNTIME wave_SOURCE = src/wave.cpp src/wave_pulse.cpp wave_LIBS = -lpulse -lpulse-simple -lportaudio diff --git a/configure.ac b/configure.ac index 2ef9b69d..3d7d0e93 100644 --- a/configure.ac +++ b/configure.ac @@ -138,7 +138,18 @@ else have_klatt=yes fi -AM_CONDITIONAL(OPT_KLATT, [test x"$have_klatt" = xyes]) +AC_ARG_WITH([mbrola], + [AS_HELP_STRING([--with-mbrola], [enable the MBROLA speech synthesizer @<:@default=yes@:>@])], + []) + +if test "$with_mbrola" = "no" ; then + have_mbrola=no +else + have_mbrola=yes +fi + +AM_CONDITIONAL(OPT_KLATT, [test x"$have_klatt" = xyes]) +AM_CONDITIONAL(OPT_MBROLA, [test x"$have_mbrola" = xyes]) dnl ================================================================ dnl wxWidgets checks. @@ -179,4 +190,5 @@ AC_MSG_NOTICE([ audio configuration: ${AUDIO} Klatt: ${have_klatt} + MBROLA: ${have_mbrola} ]) diff --git a/src/mbrowrap.cpp b/src/mbrowrap.cpp index bc5c7436..aced2c2c 100644 --- a/src/mbrowrap.cpp +++ b/src/mbrowrap.cpp @@ -3,6 +3,7 @@ * providing a subset of the API from the Windows mbrola DLL. * * Copyright (C) 2010 by Nicolas Pitre + * Copyright (C) 2013 Reece H. Dunn * * 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 @@ -16,7 +17,6 @@ */ #include "speech.h" -#ifdef INCLUDE_MBROLA #include #include @@ -609,5 +609,3 @@ void resetError_MBR(void) { mbr_errorbuf[0] = 0; } - -#endif // INCLUDE_MBROLA diff --git a/src/speech.h b/src/speech.h index 180c8544..5cb82cac 100644 --- a/src/speech.h +++ b/src/speech.h @@ -24,7 +24,6 @@ #include // conditional compilation options -#define INCLUDE_MBROLA #define INCLUDE_SONIC #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN From 00861d3bc3e3f9136ab00aa316f6d8f8ec73c82a Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Mon, 16 Sep 2013 11:14:58 +0100 Subject: [PATCH 3/4] autotools: add support for disabling libsonic (--without-sonic/--with-sonic=no) --- Makefile.am | 6 +++++- configure.ac | 12 ++++++++++++ src/sonic.cpp | 2 -- src/speech.h | 3 --- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7d172b38..9149e6dc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,7 +64,6 @@ common_SOURCE = \ src/readclause.cpp \ src/phonemelist.cpp \ src/setlengths.cpp \ - src/sonic.cpp \ src/synthdata.cpp \ src/synthesize.cpp \ src/synth_mbrola.cpp \ @@ -105,6 +104,11 @@ common_FLAGS += -DINCLUDE_MBROLA common_SOURCE += src/mbrowrap.cpp endif +if OPT_SONIC +common_FLAGS += -DINCLUDE_SONIC +common_SOURCE += src/sonic.cpp +endif + if AUDIO_RUNTIME wave_SOURCE = src/wave.cpp src/wave_pulse.cpp wave_LIBS = -lpulse -lpulse-simple -lportaudio diff --git a/configure.ac b/configure.ac index 3d7d0e93..ecbc08b9 100644 --- a/configure.ac +++ b/configure.ac @@ -148,8 +148,19 @@ else have_mbrola=yes fi +AC_ARG_WITH([sonic], + [AS_HELP_STRING([--with-sonic], [enable the sonic library to speed up the audio @<:@default=yes@:>@])], + []) + +if test "$with_sonic" = "no" ; then + have_sonic=no +else + have_sonic=yes +fi + AM_CONDITIONAL(OPT_KLATT, [test x"$have_klatt" = xyes]) AM_CONDITIONAL(OPT_MBROLA, [test x"$have_mbrola" = xyes]) +AM_CONDITIONAL(OPT_SONIC, [test x"$have_sonic" = xyes]) dnl ================================================================ dnl wxWidgets checks. @@ -191,4 +202,5 @@ AC_MSG_NOTICE([ Klatt: ${have_klatt} MBROLA: ${have_mbrola} + Sonic: ${have_sonic} ]) diff --git a/src/sonic.cpp b/src/sonic.cpp index 82febba5..99252d09 100644 --- a/src/sonic.cpp +++ b/src/sonic.cpp @@ -28,7 +28,6 @@ #include "speech.h" #include "sonic.h" -#ifdef INCLUDE_SONIC struct sonicStreamStruct { short *inputBuffer; @@ -969,4 +968,3 @@ int sonicChangeShortSpeed( sonicDestroyStream(stream); return numSamples; } -#endif // INCLUDE_SONIC diff --git a/src/speech.h b/src/speech.h index 5cb82cac..60c045aa 100644 --- a/src/speech.h +++ b/src/speech.h @@ -23,9 +23,6 @@ #include -// conditional compilation options -#define INCLUDE_SONIC - #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN #define ARCH_BIG #endif From 6dd5529dd8d16659f03c476158955e1ec3d6d62a Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Mon, 16 Sep 2013 12:14:26 +0100 Subject: [PATCH 4/4] autotools: add support for disabling async command support (--without-async/--with-async=no) --- Makefile.am | 16 +++++++++++----- configure.ac | 12 ++++++++++++ src/espeak_command.cpp | 6 ++---- src/event.cpp | 8 ++------ src/fifo.cpp | 8 ++------ src/speech.h | 5 ----- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9149e6dc..7feca9f4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,11 +72,9 @@ common_SOURCE = \ src/voices.cpp \ src/wavegen.cpp +libespeak_FLAGS = libespeak_SOURCE = \ src/speak_lib.cpp \ - src/espeak_command.cpp \ - src/event.cpp \ - src/fifo.cpp \ src/debug.cpp espeakedit_SOURCE = \ @@ -109,6 +107,14 @@ common_FLAGS += -DINCLUDE_SONIC common_SOURCE += src/sonic.cpp endif +if OPT_ASYNC +libespeak_FLAGS += -DUSE_ASYNC +libespeak_SOURCE += \ + src/espeak_command.cpp \ + src/event.cpp \ + src/fifo.cpp +endif + if AUDIO_RUNTIME wave_SOURCE = src/wave.cpp src/wave_pulse.cpp wave_LIBS = -lpulse -lpulse-simple -lportaudio @@ -140,7 +146,7 @@ docs/speak_lib.h: src/speak_lib.h lib_LTLIBRARIES += src/libespeak.la src_libespeak_la_LDFLAGS = -version-info $(SHARED_VERSION) $(wave_LIBS) -lpthread -src_libespeak_la_CXXFLAGS = $(common_FLAGS) $(wave_FLAGS) \ +src_libespeak_la_CXXFLAGS = $(common_FLAGS) $(libespeak_FLAGS) $(wave_FLAGS) \ -fpic -fvisibility=hidden -D LIBRARY \ -pedantic -fno-exceptions -D PATH_ESPEAK_DATA=\"$(DATADIR)\" src_libespeak_la_SOURCES = $(common_SOURCE) $(libespeak_SOURCE) $(wave_SOURCE) @@ -159,7 +165,7 @@ src_espeak_SOURCES = src/espeak.cpp bin_PROGRAMS += src/espeakedit src_espeakedit_LDFLAGS = $(wave_LIBS) ${WX_LIBS} -src_espeakedit_CXXFLAGS = ${WX_CXXFLAGS} $(common_FLAGS) $(wave_FLAGS) \ +src_espeakedit_CXXFLAGS = ${WX_CXXFLAGS} $(common_FLAGS) $(libespeak_FLAGS) $(wave_FLAGS) \ -D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT src_espeakedit_SOURCES = $(common_SOURCE) $(libespeak_SOURCE) $(espeakedit_SOURCE) $(wave_SOURCE) diff --git a/configure.ac b/configure.ac index ecbc08b9..a4ae96cd 100644 --- a/configure.ac +++ b/configure.ac @@ -158,9 +158,20 @@ else have_sonic=yes fi +AC_ARG_WITH([async], + [AS_HELP_STRING([--with-async], [enable support for async command processing @<:@default=yes@:>@])], + []) + +if test "$with_async" = "no" ; then + have_async=no +else + have_async=yes +fi + AM_CONDITIONAL(OPT_KLATT, [test x"$have_klatt" = xyes]) AM_CONDITIONAL(OPT_MBROLA, [test x"$have_mbrola" = xyes]) AM_CONDITIONAL(OPT_SONIC, [test x"$have_sonic" = xyes]) +AM_CONDITIONAL(OPT_ASYNC, [test x"$have_async" = xyes]) dnl ================================================================ dnl wxWidgets checks. @@ -203,4 +214,5 @@ AC_MSG_NOTICE([ Klatt: ${have_klatt} MBROLA: ${have_mbrola} Sonic: ${have_sonic} + Async: ${have_async} ]) diff --git a/src/espeak_command.cpp b/src/espeak_command.cpp index d8460c75..885b534b 100644 --- a/src/espeak_command.cpp +++ b/src/espeak_command.cpp @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2007, Gilles Casse * + * Copyright (C) 2013 Reece H. Dunn * * * * 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 * @@ -16,11 +17,10 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "speech.h" -#ifdef USE_ASYNC // This source file is only used for asynchronious modes +#include "speech.h" #include "espeak_command.h" #include #include @@ -702,6 +702,4 @@ void display_espeak_command( t_espeak_command* the_command) } #endif } - -#endif //> diff --git a/src/event.cpp b/src/event.cpp index fe2aa9b0..570c8f3d 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2007, Gilles Casse * + * Copyright (C) 2013 Reece H. Dunn * * * * 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 * @@ -17,9 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "speech.h" - -#ifdef USE_ASYNC // This source file is only used for asynchronious modes @@ -33,6 +31,7 @@ #include #include +#include "speech.h" #include "speak_lib.h" #include "event.h" #include "wave.h" @@ -723,7 +722,4 @@ ENTER("event_terminate"); init(); // purge event } } - -#endif //> - diff --git a/src/fifo.cpp b/src/fifo.cpp index bf9cc83f..2c6cad54 100644 --- a/src/fifo.cpp +++ b/src/fifo.cpp @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2007, Gilles Casse * + * Copyright (C) 2013 Reece H. Dunn * * * * 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 * @@ -16,12 +17,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "speech.h" -#ifdef USE_ASYNC // This source file is only used for asynchronious modes - // @@ -35,6 +33,7 @@ #include #include +#include "speech.h" #include "fifo.h" #include "wave.h" #include "debug.h" @@ -601,7 +600,4 @@ void fifo_terminate() init(0); // purge fifo } - -#endif //> - diff --git a/src/speech.h b/src/speech.h index 60c045aa..cbb48295 100644 --- a/src/speech.h +++ b/src/speech.h @@ -42,12 +42,7 @@ #define __cdecl //#define ESPEAK_API extern "C" -#ifdef LIBRARY -#define USE_ASYNC -#endif - #ifdef _ESPEAKEDIT -#define USE_ASYNC #define LOG_FRAMES // write keyframe info to log-espeakedit #endif