home *** CD-ROM | disk | FTP | other *** search
- /* Play an audio file through the D/A converter on the Delanco Spry board */
-
- #include <stdio.h>
- #include <stat.h>
- #define SEG 0xd000
- #define IOBASE 0x300
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- huge char *offset,*buf,*lmalloc();
- int fd;
- struct stat statbuf;
- long size;
- int c,i;
- int count = 1;
- extern char *optarg;
- extern int optind;
- char *name;
-
- while((c = getopt(argc,argv,"n:")) != EOF){
- switch(c){
- case 'n':
- count = atoi(optarg);
- break;
- }
- }
- while(optind < argc){
- name = argv[optind++];
-
- if(stat(name,&statbuf) == -1){
- printf("Can't stat %s\n",name);
- continue;
- }
- size = statbuf.st_size;
- buf = lmalloc(size);
- if(buf == NULL){
- printf("Can't alloc buffer of size %lu\n",size);
- continue;
- }
- if((fd = open(name,0)) == -1){
- printf("Can't read %s\n",name);
- continue;
- }
- offset = buf;
- while(read(fd,offset,16384) > 0){
- offset += 16384;
- }
- close(fd);
- for(i=0;i<count;i++)
- play8lin(IOBASE,buf,size);
- /* Return DAC to zero volts */
- outportw(IOBASE+0,2048);
- lfree(buf);
- }
- }
-