testpit.c

来自「speech signal process tools」· C语言 代码 · 共 107 行

C
107
字号
#include <stdio.h>#include <sps/sps.h>#include <sps/pitch.h>main (argc, argv)int argc;char **argv;{struct header *ih, *ah, *bh, *hh;struct header *oh;struct pitch *dp, *dp1;FILE *ostrm;	ih = new_header(FT_PIT);	strcpy(ih->common.prog,"testpit");	ih ->common.nchar = 3;	ih ->hd.pit->start = 5;	ih ->hd.pit->hp_thresh = 44.0;	ih ->common.ndrec = 8;	printf("type %d\n",ih->common.type);	printf("check %d\n",ih->common.check);	printf("prog %s\n",ih->common.prog);	printf("nchar %d\n",ih->common.nchar);	printf("start %d\n",ih->hd.pit->start);	printf("hp_thresh %f\n",ih->hd.pit->hp_thresh);/* first sub header */	ah = new_header(FT_PIT);	strcpy(ah->common.prog,"testpit1");	ah ->common.nchar = 3;	ah ->hd.pit->start = 5;	ah ->hd.pit->hp_thresh = 44.0;	add_source_file (ih, "first", ah);/* second new header */	bh = new_header(FT_PIT);	strcpy(bh->common.prog,"testpit2");	bh ->common.nchar = 3;	bh ->hd.pit->start = 5;	bh ->hd.pit->hp_thresh = 44.0;	add_source_file (ih, "second", bh);        TRYOPEN ( "testpit","testpit.pit",  "w", ostrm );        write_header(ih, ostrm);	/* write some data */	dp = allo_pitch_rec();	dp->tag = 1;	dp->pulse_dist = 2;	dp->raw_pulse_dist = 3;	(void) put_pitch_rec(dp,ostrm);	dp->tag = 4;	dp->pulse_dist = 5;	dp->raw_pulse_dist = 6;	(void) put_pitch_rec(dp,ostrm);	dp->tag = 7;	dp->pulse_dist = 8;	dp->raw_pulse_dist = 9;	(void) put_pitch_rec(dp,ostrm);	dp->tag = 10;	dp->pulse_dist = 11;	dp->raw_pulse_dist = 12;	(void) put_pitch_rec(dp,ostrm);	dp->tag = 13;	dp->pulse_dist = 14;	dp->raw_pulse_dist = 15;	(void) put_pitch_rec(dp,ostrm);	fclose(ostrm);	TRYOPEN("testpit", "testpit.pit", "r", ostrm);	oh = read_header(ostrm);	hh = copy_header(oh);	printf("copy header\n");	printf("type %d\n",hh->common.type);	printf("check %d\n",hh->common.check);	printf("prog %s\n",hh->common.prog);	printf("nchar %d\n",hh->common.nchar);	printf("start %d\n",hh->hd.pit->start);	printf("hp_thresh %f\n",hh->hd.pit->hp_thresh);	printf("main header\n");	printf("type %d\n",ih->common.type);	printf("check %d\n",ih->common.check);	printf("prog %s\n",ih->common.prog);	printf("nchar %d\n",ih->common.nchar);	printf("start %d\n",ih->hd.pit->start);	printf("hp_thresh %f\n",ih->hd.pit->hp_thresh);	printf("sub header 1\n");	printf("type %d\n",ih->variable.srchead[0]->common.type);	printf("check %d\n",ih->variable.srchead[0]->common.check);	printf("prog %s\n",ih->variable.srchead[0]->common.prog);	printf("nchar %d\n",ih->variable.srchead[0]->common.nchar);	printf("start %d\n",ih->variable.srchead[0]->hd.pit->start);	printf("hp_thresh %f\n",ih->variable.srchead[0]->hd.pit->hp_thresh);	printf("sub header 2\n");	printf("type %d\n",ih->variable.srchead[1]->common.type);	printf("check %d\n",ih->variable.srchead[1]->common.check);	printf("prog %s\n",ih->variable.srchead[1]->common.prog);	printf("nchar %d\n",ih->variable.srchead[1]->common.nchar);	printf("start %d\n",ih->variable.srchead[1]->hd.pit->start);	printf("hp_thresh %f\n",ih->variable.srchead[1]->hd.pit->hp_thresh);/* read the data */	dp1 = allo_pitch_rec();	while (get_pitch_rec(dp1,ostrm)) print_pitch_rec(dp1,stderr);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?