1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*************************************************************************/
/* Author : Theo Veenker (Utrecht University) */
/* Date : September 1997 */
/*-----------------------------------------------------------------------*/
/* Optional 16bit linear support for audio on IRIS 4D workstations */
/* */
/*=======================================================================*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include "EST_unix.h"
#include "EST_cutils.h"
#include "EST_Wave.h"
#include "EST_Option.h"
#include "audioP.h"
#include "EST_io_aux.h"
#if defined (SUPPORT_IRIX) || defined (SUPPORT_IRIX53)
#include <audio.h>
#include <unistd.h>
int irix_supported = TRUE;
int play_irix_wave(EST_Wave &inwave, EST_Option &al)
{
int sample_rate;
short *waveform;
int num_samples;
ALconfig config;
ALport port;
int r;
(void)al;
waveform = inwave.values().memory();
num_samples = inwave.num_samples();
sample_rate = inwave.sample_rate();
config = ALnewconfig();
ALsetsampfmt(config, AL_SAMPFMT_TWOSCOMP);
ALsetwidth(config, AL_SAMPLE_16);
ALsetchannels(config, AL_MONO);
long pvbuf[2];
pvbuf[0] = AL_OUTPUT_RATE;
pvbuf[1] = sample_rate;
ALsetparams(AL_DEFAULT_DEVICE, pvbuf, 2);
/*
ALgetparams(AL_DEFAULT_DEVICE, pvbuf, 2);
if (pvbuf[1] != sample_rate)
{
cerr << "IRIX: sample rate " << sample_rate <<
" not supported; using " << pvbuf[1] << endl;
}
*/
port = ALopenport("speech-tools", "w", config);
if (!port)
{
cerr << "IRIX: can't open audio port" << endl;
ALfreeconfig(config);
return -1;
}
r = ALwritesamps(port, waveform, num_samples);
if (r != 0)
cerr << "IRIX: failed to write to buffer" << endl;
// Wait until all samples are played.
// IRIX 5.3 doesn't have usleep
#ifdef SUPPORT_IRIX53
while (ALgetfilled(port)) sginap(1);
#elseif
while (ALgetfilled(port)) usleep(10000);
#endif
ALcloseport(port);
ALfreeconfig(config);
return 1;
}
#else
int irix_supported = FALSE;
int play_irix_wave(EST_Wave &inwave, EST_Option &al)
{
(void)inwave;
(void)al;
cerr << "IRIX 16bit linear not supported" << endl;
return -1;
}
#endif
|