⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gather.c

📁 speech signal process tools
💻 C
字号:
/* ******************************************************************************** * *  This material contains proprietary software of Entropic Speech, Inc. *  Any reproduction, distribution, or publication without the the prior *  written permission of Entropic Speech, Inc. is strictly prohibited. *  Any public distribution of copies of this work authorized in writing *  by Entropic Speech, Inc. must bear the notice: * *     "Copyright (c) 1987 Entropic Speech, Inc.; all rights reserved" * *  Program: gather * *  Written by: Jim Elliott * *  Collection of subroutines to gather histogram data for histo program. * ******************************************************************************** *//* *  SCCS program and date keywords. */#ifndef lintstatic char *sccs_id = "@(#)gather.c	1.2	10/6/87 ESI";#endif/* *  System include files. */#include <stdio.h>/* *  ESPS include files. */#include <esps/esps.h>#include <esps/anafea.h>#include <esps/fea.h>#include <esps/feaqhist.h>#include <esps/feaquant.h>#include "histo.h"/* ******************************************************************************** *  Subroutine to compute histogram for type and extension fields. ******************************************************************************** */histo_type_ext( anafea_rec, prev_type, uvced_frmlen, hist_type, hist_ext )int hist_ext[], hist_type[], uvced_frmlen;short prev_type;struct anafea *anafea_rec;{    long	fl,			/* Frame length */	np;			/* Number of pulses */    short	ft;			/* Frame type */    static int	init = YES;		/* Flag for initial entry */    static long	prev_length,		/* Previous frame length */	prev_pulses;		/* Previous number of pulses *//* *  A type value of -1 is used to encode end-of-file. We must have one, and *  only one hit in this bucket. */    if ( init )    {	init = NO;	accum_histo( hist_type, -1, MAX_TYPE );    }    np = *anafea_rec->num_pulses;    fl = *anafea_rec->frame_len;    ft = *anafea_rec->frame_type;    if ( ft == prev_type )    {	if ( ft == VOICED )	{	    if ( np == prev_pulses )		accum_histo( hist_type, 0, MAX_TYPE );	    else		accum_histo( hist_type, (int) np, MAX_TYPE );	    if ( np == 1 )		accum_histo( hist_ext, VCD, MAX_EXT );	}	else	{	    if ( fl == prev_length )		accum_histo( hist_type, 0, MAX_TYPE );	    else	    {		accum_histo( hist_type, 1, MAX_TYPE );		if ( fl == uvced_frmlen )		    accum_histo( hist_ext, UNVCD_STD, MAX_EXT );		else		    accum_histo( hist_ext, UNVCD_NONSTD, MAX_EXT );	    }	}    }    else    {	if ( ft == VOICED )	{	    accum_histo( hist_type, (int) np, MAX_TYPE );	    if ( np == 1 )		accum_histo( hist_ext, VCD, MAX_EXT );	}	else	{	    accum_histo( hist_type, 1, MAX_TYPE );	    if ( fl == uvced_frmlen )		accum_histo( hist_ext, UNVCD_STD, MAX_EXT );	    else		accum_histo( hist_ext, UNVCD_NONSTD, MAX_EXT );	}    }        prev_pulses = np;    prev_length = fl;}/* ******************************************************************************** *  Subroutine to compute histogram for power. ******************************************************************************** */histo_power( anafea_rec, auxana_rec, cont_pwr, prev_type, hist_pwr )int hist_pwr[];short cont_pwr, prev_type;struct anafea *anafea_rec;struct auxana *auxana_rec;{    int	i,			/* Loop variable */	index;			/* Difference index */    static short	prev_pwr;		/* Previous power index */    if ( *anafea_rec->frame_type == VOICED )    {        if ( cont_pwr == YES || prev_type == VOICED )        {	    index = auxana_rec->raw_power_idx[0] - prev_pwr;	    accum_histo( hist_pwr, index, MAX_PWR );        }        for ( i = 1; i < *anafea_rec->num_pulses; i++ )        {	    index = auxana_rec->raw_power_idx[i] -		auxana_rec->raw_power_idx[i-1];	    accum_histo( hist_pwr, index, MAX_PWR );        }        prev_pwr = auxana_rec->raw_power_idx[i-1];    }    else    {	if ( cont_pwr == YES || prev_type == UNVOICED )	{	    index = auxana_rec->raw_power_idx[0] - prev_pwr;	    accum_histo( hist_pwr, index, MAX_PWR );	}        prev_pwr = auxana_rec->raw_power_idx[0];    }}/* ******************************************************************************** *  Subroutine to compute histogram for pulse length. ******************************************************************************** */histo_length( anafea_rec, auxana_rec, prev_type, hist_len )int hist_len[];short prev_type;struct anafea *anafea_rec;struct auxana *auxana_rec;{    int	i,			/* Loop variable */	index;			/* Difference index */    static short	prev_len;		/* Previous pulse length */    if ( *anafea_rec->frame_type == UNVOICED )        return;    if ( prev_type == VOICED )    {	index = (int) auxana_rec->pulse_len_idx[0] - prev_len;	accum_histo( hist_len, index, MAX_LEN );    }    for ( i = 1; i < *anafea_rec->num_pulses; i++ )    {	index = (int) ( auxana_rec->pulse_len_idx[i] - auxana_rec->pulse_len_idx[i-1] );	accum_histo( hist_len, index, MAX_LEN );    }    prev_len = (int) auxana_rec->pulse_len_idx[i-1];}/* ******************************************************************************** *  Subroutine to compute histogram for spectral parameters. ******************************************************************************** */histo_spectrum( anafea_rec, auxana_rec, order_vcd, order_unvcd,    u_avg, v_avg, cont_spc, prev_type, hist_spec_inter, hist_spec_intra )int hist_spec_inter[], hist_spec_intra[];long order_unvcd, order_vcd;short cont_spc, prev_type, *u_avg, *v_avg;struct anafea *anafea_rec;struct auxana *auxana_rec;{    int	i,			/* Loop variable */	index,			/* Difference index */	offset,			/* Offset in histogram array */	order,			/* Analysis order */	same_type;		/* Logical flag */    short	*avg,			/* Static average values */	*prev_index;		/* Previous index array */    static short	prev_frm_index[ MAX_ORD ],	/* Index array - previous frame */	prev_same_index[ MAX_ORD ];	/* Index array - same frame type */    if ( *anafea_rec->frame_type == VOICED )    {	offset = 0;	order = order_vcd;	avg = v_avg;    }    else    {	offset = VSZ;	order = order_unvcd;	avg = u_avg;    }    same_type = ( *anafea_rec->frame_type == prev_type );    if ( cont_spc == YES || same_type )    {	if ( same_type )	    prev_index = prev_frm_index;	else	    prev_index = prev_same_index;        for ( i = 0; i < order; i++ )        {	    index = auxana_rec->spec_param_idx[i];	    accum_histo( hist_spec_inter + offset + i*FSZ, index - prev_index[i],	        MAX_SPEC );        }	if ( !same_type )	    for ( i = 0; i < order; i++ )		prev_same_index[i] = auxana_rec->spec_param_idx[i];    }    for ( i = 0; i < order; i++ )    {	index = auxana_rec->spec_param_idx[i] - avg[i];	accum_histo( hist_spec_intra + offset + i*FSZ, index, MAX_SPEC );        prev_frm_index[i] = auxana_rec->spec_param_idx[i];    }}/* ******************************************************************************** *  Subroutine to accumulate histogram. ******************************************************************************** */accum_histo( hist, i, max )int hist[], i, max;{    i += max;    if ( i < 0 )        i = 0;    if ( i > 2*max )        i = 2*max;    hist[i]++;}

⌨️ 快捷键说明

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