📄 voicin.f,v
字号:
* In the following chart, the decisions marked with a * may be overridden.** Voicing override of transitions at onsets:* If a V/UV or UV/V voicing decision transition occurs within one-half* frame of an onset bounding a voicing window, then the transition is* moved to occur at the onset.** P 1F* ----- -----* 0 0 0 0* 0 0 0* 1 (If there is an onset there)* 0 0 1* 0* (Based on 2F and discriminant distance)* 0 0 1 1* 0 1* 0 0 (Always)* 0 1* 0* 1 (Based on discriminant distance)* 0* 1 1 0* (Based on past, 2F, and discriminant distance)* 0 1* 1 1 (If there is an onset there)* 1 0* 0 0 (If there is an onset there)* 1 0 0 1* 1 0* 1* 0 (Based on discriminant distance)* 1 0* 1 1 (Always)* 1 1 0 0* 1 1 0* 1* (Based on 2F and discriminant distance)* 1 1 1* 0 (If there is an onset there)* 1 1 1 1** Determine if there is an onset transition between P and 1F.* OT (Onset Transition) is true if there is an onset between * P and 1F but not after 1F. OT = (AND(OBOUND(1), 2) .NE. 0 .OR. OBOUND(2) .EQ. 1) 1 .AND. AND(OBOUND(3), 1) .EQ. 0* Multi-way dispatch on voicing decision history: VSTATE = VOIBUF(1,1)*8 + VOIBUF(2,1)*4 + VOIBUF(1,2)*2 + VOIBUF(2,2) GOTO (99,1,2,99,4,5,6,7,8,99,10,11,99,13,14,99) VSTATE+11 IF (OT .AND. VOIBUF(1,3) .EQ. 1) VOIBUF(1,2) = 1 GOTO 992 IF (VOIBUF(1,3) .EQ. 0 .OR. 1 VOICE(1,2) .LT. -VOICE(2,2)) THEN VOIBUF(1,2) = 0 ELSE VOIBUF(2,2) = 1 END IF GOTO 994 VOIBUF(2,1) = 0 GOTO 995 IF (VOICE(2,1) .LT. -VOICE(1,2)) THEN VOIBUF(2,1) = 0 ELSE VOIBUF(1,2) = 1 END IF GOTO 99* VOIBUF(2,0) must be 06 IF (VOIBUF(1,0) .EQ. 1 .OR. 1 VOIBUF(1,3) .EQ. 1 .OR. 1 VOICE(2,2) .GT. VOICE(1,1)) THEN VOIBUF(2,2) = 1 ELSE VOIBUF(1,1) = 1 END IF GOTO 997 IF (OT) VOIBUF(2,1) = 0 GOTO 998 IF (OT) VOIBUF(2,1) = 1 GOTO 9910 IF (VOICE(1,2) .LT. -VOICE(2,1)) THEN VOIBUF(1,2) = 0 ELSE VOIBUF(2,1) = 1 END IF GOTO 9911 VOIBUF(2,1) = 1 GOTO 9913 IF (VOIBUF(1,3) .EQ. 0 .AND. VOICE(2,2) .LT. -VOICE(1,2)) THEN VOIBUF(2,2) = 0 ELSE VOIBUF(1,2) = 1 END IF GOTO 9914 IF (OT .AND. VOIBUF(1,3) .EQ. 0) VOIBUF(1,2) = 0* GOTO 9999 CONTINUE* Now update parameters:* ----------------------** During unvoiced half-frames, update the low band and full band unvoiced* energy estimates (LBUE and FBUE) and also the zero crossing* threshold (DITHER). (The input to the unvoiced energy filters is* restricted to be less than 10dB above the previous inputs of the* filters.)* During voiced half-frames, update the low-pass (LBVE) and all-pass * (FBVE) voiced energy estimates. IF (VOIBUF(HALF,3) .EQ. 0) THEN SFBUE = NINT(( 63*SFBUE + 8*MIN(FBE,3*OFBUE) )/64.) FBUE = SFBUE/8 OFBUE = FBE SLBUE = NINT(( 63*SLBUE + 8*MIN(LBE,3*OLBUE) )/64.) LBUE = SLBUE/8 OLBUE = LBE ELSE LBVE = NINT(( 63*LBVE + LBE )/64.) FBVE = NINT(( 63*FBVE + FBE )/64.) END IF* Set dither threshold to yield proper zero crossing rates in the* presence of low frequency noise and low level signal input.* NOTE: The divisor is a function of REF, the expected energies. DITHER = MIN(MAX( 64*SQRT(FLOAT(LBUE*LBVE)) / REF,1.),20.)* Print Test Data* IF( LISTL.GE.3 ) THEN* IF(HALF.EQ.1) WRITE(FDEBUG,930) VWIN,MINAMD,MAXAMD,MINTAU,IVRC*930 FORMAT(' Voicing:VWIN MINA MAXA MINTAU IVRC1 IVRC2'/* 1 5X,2I4,2F9.1,I8,2F7.3/* 1 ' HALF DISCR MAX/MIN LE/LVE ZC RC1 QS IVRC2'* 1 ' aR_B aR_F : DITH LBE FBE LBVE FBVE LBUE FBUE',* 1 ' SNR SNRL VS OT')* WRITE(FDEBUG,940) HALF, VOICE(HALF,3), (VALUE(I),I=1,8), DITHER,* 1 LBE, FBE, LBVE, FBVE, LBUE, FBUE,* 1 SNR, SNRL, VSTATE, OT*940 FORMAT(1X,I3,':',F8.0,F9.1,F7.3,F7.2,5F7.3,F5.1,6I6,F9.1,2I3,L3)* END IF* Voicing decisions are returned in VOIBUF. RETURN ENTRY INITVOICIN () FIRST = .TRUE. DITHER = 20 RETURN END@1.9log@Added a few comments about the accesses made to argument array VOIBUFand the local saved array VOICE.@text@d6 4d380 1a380 1 DO I = 1, 9@1.8log@Added an assignment to VSTATE that does not affect the function of theprogram at all. The only reason I put it in was so that the tracingstatements at the end, when enabled, will print a consistent value forVSTATE when HALF .EQ. 1, rather than a garbage value that could changefrom one call to the next.@text@d6 7d113 1d116 1a116 1* read (1,3) and write (1,2)d121 2a122 1* Read (HALF,3)d138 5@1.7log@Removed the inclusion of the file "vcomm.fh", and put its contentsinto this file. It was included nowhere else but here.@text@d6 4d377 7d531 1a531 1* 1 ' SNR SNRL VS OT')d535 1a535 1*940 FORMAT(1X,I3,':',F8.0,F9.1,F7.3,F7.2,5F7.3,F5.1,6I6,F5.1,2I3,L3)@1.6log@Commented out trace statements.@text@d6 3d169 13a181 1 INCLUDE 'vcomm.fh'a260 11* The following data statements initialize variables declared in* vcomm.fh (which is used nowhere else except this subroutine).* They are not Fortran PARAMETER's, but they are initialized with* DATA statements, and never modified. DATA NVDC/10/, NVDCL/5/ DATA VDCL/600,450,300,200,6*0/* The array VDC is not a Fortran PARAMETER, but it is an array* that is initialized with DATA statements, and never modified.d285 3@1.5log@Added comments about which indices of OBOUND and VOIBUF can beaccessed, and whether they are read or written. VOIBUF is fairlymessy.@text@d6 5d507 12a518 12 IF( LISTL.GE.3 ) THEN IF(HALF.EQ.1) WRITE(FDEBUG,930) VWIN,MINAMD,MAXAMD,MINTAU,IVRC930 FORMAT(' Voicing:VWIN MINA MAXA MINTAU IVRC1 IVRC2'/ 1 5X,2I4,2F9.1,I8,2F7.3/ 1 ' HALF DISCR MAX/MIN LE/LVE ZC RC1 QS IVRC2' 1 ' aR_B aR_F : DITH LBE FBE LBVE FBVE LBUE FBUE', 1 ' SNR SNRL VS OT') WRITE(FDEBUG,940) HALF, VOICE(HALF,3), (VALUE(I),I=1,8), DITHER, 1 LBE, FBE, LBVE, FBVE, LBUE, FBUE, 1 SNR, SNRL, VSTATE, OT940 FORMAT(1X,I3,':',F8.0,F9.1,F7.3,F7.2,5F7.3,F5.1,6I6,F5.1,2I3,L3) END IF@1.4log@Moved the DATA statements for the *VDC* variables later, as it isapparently illegal to have DATA statements before local variabledeclarations.@text@d6 5d89 1d93 9@1.3log@Heavily commented the local variables that are saved from oneinvocation to the next, and how the local variable FIRST is used toavoid the need to assign most of them initial values with DATAstatements.A few should be initialized, but aren't. I've guessed initial valuesfor two of these, SFBUE and SLBUE, and I've convinced myself that forVOICE, the effects of uninitialized values will die out after 2 or 3frame times. It would still be good to choose initial values forthese, but I don't know what reasonable values would be (0 comes tomind).@text@d6 13a147 36* The following data statements initialize variables declared in* vcomm.fh (which is used nowhere else except this subroutine).* They are not Fortran PARAMETER's, but they are initialized with* DATA statements, and never modified. DATA NVDC/10/, NVDCL/5/ DATA VDCL/600,450,300,200,6*0/* The array VDC is not a Fortran PARAMETER, but it is an array* that is initialized with DATA statements, and never modified.* Voicing Decision Parameter vector (* denotes zero coefficient):** * MAXMIN* LBE/LBVE* ZC* RC1* QS* IVRC2* aR_B* aR_F* * LOG(LBE/LBVE)* Define 2-D voicing decision coefficient vector according to the voicing* parameter order above. Each row (VDC vector) is optimized for a specific* SNR. The last element of the vector is the constant.* E ZC RC1 Qs IVRC2 aRb aRf c DATA VDC/ 1 0, 1714, -110, 334, -4096, -654, 3752, 3769, 0, 1181, 1 0, 874, -97, 300, -4096, -1021, 2451, 2527, 0, -500, 1 0, 510, -70, 250, -4096, -1270, 2194, 2491, 0, -1500, 1 0, 500, -10, 200, -4096, -1300, 2000, 2000, 0, -2000, 1 0, 500, 0, 0, -4096, -1300, 2000, 2000, 0, -2500, 1 50*0/d225 36@1.2log@Comments added explaining which of the local variables of thissubroutine need to be saved from one invocation to the next, and whichdo not.WARNING! Some of them that should are never given initial values inthis code. Hopefully, Fortran 77 defines initial values for them, buteven so, giving them explicit initial values is preferable.WARNING! VALUE(9) is used, but never assigned a value. It shouldprobably be eliminated from the code.@text@d6 12d56 54a109 46* Inputs:* VWIN - Voicing window limits* INBUF - Input speech buffer* LPBUF - Low-pass filtered speech buffer* BUFLIM - INBUF and LPBUF limits* HALF - Present analysis half frame number* MINAMD - Minimum value of the AMDF* MAXAMD - Maximum value of the AMDF* MINTAU - Pointer to the lag of the minimum AMDF value* IVRC(2) - Inverse filter's RC's* OBOUND - Onset boundary descriptions* AF - The analysis frame number* Output:* VOIBUF(2,0:AF) - Buffer of voicing decisions* Internal:* QS - Ratio of preemphasized to full-band energies* RC1 - First reflection coefficient* AR_B - Product of the causal forward and reverse pitch prediction gains* AR_F - Product of the noncausal forward and rev. pitch prediction gains* ZC - Zero crossing rate* DITHER - Zero crossing threshold level* MAXMIN - AMDF's 1 octave windowed maximum-to-minimum ratio* MINPTR - Location of minimum AMDF value* NVDC - Number of elements in each VDC vector* NVDCL - Number of VDC vectors* VDCL - SNR values corresponding to the set of VDC's* VDC - 2-D voicing decision coefficient vector* VALUE(9) - Voicing Parameters* VOICE(2,3)- History of LDA results* LBE - Ratio of low-band instantaneous to average energies* FBE - Ratio of full-band instantaneous to average energies* LBVE - Low band voiced energy* LBUE - Low band unvoiced energy* FBVE - Full band voiced energy* FBUE - Full band unvoiced energy* OFBUE - Previous full-band unvoiced energy* OLBUE - Previous low-band unvoiced energy* REF - Reference energy for initialization and DITHER threshold* SNR - Estimate of signal-to-noise ratio* SNR2 - Estimate of low-band signal-to-noise ratio* SNRL - SNR level number* OT - Onset transition present* VSTATE - Decimal interpretation of binary voicing classifications* FIRST - First call flaga115 1 INCLUDE 'vcomm.fh'd117 1a117 1* Parametersd128 1a128 1* Local variablesd130 2a131 7 INTEGER ZC, LBE, FBE INTEGER I, SNRL, VSTATE REAL DITHER, SNR, SNR2 REAL MAXMIN, QS, RC1, AR_B, AR_F REAL VOICE(2,3) REAL VALUE(9) LOGICAL OTd133 1a133 6* NO SAVE NECESSARY ZC, LBE, FBE* NO SAVE NECESSARY I, SNRL, VSTATE* NO SAVE NECESSARY SNR2* NO SAVE NECESSARY QS, RC1, AR_B, AR_F* NO SAVE NECESSARY VALUE* NO SAVE NECESSARY OTd135 4a138 3 SAVE DITHER, SNR SAVE MAXMIN SAVE VOICEd140 1a140 26* WARNING!* * VOICE, SFBUE, and SLBUE should be saved from one invocation to* the next, but they are never given an initial value, like all of* the other local variables that should similarly be saved.* * Does Fortran 77 specify some default initial value, like 0, or* is it undefined? If it is undefined, then this code should be* corrected to specify an initial value.* * Also, while VALUE(1) through VALUE(8) are assigned values,* VALUE(9) never is. Yet, VALUE(9) is read in the loop that* begins "DO I = 1, 9" below. If this value is automatically* initialized to 0, then it has no detrimental effect, but if it* is undefined, it could have an unpredictable and detrimental* effect on the behavior of this code. I would recommend changing* the loop to "DO I = 1, 8".* Declare and initialize filters: INTEGER LBVE, LBUE, FBVE, FBUE, OFBUE, OLBUE, SFBUE, SLBUE INTEGER REF PARAMETER (REF = 3000) LOGICAL FIRST DATA FIRST /.TRUE./, DITHER/20/, NVDC/10/, NVDCL/5/d143 2a144 2 SAVE LBVE, LBUE, FBVE, FBUE, OFBUE, OLBUE, SFBUE, SLBUE SAVE FIRSTd171 79d255 1d258 1d490 9@1.1log@Initial revision@text@d5 4a8 1* $Log$d98 3a100 3 REAL MINAMD, MAXAMD INTEGER VWIN(2), BUFLIM(4), HALF, MINTAU INTEGER AF, OBOUND(AF)d103 8a110 1 INTEGER VOIBUF(2,0:AF)d113 2a114 3 REAL DITHER, SNR, SNR2, IVRC(2) REAL MAXMIN, QS, RC1, AR_B REAL AR_Fd119 29d157 3@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -