#include #include // man 2 stat #include #include #include #include #include #include #define C const typedef double _Complex c; typedef long double _Complex cx; typedef unsigned char uchar; typedef unsigned int uint; static void pc(c C a){printf("%10.0f + %10.0fi ", __real__ a, __imag__ a);} static void pcx(c C a){printf("%e + %ei\n", __real__ a, __imag__ a);} static double sq(double x){return x*x;} static void fft(c a[], C int n){ {int j=0, i; for(i=0; i>(j<<3))&255)) return 0; return 1;} static void ex(int C d){exit(-3);} static void bitch(char C * C s){ex(fprintf(stderr, "%s: Bye.\n", s));} int main(){ if(!stdin) bitch("No input file!"); {struct stat Ss; if(fstat(fileno(stdin), &Ss)) bitch("fstat failed"); if (!Ss.st_size) bitch("Empty file."); {void C * C pp = mmap(0, Ss.st_size, PROT_READ, MAP_SHARED, fileno(stdin), 0); if(0) printf("file starts: %08x %08x\n", *(int *)pp, *(int *)(pp+4)); if(!cn("FORM", pp)) bitch("Doesn't begin 'FORM'."); printf("Size from stat: 0x%x, size from FormAIFCChunk: 0x%08x\n", (int)Ss.st_size, gi(pp+4, 4)); if(!cn("AIFC", pp+8)) bitch("Expect AIFC chunk; not there."); printf("Size from AFIC chunk: 0x%x\n", gi(pp+12, 4)); {void C * q = pp+12; void C * C pend = pp + gi(pp+4, 4); void C * fverp=0, * commp=0, * ssndp=0; while(q 3.e13) {pc(s[j]); printf("%0.6f %8.0f\n", (float)j/sz, m*1.e-8);}}}} if (0) // Compute histogram of samples of right channel. {int i; short max=0, min=0; int mni = 0, mxi = 0; int qt[200]; {int j=200; while(j--) qt[j]=0;} for(i=0; i< numSampleFrames; ++i) {short q = *(sd+2*i+1); if(q<0) {if(q< min) {min = q; mni = i;}} else {if(q > max) {max = q; mxi = i;}} {int Q = ((int)q+100000)/200-500; if(abs(Q)>= 100) {printf("%08x \n", q); bitch("Too loud.");} ++qt[Q+100];}} printf("min = %d at %d, max = %d at %d\n", min, mni, max, mxi); {int j=200; while(j--) {printf("%d ", qt[j]); if(!(j&7)) printf("\n");}}} if(0) { // Compute energy in each of many adjacent intervals. int is = 8820; // samples per interval short C * p = sd; int ic = 0;// sample cursor; interval counter double C f = (float)1/44100; while((void*)p+2*is