Edinburgh Speech Tools  2.1-release
mplayer.cc
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author : Richard Caley */
34 /* Date : August 1997 */
35 /*-----------------------------------------------------------------------*/
36 /* Optional 16bit linear support for Windows NT/95 */
37 /* */
38 /*=======================================================================*/
39 
40 #include <cstdio>
41 #include "EST_cutils.h"
42 #include "EST_Wave.h"
43 #include "EST_Option.h"
44 #include "EST_io_aux.h"
45 #include "EST_Pathname.h"
46 
47 using namespace std;
48 
49 #ifdef SUPPORT_MPLAYER
50 
52 
53 static EST_Pathname tempfile;
54 static EST_Pathname temppath;
55 static EST_Pathname tempdir;
56 
57 static void find_tempfile(void)
58 {
59  const char *s=NULL;
60 
61  if (!(s=getenv("TMP")))
62  if (!(s=getenv("TMPDIR")))
63  if (!(s=getenv("TEMPDIR")))
64  s="\tmp";
65 
66  tempdir = s;
67 
68  char buffer[512];
69  sprintf(buffer, "est%4d.wav", getpid());
70  tempfile = buffer;
71  temppath = EST_Pathname::append(tempdir.as_directory(), tempfile);
72 }
73 
74 int play_mplayer_wave(EST_Wave &inwave, EST_Option &al)
75 {
76 
77  if (tempfile == "")
78  find_tempfile();
79 
80  inwave.save(temppath, "riff");
81 
82  char command[1000];
83 
84  sprintf(command,
85  "mplayer /play %s\\%s",
86  (const char *)tempdir,
87  (const char *)tempfile);
88 
89  cout << "command '" << command <<"'\n";
90  system(command);
91 
92  unlink(temppath);
93 
94  return 1;
95 }
96 
97 #else
99 
101 {
102  (void)inwave;
103  (void)al;
104  cerr << "Windows mplayer not supported" << endl;
105  return -1;
106 }
107 
108 #endif
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
Definition: EST_Wave.h:64
Utility IO Function header file.
static EST_Pathname append(EST_Pathname directory, EST_Pathname addition)
int mplayer_supported
Definition: mplayer.cc:98
char * getenv()
EST_write_status save(const EST_String filename, const EST_String EST_filetype="")
Definition: EST_Wave.cc:355
#define FALSE
Definition: EST_bool.h:119
NULL
Definition: EST_WFST.cc:55
int play_mplayer_wave(EST_Wave &inwave, EST_Option &al)
Definition: mplayer.cc:100
EST_Pathname as_directory(void) const
#define TRUE
Definition: EST_bool.h:118