49 #include <pulse/simple.h> 50 #include <pulse/error.h> 53 const static char *err_prefix =
"Pulseaudio: ";
65 ss.format = PA_SAMPLE_S16NE;
77 if (num_samples <= 0) {
82 s = pa_simple_new(
NULL,
84 record ? PA_STREAM_RECORD : PA_STREAM_PLAYBACK,
86 record ?
"Record" :
"Speech",
93 cerr << err_prefix << pa_strerror(err) << endl;
98 pa_simple_read (s, waveform, num_samples*
sizeof(
short), &err) :
99 pa_simple_write(s, waveform, num_samples*sizeof(short), &err);
102 cerr << err_prefix << pa_strerror(err) << endl;
106 if (!record && pa_simple_drain(s, &err) < 0) {
107 cerr << err_prefix << pa_strerror(err) << endl;
120 return transfer_pulse_wave(inwave, al, 0);
125 return transfer_pulse_wave(inwave, al, 1);
135 cerr <<
"Audio: pulse not compiled in this version" << endl;
143 cerr <<
"Audio: pulse not compiled in this version" << endl;
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
ssize_t num_samples() const
return the number of samples in the waveform
int record_pulse_wave(EST_Wave &inwave, EST_Option &al)
void err(const char *message, LISP x) EST_NORETURN
const EST_SMatrix & values() const
int sample_rate() const
return the sampling rate (frequency)
int play_pulse_wave(EST_Wave &inwave, EST_Option &al)