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

📄 vq_lib.c

📁 It is source code for Melp2.4kps vocoder using dsp tms320vc55x of ti
💻 C
字号:
/*

*2.4 kbps MELP Proposed Federal Standard speech coder
*
*TMS320C5x assembly code
*
*version 1.0
*
*Copyright (c) 1998, Texas Instruments, Inc.  
*
*Texas Instruments has intellectual property rights on the MELP
*algorithm.  The Texas Instruments contact for licensing issues for
*commercial and non-government use is William Gordon, Director,
*Government Contracts, Texas Instruments Incorporated, Semiconductor
*Group (phone 972 480 7442).

*/

/*************************************************************************
*
* The following code was hand optimized for the Texas Instuments
* TMS320C5x DSP by DSPCon, Inc.  For information, please contact DSPCon
* at:
* 
*                       DSPCon, Inc.
*                       380 Foothill Road
*                       Bridgewater, New Jersey 08807
*                       (908) 722-5656
*                       info@dspcon.com
*                       www.dspcon.com
*
*************************************************************************/



#include "spbstd.h"
#include "mathhalf.h"
#include "mat.h"
#include "math_lib.h"
#include "lpc.h"
#include "vq.h"



/* VQ_LSPW- compute LSP weighting vector-

    Atal's method:
	From Atal and Paliwal (ICASSP 1991)
	(Note: Paliwal and Atal used w(k)^2(u(k)-u_hat(k))^2,
	 and we use w(k)(u(k)-u_hat(k))^2 so our weights are different
	 but the method (i.e. the weighted MSE) is the same.

		*/
/* Q values:
   w is Q11
   lsp is Q15
   a is Q12 */

#define X064_Q15 (Shortword)(0.64*((Longword)1<<15))
#define X016_Q15 (Shortword)(0.16*((Longword)1<<15))
#define XN03_Q15 (Shortword)(-0.3*((Longword)1<<15))

Shortword *vq_lspw(Shortword *w, Shortword *lsp, Shortword *a,
		   Shortword p)
{
    Shortword j;
    Longword L_temp;

    for(j = 0; j < p; j++)
      {
	L_temp = lpc_aejw(a,lsp[j],p);    /* L_temp in Q19 */

	w[j] = L_pow_fxp(L_temp,(Shortword)XN03_Q15,19,11);

	if (j == 8)
	  w[j] = mult(w[j], (Shortword)X064_Q15);
	else if (j == 9)
	  w[j] = mult(w[j], (Shortword)X016_Q15);

      }

    return(w);
} /* VQ_LSPW */




/* VQ_FSW -
   compute the weights for Euclidean distance of Fourier harmonics  */
/* Q values:
   w_fs - Q14
   pitch - Q9 */

#define EIGHT_Q11  (8*(1<<11))
#define X14_Q14    (1.4*(1<<14))
#define ONE_Q28    ((Longword)1<<28)
#define X069_Q15   (Shortword)(0.69*((Longword)1<<15))
#define X75_Q8     (75*(1<<8))
#define X25_Q6     (25*(1<<6))
#define X117_Q5    (117*(1<<5))


void vq_fsw(Shortword *w_fs, Shortword num_harm, Shortword pitch)
{

    Shortword j;
    Shortword tempw0;
    Shortword temp,denom;
    Longword L_temp;

    /* Calculate fundamental frequency */
    /* w0 = TWOPI/pitch */
    /* tempw0 = w0/(0.25*PI) = 8/pitch */
    tempw0 = divide_s((Shortword)EIGHT_Q11,pitch);   /* tempw0 in Q17 */
    for(j=0; j < num_harm; j++) {

      /* Bark-scale weighting */
      /* w_fs[j] = 117.0 / (25.0 + 75.0*
		   pow(1.0 + 1.4*SQR(w0*(j+1)/(0.25*PI)),0.69)) */

      temp = shl(add(j,1),11);    /* Q11 */
      temp = extract_h(L_shl(L_mult(tempw0,temp),1));    /* Q14 */
      temp = mult(temp,temp);    /* Q13 */
      L_temp = L_add(ONE_Q28,L_mult((Shortword)X14_Q14,temp));     /* Q28 */
      temp = L_pow_fxp(L_temp,(Shortword)X069_Q15,28,13);     /* Q13 */
      denom = add(X25_Q6,mult(X75_Q8,temp));     /* Q6 */
      w_fs[j] = divide_s(X117_Q5,denom);    /* Q14 */    
    }
}

⌨️ 快捷键说明

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