prnt_hdr.c
来自「speech signal process tools」· C语言 代码 · 共 687 行 · 第 1/2 页
C
687 行
voidprint_spec(indent, hdr)int indent;struct header *hdr;{ int i; struct spec_header *h = hdr->hd.spec; tab(indent); (void) printf("---Type Specific Part of Header (SPEC)---\n"); tab(indent); (void) printf("start: %ld, nan: %ld, frmlen: %d\n", h->start, h->nan, (int)h->frmlen); tab(indent); (void) printf("order_vcd: %d, order_unvcd: %d\n", (int)h->order_vcd, (int)h->order_unvcd); tab(indent); if(idx_ok(h->win_type,win_type_codes)) (void) printf("win_type: %s\n",win_type_codes[h->win_type]); else (void) printf("win_type: invalid code %d\n",(int)h->win_type); tab(indent); (void) printf("sf: %g\n",h->sf); tab(indent); if(idx_ok(h->spec_an_meth,spec_an_methods)) (void) printf("spec_an_meth: %s\n",spec_an_methods[h->spec_an_meth]); else (void) printf("spec_an_meth: invalid code %d\n",(int)h->spec_an_meth); tab(indent); (void) printf("dcrem: %g\n",h->dcrem); tab(indent); if(idx_ok(h->post_proc,post_proc_codes)) (void) printf("post_proc: %s\n",post_proc_codes[h->post_proc]); else (void) printf("post_proc: invalid code %d\n",(int)h->post_proc); tab(indent); if(idx_ok(h->frame_meth,frame_methods)) (void) printf("frame_meth: %s\n",frame_methods[h->frame_meth]); else (void) printf("frame_meth: invalid code %d\n",(int)h->frame_meth); tab(indent); (void) printf("voicing: %s\n", (h->voicing ? "YES" : "NO" )); tab(indent); if(idx_ok(h->freq_format,freq_format_codes)) (void) printf("freq_format: %s\n",freq_format_codes[h->freq_format]); else (void) printf("freq_format: invalid code %d\n",(int)h->freq_format); tab(indent); if(idx_ok(h->spec_type,spec_type_codes)) (void) printf("spec_type: %s\n",spec_type_codes[h->spec_type]); else (void) printf("spec_type: invalid code %d\n",(int)h->spec_type); tab(indent); (void) printf("contin: %s, num_freqs: %ld\n", (h->contin ? "YES" : "NO" ), h->num_freqs); for (i=0; i<SPEC_SPARES; i++) if (h->spares[i] != 0) { tab(indent); (void) printf("spares[%d]: 0x%x\n", i,(int) h->spares[i]); } pr_zfunc(indent,"pre_emp",h->pre_emp); if(h->freqs) { int j=6; for(i=0; i<h->num_freqs; i++) { if(j>5) { tab(indent); (void)printf("freqs[%d]: ",i); j=0; } (void)printf("%10.4f",h->freqs[i]); j++; } } return;}voidprint_filt(indent,hdr)int indent;struct header *hdr;{ int i,n; struct filt_header *h = hdr->hd.filt; tab(indent); (void) printf("---Type Specific Part of Header (FILT)---\n"); tab(indent); (void) printf("max_num: %d, max_den: %d\n",h->max_num,h->max_den); tab(indent); if(idx_ok(h->func_spec,filt_func_spec)) (void) printf("func_spec: %s\n",filt_func_spec[h->func_spec]); else (void) printf("func_spec: invalid code %d\n",h->func_spec); tab(indent); (void)printf("nbands: %d, npoints: %d, g_size: %d, nbits: %d\n", h->nbands,h->npoints,h->g_size,h->nbits); tab(indent); if(idx_ok(h->type,filt_type)) (void) printf("type: %s\n",filt_type[h->type]); else (void) printf("type: invalid code %d\n",h->type); tab(indent); if(idx_ok(h->method,filt_method)) (void) printf("method: %s\n",filt_method[h->method]); else (void) printf("method: invalid code %d\n",h->method); for (i=0; i<FILT_SPARES; i++) if (h->spares[i] != 0) { tab(indent); (void) printf("spares[%d]: 0x%x\n", i,(int) h->spares[i]); } if(h->nbands != 0) { int j=6; for(i=0; i<=h->nbands; i++) { if(j>5) { tab(indent); (void) printf("bandedges[%d]: ",i); j=0; } (void) printf("%g ",h->bandedges[i]); j++; } (void)printf("\n"); } if(h->npoints != 0) { int j=6; for(i=0; i<h->npoints; i++) { if(j>5) { tab(indent); (void) printf("points[%d]: ",i); j=0; } (void) printf("%g ",h->points[i]); j++; } (void)printf("\n"); } if(h->func_spec == BAND) n = h->nbands; else n = h->npoints; if(n != 0) { int j=6; for(i=0; i<n; i++) { if(j>5) { tab(indent); (void) printf("gains[%d]: ",i); j=0; } (void) printf("%g ",h->gains[i]); j++; } (void)printf("\n"); } if(n != 0) { int j=6; for(i=0; i<n; i++) { if(j>5) { tab(indent); (void) printf("wts[%d]: ",i); j=0; } (void) printf("%g ",h->wts[i]); j++; } (void)printf("\n"); } return;}voidprint_scbk(indent,hdr)int indent;struct header *hdr;{ int i; struct scbk_header *h = hdr->hd.scbk; tab(indent); (void) printf("---Scaler Codebook File---\n"); tab(indent); (void) printf("num_items: %ld, num_cdwds: %d\n", h->num_items,h->num_cdwds); tab(indent); (void) printf("convergence: %f, element_num: %d\n", h->convergence,h->element_num); tab(indent); if(idx_ok(h->distortion,scbk_distortion)) (void) printf("distortion: %s\n",scbk_distortion[h->distortion]); else (void) printf("distortion: invalid code %d\n",h->distortion); tab(indent); if(idx_ok(h->codebook_type,scbk_codebook_type)) (void) printf("codebook_type: %s\n",scbk_codebook_type[h->codebook_type]); else (void) printf("codebook_type: invalid code %d\n",h->codebook_type); for (i=0; i<SCBK_SPARES; i++) if (h->spares[i] != 0) { tab(indent); (void) printf("spares[%d]: 0x%x\n", i,(int) h->spares[i]); }}voidprint_fea(indent,hdr)int indent;struct header *hdr;{ int i, j; struct fea_header *h = hdr->hd.fea; extern char *fea_file_type[]; tab(indent); (void) printf("---Type Specific Part of Header (FEA)---\n"); tab(indent); if(idx_ok(h->fea_type,fea_file_type)) (void) printf("fea_type: %s, ", fea_file_type[h->fea_type]); else (void) printf("fea_type: invalid code %d, ",h->fea_type); printf("segment_labeled: %s, field_count: %d\n", (h->segment_labeled ? "YES" : "NO" ), h->field_count);#ifndef NOPAD if(h->field_order == YES && indent == 0) (void)printf("File is in field_order.\n");#endif if (vflag) for (i=0; i<h->field_count; i++) { tab(indent); (void)printf("Item name: %s, ", h->names[i]); tab(indent); if(idx_ok(h->types[i],type_codes)) (void)printf("type: %s, ",type_codes[h->types[i]]); else (void)printf("type: invalid code: %d, ",h->types[i]); tab(indent); (void)printf("size: %ld", h->sizes[i]); (void)printf(", rank: %d", h->ranks[i]); (void)printf("\n"); if(h->ranks[i] >= 1) { tab(indent); (void)printf(" Dimensions: "); for(j=0; j<h->ranks[i]; j++) (void)printf("% ld",h->dimens[i][j]); (void)printf("\n"); } if (h->types[i] == CODED) { char **s; tab(indent); (void)printf(" Possible coded values:\n"); s = h->enums[i]; while(*s != NULL) { tab(indent); (void)printf(" %s\n",*s++); } } if(h->derived[i]) { char **s; tab(indent); (void)printf(" Derived from:\n"); s = h->srcfields[i]; while(*s != NULL) { tab(indent); (void)printf(" %s\n",*s++); } } } /* end for (i = 0; i < h->field_count; i++) */ if (vflag) for (i=0; i<FEA_SPARES; i++) if (h->spares[i] != 0) { tab(indent); (void) printf("spares[%d]: 0x%x\n", i,(int) h->spares[i]); }}voidsort (v, n, comp, exch) char *v[];int n;int (*comp) (), (*exch) ();{/* sort strings v[0]...v[n-1] */ int gap, i, j; for (gap = n/2; gap > 0; gap /= 2) for (i = gap; i < n; i++) for (j = i-gap; j >= 0; j -= gap) { if ((*comp) (v[j], v[j+gap]) <= 0) break; (*exch) (&v[j], &v[j+gap]); }}swap (px, py) /* interchange *px and *py */char *px[], *py[];{ char *temp; temp = *px; *px = *py; *py = temp;}#define LINE_LENGTH 79voidprint_txtcomment(text, indent)char *text; /* text to print */int indent; /* number of spaces to indent */{/* used to print out the text field and comment field in the * header; if any text exceeds the LINE_LENGTH limit, a line-feed * is put out and the indentation of the continuation is set to * an additional 2 spaces */ int count = 0; /* position in line */ spsassert(text != NULL, "print_txtcomment: null text"); while (*text != '\0') { if (count == 0) { tab(indent); (void) fputc(*text, stdout); count = indent + 1; } else if (count < LINE_LENGTH) { (void) fputc(*text, stdout); count++; } else { (void) putchar('\n'); tab(indent + 2); (void) fputc(*text, stdout); count = indent + 3; } if (*text == '\n') count = 0; text++; } if(text[strlen(text)-1] != '\n') (void)putchar('\n');}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?