2 * hdrec -- some sort of multi tracker (not right now, but in the future :p)
4 * author: hackbard@hackdaworld.dyndns.org
11 #include <sys/ioctl.h>
12 #include <sys/types.h>
14 #include <sys/soundcard.h>
24 printf("-h \t\t print this help\n");
25 printf("-r <file> \t record to <file>\n");
26 printf("-p <file> \t play from <file>\n");
27 printf("-s \t\t stereo\n");
28 printf("-m \t\t mono\n");
29 printf("-f <format> \t 1=8bit - 2=16bit (le)\n");
30 printf("-F <hz> \t frequency\n");
35 int main(int argc,char **argv) {
39 char device[MAX_C_DEVICE];
44 char record_file[MAX_C_FILE];
45 char play_file[MAX_C_FILE];
51 set.format=AFMT_S16_LE;
64 strcpy(record_file,argv[++i]);
68 strcpy(play_file,argv[++i]);
78 if(atoi(argv[i])==1) set.format=AFMT_U8;
79 if(atoi(argv[i])==2) set.format=AFMT_S16_LE;
82 set.freq=atoi(argv[++i]);
85 strncpy(device,argv[++i],MAX_C_DEVICE-1);
94 if(!strcmp("",device)) {
95 printf("you have to specify a device!\n");
100 if(mode&RECORD) o_mode=O_RDONLY;
101 if(mode&PLAY) o_mode=O_WRONLY;
102 if(mode&RECORD && mode&PLAY) o_mode=O_RDWR;
103 if((audio_fd=open_sound_dev(device,o_mode))==-1) {
104 printf("unable to open %s\n",device);
110 if((pfile_fd=open_file(play_file,O_RDONLY))==-1) {
111 printf("unable to open file %s for reading\n",play_file);
116 if((sfile_fd=open_file(record_file,O_CREAT|O_WRONLY))==-1) {
117 printf("unable to open file %s for writing\n",record_file);
122 /* set dsp and get capabilities */
123 if(get_dsp_cap(audio_fd,&set,1)==-1) {
124 printf("unable to get capabilities :(\n");
127 if(set_dsp(audio_fd,&set)==-1) {
128 printf("unable to set dsp :(\n");
132 /* allocating buffer */
133 if((buf=malloc(set.bufsize*sizeof(unsigned char)))==NULL) {
134 printf("allocating memory failed :(\n");
140 printf("playing file %s ...\n",play_file);
143 rw=read(pfile_fd,buf,set.bufsize);
144 write(audio_fd,buf,set.bufsize);
149 printf("recording to file %s ...\n",record_file);
152 rw=read(audio_fd,buf,set.bufsize);
153 write(sfile_fd,buf,set.bufsize);