📄 psps.c
字号:
(void) printf("Record %d: ",i-1); (void) print_spec_rec(spec_rec,h,stdout); } } break;#ifdef ESI case FT_ROS: ros_rec = allo_ros_rec(h); i = srec; while (i++ <= erec && (get_ros_rec(ros_rec,h,istrm) != EOF)) { if (!tflag || (tflag && ros_rec->tag >= stag && ros_rec->tag <= etag)) { (void) printf("Record %d: ",i-1); (void) print_ros_rec(ros_rec,h,stdout); } } break;#endif ESI case FT_FILT: filt_rec = allo_filt_rec(h); i = srec; while (i++ <= erec && (get_filt_rec(filt_rec,h,istrm) != EOF)) { if (!tflag || (tflag && filt_rec->tag >= stag && filt_rec->tag <= etag)) { (void) printf("Record %d: ",i-1); (void) print_filt_rec(filt_rec,h,stdout); } } break; case FT_SCBK: scbk_rec = allo_scbk_rec(h); i = srec; while (i++ <= erec && (get_scbk_rec(scbk_rec,h,istrm) != EOF)) { if (tflag) { ERROR_EXIT("No tags exist in Scalar Quantization Codebook"); } else { (void) printf("Record %d: ",i-1); (void) print_scbk_rec(scbk_rec,h,stdout); } } break; case FT_FEA: switch (h->hd.fea->fea_type) { case FEA_SPEC: feaspec_rec = allo_feaspec_rec(h, FLOAT); i = srec; while (i++ <= erec && (get_feaspec_rec(feaspec_rec,h,istrm) != EOF)) { if (!tflag || (tflag && *feaspec_rec->tag >= stag && *feaspec_rec->tag <= etag)) { (void) printf("Record %d: ",i-1); (void) print_feaspec_rec(feaspec_rec,h,stdout); } } break; case FEA_FILT: feafilt_rec = allo_feafilt_rec(h); i = srec; while (i++ <= erec && (get_feafilt_rec(feafilt_rec,h,istrm) != EOF)) { (void) printf("Record %d: ",i-1); (void) print_feafilt_rec(feafilt_rec,h,stdout); } break; case FEA_SD: if(get_fea_siz("samples",h,(short *)NULL, (long **)NULL) > 1 || h->hd.fea->field_count > 1){ fea_rec = allo_fea_rec(h); i = srec; while (i++ <= erec && (get_fea_rec(fea_rec,h,istrm) != EOF)) { if (!tflag || (tflag && fea_rec->tag >= stag && fea_rec->tag <= etag)) { (void) printf("Record %d: ",i-1); (void) print_fea_recf(fea_rec,h,stdout,field_name); } } } else if (complex_type(h)) pr_feasd_data (istrm, srec, erec, h); else pr_sd_data (istrm, srec, erec, h); break; default: fea_rec = allo_fea_rec(h); i = srec; while (i++ <= erec && (get_fea_rec(fea_rec,h,istrm) != EOF)) { if (!tflag || (tflag && fea_rec->tag >= stag && fea_rec->tag <= etag)) { (void) printf("Record %d: ",i-1); (void) print_fea_recf(fea_rec,h,stdout,field_name); } } break; } break; default: if (!gflag) Fprintf(stderr, "psps: Unknown file type, code: %d\n",h->common.type); rec_size = get_rec_len (h); if ((data = calloc_d((unsigned)rec_size)) == NULL) ERROR_EXIT("calloc could not allocate memory for data"); i = srec; while (i++ <= erec && (get_gen_recd(data,&tag,h,istrm) != EOF)) { if (!tflag || (tflag && tag >= stag && tag <= etag)) { (void) printf ("Record: %d", i-1); if (h->common.tag == YES) (void) printf (" Tag: %ld\n", tag); else (void) printf ("\n"); for (k = 0; k < rec_size; k++) (void) printf (" element%d: %g\n",k+1,data[k]); } } } exit (0);/* NOTREACHED */}voidpr_history(name,h,level)char *name;struct header *h;int level;{/* * prints common portion of all embedded headers */ int i; tab(level); (void) printf("File: %s\n",name); print_common(level,h); level++; for (i = 0; h->variable.srchead[i] && i < h->variable.nheads; i++) { tab (level); (void) printf ("----------------\n"); pr_history (h->variable.source[i], h->variable.srchead[i], level); } return;}char *file_typeX(type)short type;{ switch (type) {#ifdef ESI case FT_ANA: return "ANA (Analysis File)"; case FT_PIT: return "PIT (Pitch Data File)"; case FT_ROS: return "RPS (Rosetta Speech Frame File)";#endif case FT_SD: return "SD (Sampled Data File)"; case FT_SPEC: return "SPEC (Spectral Records)"; case FT_FILT: return "FILT (Filter Coefficient File)"; case FT_SCBK: return "SCBK (Scaler Codebook File)"; case FT_FEA: return "FEA (Feature File)"; default: return "Unknown type"; }}voidpr_sd_data (istrm, srec, erec, h)FILE *istrm;struct header *h;long srec, erec;{/* print a range of data from a ESPS sampled data file * for integer types, 10/line. For floating types, 5/line. */ int itype; double data[10]; long i, npl, ngot, nleft = erec - srec + 1; itype = (h->common.nlong || h->common.nshort || h->common.nchar); if (srec > erec) return; npl = (itype ? 10 : 5); while (nleft > 0) { if (npl > nleft) npl = nleft; ngot = get_sd_recd (data, (int)npl, h, istrm); if (ngot == 0) break; (void) printf ("%6d: ", srec); if (itype) for (i = 0; i < ngot; i++) (void) printf ("%7d", (int) data[i]); else for (i = 0; i < ngot; i++) { (void) printf (" %10.4f", data[i]); } putchar ('\n'); nleft -= ngot; srec += ngot; }}voidpr_full_header(name,h,recursive,level)char *name;struct header *h;int recursive,level;{/* * prints full headers, including type specific and generics; * embedded headers printed if recursive set */ tab (level); (void) printf("File: %s\n",name); print_common(level,h); if (vflag && h->variable.refhd) { (void) printf("Reference Header:\n"); pr_full_header("reference header",h->variable.refhd,0,level+1); }#ifdef ESI if (h->common.type == FT_ANA) print_ana(level,h); if (h->common.type == FT_PIT) print_pitch(level,h); if (h->common.type == FT_ROS) print_ros(level,h);#endif ESI if (h->common.type == FT_SD) print_sd(level,h); if (h->common.type == FT_SPEC) print_spec(level,h); if (h->common.type == FT_FILT) print_filt(level,h); if (h->common.type == FT_SCBK) print_scbk(level,h); if (h->common.type == FT_FEA) print_fea(level,h); print_generic(level,h); (void) printf("\n"); if (recursive) { int i = 0; level++; while (h->variable.srchead[i] && i < h->variable.nheads) { tab (level); (void) printf ("----------------\n"); pr_full_header (h->variable.source[i], h->variable.srchead[i], recursive, level); i++; } }}/* myrealloc is like realloc, except that if ptr is NULL, it acts like a calloc*/static char *myrealloc(ptr, size)char *ptr;unsigned size;{ spsassert(size > 0, "psps/myrealloc: size <= 0"); if (ptr == NULL) return calloc((unsigned)1,size); else return realloc(ptr, size);}intcomplex_type(hdr)struct header *hdr;{ spsassert(hdr->common.type == FT_FEA && hdr->hd.fea->fea_type == FEA_SD, "complex_type() in psps.c called with wrong arg type"); if (hdr->hd.fea->ndcplx || hdr->hd.fea->nfcplx || hdr->hd.fea->nlcplx || hdr->hd.fea->nscplx || hdr->hd.fea->nbcplx) return 1; else return 0;}voidpr_feasd_data (istrm, srec, erec, h)FILE *istrm;struct header *h;long srec, erec;{/* multi-channel or complex or both */ int itype; double_cplx *cplx_data; struct feasd *feasd_data; long i, npl, ngot, nleft = erec - srec + 1; itype = (h->common.nlong || h->common.nshort || h->common.nchar); if (srec > erec) return; npl = (itype ? 4 : 3); feasd_data = allo_feasd_recs(h,DOUBLE_CPLX,4L,NULL,YES); while (nleft > 0) { if (npl > nleft) npl = nleft; ngot = get_feasd_recs(feasd_data,0L,npl,h,istrm); if (ngot == 0) break; (void) printf ("%6d: ", srec); cplx_data = (double_cplx *)feasd_data->data; if (itype) for (i = 0; i < ngot; i++) (void) printf ("[%7d,%7d]",(int)cplx_data[i].real, (int)cplx_data[i].imag); else for (i = 0; i < ngot; i++) { (void) printf ("[%10.4f,%10.4f]",cplx_data[i].real, cplx_data[i].imag); } putchar ('\n'); nleft -= ngot; srec += ngot; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -