#include <stdio.h>#include <string.h>#include <math.h>#include "machine.h"#include "sciprint.h"Include dependency graph for writeau.c:

Go to the source code of this file.
Functions | |
| void mput2 | __PARAMS ((FILE *fa, integer swap, double *res, integer n, char *type, integer *ierr)) |
| void | writeau (integer *flag, integer *nevprt,*t, xd, x, integer *nx, z, integer *nz, tvec, integer *ntvec, rpar, integer *nrpar, ipar, integer *nipar, inptr, insz, integer *nin, outptr, outsz, integer *nout) |
| void writeau | ( | integer * | flag, | |
| integer* | nevprt, | |||
| * | t, | |||
| xd | , | |||
| x | , | |||
| integer* | nx, | |||
| z | , | |||
| integer* | nz, | |||
| tvec | , | |||
| integer* | ntvec, | |||
| rpar | , | |||
| integer* | nrpar, | |||
| ipar | , | |||
| integer* | nipar, | |||
| inptr | , | |||
| insz | , | |||
| integer* | nin, | |||
| outptr | , | |||
| outsz | , | |||
| integer* | nout | |||
| ) |
Definition at line 11 of file writeau.c.
References buffer, f(), fd, i, ierr, int, mput2(), n, sciprint(), and y.
00017 : file name length 00018 ipar[2:4] = fmt : numbers type ascii code 00019 ipar[5] = n : buffer length in number of records 00020 ipar[6] = swap 00021 ipar[7:6+lfil] = character codes for file name 00022 */ 00023 { 00024 FILE *fd; 00025 int n, k,/* m,*/ i, ierr; 00026 double *buffer,*record; 00027 /* long offset;*/ 00028 int SCALE = 32768; 00029 int BIAS = 132; 00030 int CLIP = 32635; 00031 int OFFSET = 335; 00032 double y; 00033 int sig; 00034 int e; 00035 double f; 00036 00037 00038 --ipar; 00039 --z; 00040 fd=(FILE *)(long)z[2]; 00041 buffer = (z+3); 00042 ierr=0; 00043 /* 00044 k : record counter within the buffer 00045 */ 00046 00047 if (*flag==2&&*nevprt>0) 00048 { /* add a new record to the buffer */ 00049 n = ipar[5]; 00050 k = (int)z[1]; 00051 /* copy current record to output 00052 printf("%i\n",k);*/ 00053 record=buffer+(k-1)*(*nin); 00054 00055 for (i=0;i<*nin;i++) 00056 { 00057 y= *inptr[i]; 00058 y=SCALE*y; 00059 if (y<0.0) 00060 { 00061 y=-y; 00062 sig=-1; 00063 } 00064 else 00065 sig=1; 00066 if(y>CLIP) 00067 y=CLIP; 00068 y=y+BIAS; 00069 f=frexp(y,&e); 00070 y=64*sig-16*e- (int) (32*f)+OFFSET; 00071 record[i] = y; 00072 } 00073 if (k<n) 00074 z[1] = z[1]+1.0; 00075 else { 00076 mput2(fd,ipar[6],buffer,ipar[5]*(*nin),"uc",&ierr); 00077 if(ierr!=0) { 00078 *flag = -3; 00079 return; 00080 } 00081 z[1] = 1.0; 00082 00083 } 00084 00085 } 00086 else if (*flag==4) { 00087 fd = fopen("/dev/audio","wb"); 00088 if (!fd ) { 00089 sciprint("Could not open /dev/audio!\n"); 00090 *flag = -3; 00091 return; 00092 } 00093 z[2]=(double)(long)fd; 00094 z[1] = 1.0; 00095 } 00096 else if (*flag==5) { 00097 if(z[2]==0) return; 00098 k =(int) z[1]; 00099 if (k>1) {/* flush rest of buffer */ 00100 mput2(fd,ipar[6],buffer,(k-1)*(*nin),"uc",&ierr); 00101 if(ierr!=0) { 00102 *flag = -3; 00103 return; 00104 } 00105 } 00106 fclose(fd); 00107 z[2] = 0.0; 00108 } 00109 return; 00110 }
Here is the call graph for this function:

1.5.1