40 #include "EST_audio.h" 41 #include "EST_cmd_line_options.h" 42 #if defined(WIN32) || defined(__CYGWIN__) 48 #if defined(WIN32) || defined(__CYGWIN__) 86 int main (
int argc,
char *argv[])
96 "Summary; record waveform from audio device\n"+
97 "use \"-\" to make output files stdout\n"+
99 "-f <int> Input sample rate\n"+
100 "-audiodevice <string> use specified audiodevice if appropriate\n" 102 "-time <float> Wave length in seconds\n"+
103 options_wave_output()+
105 "-p <string> audio device protocol. Ths supported types are\n"+
106 " "+options_supported_audio()+
"\n",
112 al.
add_item(
"-sample_rate",
"16000");
117 out_file = al.
val(
"-o");
118 #if defined(WIN32) || defined(__CYGWIN__) 119 if (win_record_wave(wave,al) != 0)
121 if (record_wave(wave,al) != 0)
127 write_wave(wave, out_file, al);
131 #if defined(WIN32) || defined(__CYGWIN__) 134 char command_buffer[100];
135 MCIERROR audio_error;
141 cerr <<
"na_record: for Win32 version, must specify an output file with the -o flag" << endl;
144 out_file = al.
val(
"-o");
150 audio_error = mciSendString(
"open new type waveaudio alias mysound buffer 6",NULL,0,NULL);
152 sprintf(command_buffer,
"set mysound time format ms bitspersample 16 samplespersec %d",44100);
153 audio_error = mciSendString(command_buffer,NULL, 0 ,NULL);
164 sprintf(command_buffer,
"record mysound from 0 to %d wait",(
int)(2*1000*al.
fval(
"-time")*44100)/11025);
165 audio_error = mciSendString(command_buffer,NULL,0,NULL);
166 sprintf(command_buffer,
"save mysound %s",(
char *)al.
val(
"-o"));
167 audio_error = mciSendString(command_buffer,NULL,0,NULL);
169 audio_error = mciSendString(
"close mysound",NULL,0,NULL);
171 read_wave(wave, out_file, al);
int ival(const EST_String &rkey, int m=1) const
float fval(const EST_String &rkey, int m=1) const
const int present(const K &rkey) const
Returns true if key is present.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
void resample(int rate)
Resample waveform to rate