55 #include <audio/audiolib.h> 56 #include <audio/soundlib.h> 58 #define VOL(volume) ((1 << 16) * (volume) / 100) 59 #define au_serverrate 16000 60 static int nas_playing = 0;
65 #define NAS_BIG_ENDIAN (((char *)&endian_int)[0] == 0) 67 static void na_sync_play_cb(AuServer *aud, AuEventHandlerRec *handler,
68 AuEvent *ev, AuPointer data)
70 int *d = (
int *) data;
85 int dev_sr[] = {8000, 9600, 11025, 16000, 18900, 22050, 32000,
86 37800, 44100, 48000, -1};
88 char *auservername =
NULL;
93 AuEventHandlerRec *er;
95 int num_samps, samp_rate;
100 aud = AuOpenServer(auservername, 0,
NULL, 0,
NULL,
NULL);
103 cerr <<
"Can't access NAS server " << auservername << endl;
111 bool samp_rate_ok =
FALSE;
112 for (i=0; dev_sr[i] != -1; i++)
113 if (samp_rate == dev_sr[i])
115 if (samp_rate_ok ==
FALSE)
117 if (samp_rate == 10000)
130 in = SoundCreate(SoundFileFormatNone,
133 samp_rate, num_samps,
NULL);
135 in = SoundCreate(SoundFileFormatNone,
137 AuFormatLinearSigned16MSB :
138 AuFormatLinearSigned16LSB),
140 samp_rate, num_samps,
NULL);
142 er = AuSoundPlayFromData(aud, in, waveform, AuNone, VOL(100),
144 (AuPointer) &d,(AuFlowID *)
NULL,
148 AuNextEvent(aud, AuTrue, &ev);
149 AuDispatchEvent(aud, &ev);
165 cerr <<
"NAS: record not written yet\n";
176 cerr <<
"NAS playback not supported" << endl;
185 cerr <<
"NAS record not supported" << endl;
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
char * wstrdup(const char *s)
Utility IO Function header file.
ssize_t num_samples() const
return the number of samples in the waveform
const EST_SMatrix & values() const
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
int record_nas_wave(EST_Wave &wave, EST_Option &al)
int play_nas_wave(EST_Wave &inwave, EST_Option &al)
int sample_rate() const
return the sampling rate (frequency)
int present(const K &rkey) const
Returns true if key is present.
ssize_t num_channels() const
return the number of channels in the waveform
void resample(int rate)
Resample waveform to rate
EST_String sample_type() const