aboutsummaryrefslogtreecommitdiff
path: root/audio/rsynth
diff options
context:
space:
mode:
authorTobias Kortkamp <tobik@FreeBSD.org>2017-05-30 16:18:54 +0000
committerTobias Kortkamp <tobik@FreeBSD.org>2017-05-30 16:18:54 +0000
commitb910ce6befcb6db688969511f5e5d9f22ed92dcc (patch)
treea7f71174c9e076e1c846a6b264eccd86cd8cbaf6 /audio/rsynth
parent98885b32653c44aaf60126152077584519b75fc2 (diff)
downloadports-b910ce6befcb6db688969511f5e5d9f22ed92dcc.tar.gz
ports-b910ce6befcb6db688969511f5e5d9f22ed92dcc.zip
Notes
Diffstat (limited to 'audio/rsynth')
-rw-r--r--audio/rsynth/Makefile23
-rw-r--r--audio/rsynth/files/ossplay.c (renamed from audio/rsynth/files/freebsdplay.c)84
-rw-r--r--audio/rsynth/files/patch-Makefile.in11
-rw-r--r--audio/rsynth/files/patch-configure.in2
-rw-r--r--audio/rsynth/files/sndioplay.c112
-rw-r--r--audio/rsynth/pkg-plist6
6 files changed, 163 insertions, 75 deletions
diff --git a/audio/rsynth/Makefile b/audio/rsynth/Makefile
index fdf82b18215b..4519037ab93a 100644
--- a/audio/rsynth/Makefile
+++ b/audio/rsynth/Makefile
@@ -3,7 +3,7 @@
PORTNAME= rsynth
PORTVERSION= 2.0
-PORTREVISION= 4
+PORTREVISION= 5
CATEGORIES= audio accessibility
MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/ \
ftp://ftp.enst.fr/pub/unix/multimedia/
@@ -11,14 +11,27 @@ MASTER_SITES= ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/ \
MAINTAINER= ports@FreeBSD.org
COMMENT= Speech synthesizer
-LIB_DEPENDS= libgdbm.so:databases/gdbm \
- libaudio.so:audio/nas
+LICENSE= PD
+
+OPTIONS_DEFINE= DB NAS SNDIO
+OPTIONS_SUB= yes
+
+DB_DESC= Build dictionary database tools
+DB_LIB_DEPENDS= libgdbm.so:databases/gdbm
+DB_CONFIGURE_ENV_OFF= ac_cv_lib_gdbm_gdbm_open=no
+NAS_LIB_DEPENDS= libaudio.so:audio/nas
+NAS_CONFIGURE_ENV_OFF= ac_cv_header_audio_audiolib_h=no
+SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio
+SNDIO_MAKE_ENV= SAY_LIBS=-lsndio
USES= autoreconf
GNU_CONFIGURE= yes
-pre-configure:
- @${CP} ${FILESDIR}/freebsdplay.c ${WRKSRC}/config/freebsdplay.c
+pre-configure-SNDIO-on:
+ @${CP} ${FILESDIR}/sndioplay.c ${WRKSRC}/config/freebsdplay.c
+
+pre-configure-SNDIO-off:
+ @${CP} ${FILESDIR}/ossplay.c ${WRKSRC}/config/freebsdplay.c
post-configure:
@${REINPLACE_CMD} -E 's,(BIN|LIB)_DIR\),DESTDIR\)$$\(&,g' \
diff --git a/audio/rsynth/files/freebsdplay.c b/audio/rsynth/files/ossplay.c
index 3b8a63335220..0a20a1d7e69f 100644
--- a/audio/rsynth/files/freebsdplay.c
+++ b/audio/rsynth/files/ossplay.c
@@ -29,57 +29,43 @@
#define SAMP_RATE 8000
long samp_rate = SAMP_RATE;
-/* Audio Parameters */
-
static int dev_fd = -1;
- /* file descriptor for audio device */
char *dev_file = "/dev/dsp";
-static int linear_fd = -1;
-
-static char *linear_file = NULL;
-
char *prog = "hplay";
-static int
-audio_open(void)
-{
- dev_fd = open(dev_file, O_WRONLY | O_NDELAY);
- if (dev_fd < 0)
- {
- perror(dev_file);
- return 0;
- }
- return 1;
-}
-
int
audio_init(int argc, char *argv[])
{
int rate_set = 0;
int use_audio = 1;
+ int fmt;
prog = argv[0];
- argc = getargs("freebsd Audio",argc, argv,
+ argc = getargs("Audio output",argc, argv,
"r", "%d", &rate_set, "Sample rate",
"a", NULL, &use_audio, "Audio enable",
NULL);
- if (help_only)
+ if (help_only || !use_audio)
return argc;
- if (use_audio)
- audio_open();
+ dev_fd = open(dev_file, O_WRONLY);
+ if (dev_fd < 0) {
+ perror(dev_file);
+ return argc;
+ }
if (rate_set)
samp_rate = rate_set;
- if (dev_fd > 0)
- {
- ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate);
- printf("Actual sound rate: %ld\n", samp_rate);
- }
+ fmt = AFMT_S16_NE;
+ if (ioctl(dev_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
+ perror("SNDCTL_DSP_SETFMT");
+
+ if (ioctl(dev_fd, SNDCTL_DSP_SPEED, &samp_rate) < 0)
+ perror("SNDCTL_DSP_SPEED");
return argc;
}
@@ -87,54 +73,20 @@ audio_init(int argc, char *argv[])
void
audio_term()
{
- int dummy;
-
- /* Close audio system */
if (dev_fd >= 0)
{
- ioctl(dev_fd, SNDCTL_DSP_SYNC, &dummy);
close(dev_fd);
dev_fd = -1;
}
-
- /* Finish linear file */
- if (linear_fd >= 0)
- {
- ftruncate(linear_fd, lseek(linear_fd, 0L, SEEK_CUR));
- close(linear_fd);
- linear_fd = -1;
- }
}
void
audio_play(int n, short *data)
{
- if (n > 0)
+ if (n > 0 && dev_fd >= 0)
{
- unsigned char *converted = (unsigned char *) malloc(n);
- int i;
-
- if (converted == NULL)
- {
- fprintf(stderr, "Could not allocate memory for conversion\n");
- exit(3);
- }
-
- for (i = 0; i < n; i++)
- converted[i] = (data[i] - 32768) / 256;
-
- if (linear_fd >= 0)
- {
- if (write(linear_fd, converted, n) != n)
- perror("write");
- }
-
- if (dev_fd >= 0)
- {
- if (write(dev_fd, converted, n) != n)
- perror("write");
- }
-
- free(converted);
+ size_t size = n * sizeof(short);
+ if (write(dev_fd, data, size) != size)
+ perror("write");
}
}
diff --git a/audio/rsynth/files/patch-Makefile.in b/audio/rsynth/files/patch-Makefile.in
new file mode 100644
index 000000000000..a302d1bd2e4d
--- /dev/null
+++ b/audio/rsynth/files/patch-Makefile.in
@@ -0,0 +1,11 @@
+--- Makefile.in.orig 2017-05-20 02:25:06 UTC
++++ Makefile.in
+@@ -34,7 +34,7 @@ SAY_OBJS = say.o saynum.o darray.o ASCII.o phones.o te
+ getarg.o Revision.o
+
+ say : $(SAY_OBJS) hplay.o
+- $(CC) -o $@ $(LDFLAGS) $(SAY_OBJS) hplay.o $(LDLIBS)
++ $(CC) -o $@ $(LDFLAGS) $(SAY_OBJS) hplay.o $(SAY_LIBS) $(LDLIBS)
+
+ nasay : $(SAY_OBJS) naplay.o
+ $(CC) -o $@ $(LDFLAGS) $(SAY_OBJS) naplay.o $(XLIBS) $(LDLIBS)
diff --git a/audio/rsynth/files/patch-configure.in b/audio/rsynth/files/patch-configure.in
index 52505df8549e..2a2e51216236 100644
--- a/audio/rsynth/files/patch-configure.in
+++ b/audio/rsynth/files/patch-configure.in
@@ -27,7 +27,7 @@
PROGS="$PROGS mkdictdb dlookup"
else
DICTS=""
-@@ -126,7 +128,7 @@ if test "$ac_cv_header_audio_audiolib_h"
+@@ -126,7 +128,7 @@ if test "$ac_cv_header_audio_audiolib_h" = yes ; then
XLIBS="-laudio $XLIBS"
AC_DEFINE(HAVE_NAS)
],,$XLIBS $LIBS)
diff --git a/audio/rsynth/files/sndioplay.c b/audio/rsynth/files/sndioplay.c
new file mode 100644
index 000000000000..c30adefca552
--- /dev/null
+++ b/audio/rsynth/files/sndioplay.c
@@ -0,0 +1,112 @@
+#include <config.h>
+
+/*****************************************************************/
+/*** ***/
+/*** Play out a file on OpenBSD ***/
+/*** (conf/linuxplay.c with changes) ***/
+/*** ***/
+/*****************************************************************/
+
+#include <useconfig.h>
+#include <stdio.h>
+#include <math.h>
+#include <ctype.h>
+
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/signal.h>
+
+#include <sndio.h>
+
+#include "proto.h"
+#include "getargs.h"
+#include "hplay.h"
+
+#define SAMP_RATE 8000
+long samp_rate = SAMP_RATE;
+
+static struct sio_hdl *hdl;
+static struct sio_par par;
+
+char *prog = "hplay";
+
+int
+audio_init(int argc, char *argv[])
+{
+ int rate_set = 0;
+ int use_audio = 1;
+
+ prog = argv[0];
+
+ argc = getargs("Audio output",argc, argv,
+ "r", "%d", &rate_set, "Sample rate",
+ "a", NULL, &use_audio, "Audio enable",
+ NULL);
+
+ if (help_only)
+ return argc;
+
+ if (rate_set)
+ samp_rate = rate_set;
+
+ if (!use_audio)
+ return argc;
+
+ hdl = sio_open(NULL, SIO_PLAY, 0);
+ if (hdl == NULL)
+ {
+ fprintf(stderr, "sio_open failed\n");
+ return argc;
+ }
+
+ sio_initpar(&par);
+ par.bits = 16;
+ par.sig = 1;
+ par.le = SIO_LE_NATIVE;
+ par.rate = samp_rate;
+ par.pchan = 1;
+
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
+ {
+ fprintf(stderr, "error setting sndio parameters\n");
+ hdl = NULL;
+ }
+
+ if (par.bits != 16 || par.le != SIO_LE_NATIVE || par.sig != 1 || par.pchan != 1)
+ {
+ fprintf(stderr, "returned incorrect sndio parameters\n");
+ hdl = NULL;
+ }
+
+ samp_rate = par.rate;
+
+ if (hdl && !sio_start(hdl))
+ {
+ fprintf(stderr, "error starting sndio\n");
+ hdl = NULL;
+ }
+
+ return argc;
+}
+
+void
+audio_term()
+{
+ if (hdl)
+ {
+ sio_close(hdl);
+ hdl = NULL;
+ }
+}
+
+void
+audio_play(int n, short *data)
+{
+ if (n > 0 && hdl)
+ {
+ size_t size = n * sizeof(short);
+ if (sio_write(hdl, data, size) != size)
+ fprintf(stderr, "sio_write: short write");
+ }
+}
diff --git a/audio/rsynth/pkg-plist b/audio/rsynth/pkg-plist
index a6d8e33928ed..90761f0aaa8a 100644
--- a/audio/rsynth/pkg-plist
+++ b/audio/rsynth/pkg-plist
@@ -1,4 +1,4 @@
-bin/dlookup
-bin/mkdictdb
+%%DB%%bin/dlookup
+%%DB%%bin/mkdictdb
bin/say
-bin/nasay
+%%NAS%%bin/nasay