83bee1
diff -up festival/lib/init.scm.pulse festival/lib/init.scm
83bee1
--- festival/lib/init.scm.pulse	2009-09-29 02:05:53.156687751 -0400
83bee1
+++ festival/lib/init.scm	2009-09-29 02:14:18.911692694 -0400
83bee1
@@ -77,6 +77,9 @@
83bee1
 ;;;  Some default parameters
83bee1
 (Parameter.def 'Wavefiletype 'riff)
83bee1
 
83bee1
+;;; default to pulseaudio
83bee1
+(Parameter.def 'Audio_Method 'pulseaudio)
83bee1
+
83bee1
 ;;; Set default audio method
83bee1
 (cond
83bee1
  ((member 'nas *modules*)
83bee1
diff -up festival/speech_tools/audio/audioP.h.pulse festival/speech_tools/audio/audioP.h
83bee1
--- festival/speech_tools/audio/audioP.h.pulse	2004-07-15 19:03:04.000000000 -0400
83bee1
+++ festival/speech_tools/audio/audioP.h	2009-09-29 02:05:53.353695375 -0400
83bee1
@@ -40,6 +40,7 @@
83bee1
 #define __AUDIOP_H__
83bee1
 
83bee1
 int play_nas_wave(EST_Wave &inwave, EST_Option &al);
83bee1
+int play_pulse_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 int play_esd_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 int play_sun16_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 int play_voxware_wave(EST_Wave &inwave, EST_Option &al);
83bee1
@@ -49,6 +50,7 @@ int play_irix_wave(EST_Wave &inwave, EST
83bee1
 int play_macosx_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 
83bee1
 int record_nas_wave(EST_Wave &inwave, EST_Option &al);
83bee1
+int record_pulse_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 int record_esd_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 int record_sun16_wave(EST_Wave &inwave, EST_Option &al);
83bee1
 int record_voxware_wave(EST_Wave &inwave, EST_Option &al);
83bee1
diff -up festival/speech_tools/audio/gen_audio.cc.pulse festival/speech_tools/audio/gen_audio.cc
83bee1
--- festival/speech_tools/audio/gen_audio.cc.pulse	2004-09-30 08:53:35.000000000 -0400
83bee1
+++ festival/speech_tools/audio/gen_audio.cc	2009-09-29 02:05:53.354687890 -0400
83bee1
@@ -89,6 +89,8 @@ int play_wave(EST_Wave &inwave, EST_Opti
83bee1
     {
83bee1
 	if (nas_supported)
83bee1
 	    protocol = "netaudio";  // the default protocol
83bee1
+	else if (pulse_supported)
83bee1
+	    protocol = "pulseaudio";
83bee1
 	else if (esd_supported)
83bee1
 	    protocol = "esdaudio";
83bee1
 	else if (sun16_supported)
83bee1
@@ -111,6 +113,8 @@ int play_wave(EST_Wave &inwave, EST_Opti
83bee1
 
83bee1
     if (upcase(protocol) == "NETAUDIO")
83bee1
 	return play_nas_wave(*toplay,al);
83bee1
+    else if (upcase(protocol) == "PULSEAUDIO")
83bee1
+	return play_pulse_wave(*toplay,al);
83bee1
     else if (upcase(protocol) == "ESDAUDIO")
83bee1
 	return play_esd_wave(*toplay,al);
83bee1
     else if (upcase(protocol) == "SUNAUDIO")
83bee1
@@ -246,6 +250,8 @@ EST_String options_supported_audio(void)
83bee1
 	audios += " netaudio";
83bee1
     else if (esd_supported)
83bee1
 	audios += " esdaudio";
83bee1
+    if (pulse_supported)
83bee1
+	audios += " pulseaudio";
83bee1
     if (sun16_supported)
83bee1
 	audios += " sun16audio";
83bee1
     if (freebsd16_supported)
83bee1
@@ -286,8 +292,10 @@ int record_wave(EST_Wave &wave, EST_Opti
83bee1
     {
83bee1
 	if (nas_supported)
83bee1
 	    protocol = "netaudio";  // the default protocol
83bee1
+	else if (pulse_supported)
83bee1
+	    protocol = "pulseaudio";
83bee1
 	else if (esd_supported)
83bee1
-	    protocol = "esdaudio";  // the default protocol
83bee1
+	    protocol = "esdaudio";
83bee1
 	else if (sun16_supported)
83bee1
 	    protocol = "sun16audio";
83bee1
 	else if (freebsd16_supported)
83bee1
@@ -306,6 +314,8 @@ int record_wave(EST_Wave &wave, EST_Opti
83bee1
 
83bee1
     if (upcase(protocol) == "NETAUDIO")
83bee1
 	return record_nas_wave(wave,al);
83bee1
+    else if (upcase(protocol) == "PULSEAUDIO")
83bee1
+	return record_pulse_wave(wave,al);
83bee1
     else if (upcase(protocol) == "ESDAUDIO")
83bee1
         return record_esd_wave(wave,al);
83bee1
     else if (upcase(protocol) == "SUN16AUDIO")
83bee1
diff -up festival/speech_tools/audio/Makefile.pulse festival/speech_tools/audio/Makefile
83bee1
--- festival/speech_tools/audio/Makefile.pulse	2004-07-15 19:03:04.000000000 -0400
83bee1
+++ festival/speech_tools/audio/Makefile	2009-09-29 02:05:53.355692417 -0400
83bee1
@@ -44,7 +44,7 @@ LOCAL_DEFAULT_LIBRARY = estbase
83bee1
 H = audioP.h
83bee1
 CPPSRCS = gen_audio.cc nas.cc esd.cc sun16audio.cc voxware.cc  \
83bee1
           mplayer.cc win32audio.cc irixaudio.cc os2audio.cc \
83bee1
-          macosxaudio.cc
83bee1
+          macosxaudio.cc pulseaudio.cc
83bee1
 
83bee1
 SRCS = $(CPPSRCS)
83bee1
 OBJS = $(CPPSRCS:.cc=.o)
83bee1
diff -up /dev/null festival/speech_tools/audio/pulseaudio.cc
83bee1
--- /dev/null	2009-09-29 00:23:01.118964058 -0400
83bee1
+++ festival/speech_tools/audio/pulseaudio.cc	2009-09-29 02:05:53.357688202 -0400
83bee1
@@ -0,0 +1,134 @@
83bee1
+/*************************************************************************/
83bee1
+/*                                                                       */
83bee1
+/*                Centre for Speech Technology Research                  */
83bee1
+/*                     University of Edinburgh, UK                       */
83bee1
+/*                      Copyright (c) 1997,1998                          */
83bee1
+/*                            Red Hat, Inc.                              */
83bee1
+/*                         Copyright (c) 2008                            */
83bee1
+/*                        All Rights Reserved.                           */
83bee1
+/*                                                                       */
83bee1
+/*  Permission is hereby granted, free of charge, to use and distribute  */
83bee1
+/*  this software and its documentation without restriction, including   */
83bee1
+/*  without limitation the rights to use, copy, modify, merge, publish,  */
83bee1
+/*  distribute, sublicense, and/or sell copies of this work, and to      */
83bee1
+/*  permit persons to whom this work is furnished to do so, subject to   */
83bee1
+/*  the following conditions:                                            */
83bee1
+/*   1. The code must retain the above copyright notice, this list of    */
83bee1
+/*      conditions and the following disclaimer.                         */
83bee1
+/*   2. Any modifications must be clearly marked as such.                */
83bee1
+/*   3. Original authors' names are not deleted.                         */
83bee1
+/*   4. The authors' names are not used to endorse or promote products   */
83bee1
+/*      derived from this software without specific prior written        */
83bee1
+/*      permission.                                                      */
83bee1
+/*                                                                       */
83bee1
+/*  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        */
83bee1
+/*  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      */
83bee1
+/*  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   */
83bee1
+/*  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     */
83bee1
+/*  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    */
83bee1
+/*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   */
83bee1
+/*  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          */
83bee1
+/*  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       */
83bee1
+/*  THIS SOFTWARE.                                                       */
83bee1
+/*                                                                       */
83bee1
+/*************************************************************************/
83bee1
+/*                Author :  Michal Schmidt                               */
83bee1
+/*                Date   :  November 2008                                */
83bee1
+/*-----------------------------------------------------------------------*/
83bee1
+/*  Optional support for PulseAudio                                      */
83bee1
+/*=======================================================================*/
83bee1
+
83bee1
+#include "EST_Wave.h"
83bee1
+#include "EST_Option.h"
83bee1
+#include "audioP.h"
83bee1
+
83bee1
+#ifdef SUPPORT_PULSE
83bee1
+
83bee1
+#include <pulse/simple.h>
83bee1
+#include <pulse/error.h>
83bee1
+
83bee1
+int pulse_supported = TRUE;
83bee1
+const static char *err_prefix = "Pulseaudio: ";
83bee1
+
83bee1
+static int transfer_pulse_wave(EST_Wave &inwave, EST_Option &al, int record)
83bee1
+{
83bee1
+    short *waveform;
83bee1
+    int num_samples;
83bee1
+    int err, pa_ret;
83bee1
+    int ret = -1;
83bee1
+    pa_simple *s = NULL;
83bee1
+    pa_sample_spec ss;
83bee1
+
83bee1
+    ss.format   = PA_SAMPLE_S16NE;
83bee1
+    ss.channels = 1;
83bee1
+    ss.rate     = inwave.sample_rate();
83bee1
+
83bee1
+    waveform    = inwave.values().memory();
83bee1
+    num_samples = inwave.num_samples();
83bee1
+
83bee1
+    s = pa_simple_new(NULL,           // Use the default server.
83bee1
+	"Festival",                   // Our application's name.
83bee1
+	record ? PA_STREAM_RECORD : PA_STREAM_PLAYBACK,
83bee1
+	NULL,                         // Use the default device.
83bee1
+	record ? "Record" : "Speech", // Description of our stream.
83bee1
+	&ss,                // Our sample format.
83bee1
+	NULL,               // Use default channel map
83bee1
+	NULL,               // Use default buffering attributes.
83bee1
+	&err;;
83bee1
+
83bee1
+    if (!s) {
83bee1
+	cerr << err_prefix << pa_strerror(err) << endl;
83bee1
+	goto finish;
83bee1
+    }
83bee1
+
83bee1
+    pa_ret = record ?
83bee1
+	pa_simple_read (s, waveform, num_samples*sizeof(short), &err) :
83bee1
+	pa_simple_write(s, waveform, num_samples*sizeof(short), &err;;
83bee1
+
83bee1
+    if (pa_ret < 0) {
83bee1
+	cerr << err_prefix << pa_strerror(err) << endl;
83bee1
+	goto finish;
83bee1
+    }
83bee1
+
83bee1
+    if (!record && pa_simple_drain(s, &err) < 0) {
83bee1
+	cerr << err_prefix << pa_strerror(err) << endl;
83bee1
+	goto finish;
83bee1
+    }
83bee1
+
83bee1
+    ret = 1;
83bee1
+finish:
83bee1
+    if (s)
83bee1
+	pa_simple_free(s);
83bee1
+    return ret;
83bee1
+}
83bee1
+
83bee1
+int play_pulse_wave(EST_Wave &inwave, EST_Option &al)
83bee1
+{
83bee1
+	return transfer_pulse_wave(inwave, al, 0);
83bee1
+}
83bee1
+
83bee1
+int record_pulse_wave(EST_Wave &inwave, EST_Option &al)
83bee1
+{
83bee1
+	return transfer_pulse_wave(inwave, al, 1);
83bee1
+}
83bee1
+
83bee1
+#else
83bee1
+int pulse_supported = FALSE;
83bee1
+
83bee1
+int play_pulse_wave(EST_Wave &inwave, EST_Option &al)
83bee1
+{
83bee1
+    (void)inwave;
83bee1
+    (void)al;
83bee1
+    cerr << "Audio: pulse not compiled in this version" << endl;
83bee1
+    return -1;
83bee1
+}
83bee1
+
83bee1
+int record_pulse_wave(EST_Wave &inwave, EST_Option &al)
83bee1
+{
83bee1
+    (void)inwave;
83bee1
+    (void)al;
83bee1
+    cerr << "Audio: pulse not compiled in this version" << endl;
83bee1
+    return -1;
83bee1
+}
83bee1
+
83bee1
+#endif
83bee1
diff -up festival/speech_tools/config/config.in.pulse festival/speech_tools/config/config.in
83bee1
--- festival/speech_tools/config/config.in.pulse	2009-09-29 02:05:53.045693311 -0400
83bee1
+++ festival/speech_tools/config/config.in	2009-09-29 02:05:53.358687421 -0400
83bee1
@@ -79,6 +79,9 @@ OPTIMISE_sigpr = 3
83bee1
 ## NCD's network audio system, This is recommended.
83bee1
 # INCLUDE_MODULES += NAS_AUDIO
83bee1
 
83bee1
+## PulseAudio sound server
83bee1
+INCLUDE_MODULES += PULSE_AUDIO
83bee1
+
83bee1
 ## Elightenment Sound Demon, for KDE etc.
83bee1
 # INCLUDE_MODULES += ESD_AUDIO
83bee1
 
83bee1
diff -up festival/speech_tools/config/modules/Makefile.pulse festival/speech_tools/config/modules/Makefile
83bee1
--- festival/speech_tools/config/modules/Makefile.pulse	2004-07-15 19:03:05.000000000 -0400
83bee1
+++ festival/speech_tools/config/modules/Makefile	2009-09-29 02:05:53.359687618 -0400
83bee1
@@ -41,7 +41,8 @@ RULESETS = efence.mak dmalloc.mak debugg
83bee1
 	psola_tm.mak editline.mak tcl.mak \
83bee1
 	freebsd16_audio.mak irix_audio.mak linux16_audio.mak \
83bee1
 	sun16_audio.mak win32_audio.mak macosx_audio.mak \
83bee1
-	mplayer_audio.mak nas_audio.mak esd_audio.mak
83bee1
+	mplayer_audio.mak nas_audio.mak esd_audio.mak \
83bee1
+	pulse_audio.mak
83bee1
 
83bee1
 FILES = Makefile descriptions $(RULESETS) 
83bee1
 
83bee1
diff -up /dev/null festival/speech_tools/config/modules/pulse_audio.mak
83bee1
--- /dev/null	2009-09-29 00:23:01.118964058 -0400
83bee1
+++ festival/speech_tools/config/modules/pulse_audio.mak	2009-09-29 02:05:53.361688082 -0400
83bee1
@@ -0,0 +1,9 @@
83bee1
+## Definitions for PulseAudio
83bee1
+
83bee1
+INCLUDE_PULSE_AUDIO=1
83bee1
+
83bee1
+MOD_DESC_PULSE_AUDIO=PulseAudio support
83bee1
+
83bee1
+AUDIO_DEFINES += -DSUPPORT_PULSE
83bee1
+AUDIO_INCLUDES += -I$(PULSE_INCLUDE)
83bee1
+MODULE_LIBS += -lpulse-simple
83bee1
diff -up festival/speech_tools/config/project.mak.pulse festival/speech_tools/config/project.mak
83bee1
--- festival/speech_tools/config/project.mak.pulse	2009-09-29 02:05:53.104720729 -0400
83bee1
+++ festival/speech_tools/config/project.mak	2009-09-29 02:05:53.362687372 -0400
83bee1
@@ -60,7 +60,7 @@ MODULE_DIRECTORY = $(TOP)
83bee1
 # List of all known modules
83bee1
 
83bee1
 DISTRIBUTED_MODULES = \
83bee1
-	NAS_AUDIO ESD_AUDIO NATIVE_AUDIO MPLAYER_AUDIO \
83bee1
+	NAS_AUDIO PULSE_AUDIO ESD_AUDIO NATIVE_AUDIO MPLAYER_AUDIO \
83bee1
 	EDITLINE \
83bee1
 	SIOD WAGON SCFG WFST OLS \
83bee1
 	JAVA JAVA_CPP JAVA_MEDIA \
83bee1
@@ -109,6 +109,7 @@ PROJECT_LIBRARY_VERSION_estbase = $(PROJ
83bee1
 PROJECT_LIBRARY_VERSION_eststring = 1.2
83bee1
 PROJECT_LIBRARY_VERSION_estjava = $(PROJECT_VERSION).1
83bee1
 
83bee1
+PROJECT_LIBRARY_NEEDS_SYSLIBS_estbase=1
83bee1
 PROJECT_LIBRARY_NEEDS_SYSLIBS_estjava=1
83bee1
 
83bee1
 PROJECT_DEFAULT_LIBRARY = estools
83bee1
diff -up festival/speech_tools/config/systems/default.mak.pulse festival/speech_tools/config/systems/default.mak
83bee1
--- festival/speech_tools/config/systems/default.mak.pulse	2005-07-17 09:06:49.000000000 -0400
83bee1
+++ festival/speech_tools/config/systems/default.mak	2009-09-29 02:05:53.364688115 -0400
83bee1
@@ -61,6 +61,12 @@ NAS_INCLUDE = /usr/X11R6/include
83bee1
 NAS_LIB = /usr/X11R6/lib
83bee1
 
83bee1
 ###########################################################################
83bee1
+## Where to find PulseAudio
83bee1
+
83bee1
+PULSE_INCLUDE = /usr/include
83bee1
+PULSE_LIB = /usr/lib
83bee1
+
83bee1
+###########################################################################
83bee1
 ## Where to find Enlightenment Speech Demon
83bee1
 
83bee1
 ESD_INCLUDE = /usr/local/include
83bee1
diff -up festival/speech_tools/include/EST_audio.h.pulse festival/speech_tools/include/EST_audio.h
83bee1
--- festival/speech_tools/include/EST_audio.h.pulse	2004-07-15 19:03:05.000000000 -0400
83bee1
+++ festival/speech_tools/include/EST_audio.h	2009-09-29 02:05:53.365689290 -0400
83bee1
@@ -43,6 +43,7 @@
83bee1
 #include "EST_Option.h"
83bee1
 
83bee1
 extern int nas_supported;
83bee1
+extern int pulse_supported;
83bee1
 extern int esd_supported;
83bee1
 extern int sun16_supported;
83bee1
 extern int freebsd16_supported;