home *** CD-ROM | disk | FTP | other *** search
- /* */
- #include <stdio.h>
- #include <process.h>
- int *storage[8],k,count;
- unsigned i;
- #define CONTROL 0x34
- #define CONT2 0xb4
- unsigned prt0,cntrlpt,prt1,prt2;
- main(argc,argv)
- int argc;
- char *argv[];
- {
-
- unsigned div,outport;
- int value,baseio,seg320;
- char name[20],buffer[24],*malloc();
- float trate,osc,rate;
- FILE *fp;
- for(k=0;k<6;k++) storage[k]=(int *)malloc(0x8000);
- clark: do {
- printf("Input desired sample rate in Hz ");
- scanf( "%f",&rate);
- } while ( (rate < 80.0 ) || (rate > 40000.1));
- /* count gives you the oscillator "divisor" just as in SIO's */
- osc=6.25e+6;
- count = 6.25e+6/rate;
- if ( count == 0 ) count =1;
- if ( count == 1 ) count =2;
- trate = osc /(float)count;
- printf("\nRate = %lf ",trate);
- /* set timers for desired sampling rate */
- control_timer(count,osc,&trate);
- baseio=0x300;
- seg320=0xd000;
- inp(baseio+7); /* halt */
- /* Load the fft and square routines */
- spawnl(P_WAIT,"intel",argv[0],"send","d000","300","0",NULL);
- printf("\nSource File Name ? ");
- scanf("%s",name);
- if( (fp =fopen(name,"rb")) == NULL )
- {
- printf("file open error\n");
- exit();
- }
- for (k=0;k<6;k++)
- fread(storage[k],2,0x4000,fp); /* read the file into array */
- printf("\nOutput Port (0,1,2,4 for D/A) ? ");
- scanf("%d",&outport);
- inp(baseio+6);
- for (k=0;k<6;k++) {
- empbuf(baseio,k); /* send to the 320 */
- }
- inp(baseio+7);
- fclose(fp);
- }
-
- empbuf(baseio,which)
- int baseio,which;
- {
- int jj,kk,porto;
- jj=-1;
- porto=baseio+4;
- for (kk=0;kk<0x4000;kk++) {
- while (inp(porto)==jj) {};
- jj=inp(baseio+4);
- outp(baseio,(*(storage[which]+kk)&0xff));
- outp(baseio+1,((*(storage[which]+kk)>>8)&0xff));
- }
- }
- control_timer(cnt,osc,trate)
- long cnt;
- float *trate,osc;
- {
- int ctl,cth;
- /* tell board timer info coming */
- outp(cntrlpt ,CONTROL);
- /* count is timing divisor */
- ctl = cnt & 0xff; /* lo byte */
- cth = ( cnt >> 8 ) & 0xff;/* hi byte */
- /* control timer 0 */
- outp(prt0 , ctl);
- outp(prt0 , cth);
- /* control timer 2 */
- outp(cntrlpt , CONT2);
- outp(prt2 , ctl);
- outp(prt2 , cth);
- /* compute new sampling rate for output on screen*/
- *trate = osc/(float)cnt;
- }
-
- ci()
- {
- int kbhit(),getch(),j;
- while (kbhit()==0) {};
- j=getch();
- }
-
-