sp_coef.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:141k
源码类别:

MTK

开发平台:

C++ Builder

  1.     fprintf( fp, "%dn", CoeffLength);
  2.     for (int i=0; i<CoeffLength; i++)
  3.     {
  4.        fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i] );
  5.     }
  6.     fclose(fp);
  7.     return true;
  8. }
  9. //==============================================================================
  10. //////////////////////         16k            //////////////////////////////////
  11. //==============================================================================
  12. //=============================================================================
  13. /////////////////////////////////////// FIR 1 /////////////////////////////////
  14. //=============================================================================
  15. bool CSPCOEF::REQ_Read_16k_FIR1_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  16. {
  17.     m_eAudioParamType = e_audio_para_type;
  18.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  19.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  20.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  21.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  22.         )
  23.     {
  24.         return false;
  25.     }
  26.     FILE *fp;
  27.     bool IsEof;
  28.     int i;
  29.     fp = fopen(filename, "r");
  30.     if (NULL == fp)
  31.     {
  32.         return false;
  33.     }
  34.     if (!feof(fp))
  35.     {
  36.        fscanf(fp, "%d", &m_iCoeffLen);
  37.     }
  38.     i=0; // initialize i
  39.     int coeff;
  40.     while(!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
  41.     {
  42.         fscanf(fp, "%d", &coeff);
  43.         m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i] = (short) coeff;
  44.         i++;
  45.     }
  46.     for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  47.     {
  48.         m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i]=0;
  49.     }
  50.     fclose(fp);
  51.     return true;
  52. }
  53. //---------------------------------------------------------------------------
  54. bool CSPCOEF::REQ_Write_16k_FIR1_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  55. {
  56.     m_eAudioParamType = e_audio_para_type;
  57.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  58.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  59.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  60.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  61.         )
  62.     {
  63.         return false;
  64.     }
  65.     FILE *fp;
  66.     int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
  67.     fp = fopen(filename, "w");
  68.     if(fp == NULL)
  69.     return false;
  70.     for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  71.     {
  72.         if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i])
  73.         {
  74.             CoeffLength = i;
  75.             break;
  76.         }
  77.     }
  78.     fprintf(fp, "%dn", CoeffLength);
  79.     for (int i=0; i<CoeffLength; i++)
  80.     {
  81.        fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i]);
  82.     }
  83.     fclose(fp);
  84.     return true;
  85. }
  86. //===========================================================================
  87. bool CSPCOEF::REQ_Read_16k_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  88. {
  89.     m_eAudioParamType = e_audio_para_type;
  90.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  91.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  92.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  93.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  94.         )
  95.     {
  96.         return false;
  97.     }
  98.     FILE *fp;
  99.     bool IsEof;
  100.     int i=0;
  101.     fp = fopen(filename, "r");
  102.     if (NULL == fp)
  103.     {
  104.         return false;
  105.     }
  106.     if (!feof(fp))
  107.     {
  108.        fscanf( fp, "%d", &m_iCoeffLen);
  109.     }
  110.     i=0; // initialize i
  111.     int coeff;
  112.     while (!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
  113.     {
  114.         fscanf( fp, "%d", &coeff );
  115.         m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i] = (short) coeff;
  116.         i++;
  117.     }
  118.     for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  119.     {
  120.         m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i] = 0;
  121.     }
  122.     fclose(fp);
  123.     return true;
  124. }
  125. //===========================================================================
  126. bool CSPCOEF::REQ_Write_16k_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  127. {
  128.     m_eAudioParamType = e_audio_para_type;
  129.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  130.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  131.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  132.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  133.         )
  134.     {
  135.         return false;
  136.     }
  137.     FILE *fp;
  138.     int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
  139.     fp = fopen(filename, "w");
  140.     if (NULL == fp)
  141.     {
  142.         return false;
  143.     }
  144.     for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  145.     {
  146.         if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i])
  147.         {
  148.             CoeffLength = i;
  149.             break;
  150.         }
  151.     }
  152.     fprintf(fp, "%dn", CoeffLength);
  153.     for (int i=0; i<CoeffLength; i++)
  154.     {
  155.         fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i]);
  156.     }
  157.     fclose(fp);
  158.     return true;
  159. }
  160. //==============================================================================
  161. /////////////////////////////////////// FIR 2 //////////////////////////////////
  162. //==============================================================================
  163. bool CSPCOEF::REQ_Read_16k_FIR2_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  164. {
  165.     m_eAudioParamType = e_audio_para_type;
  166.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  167.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  168.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  169.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  170.         )
  171.     {
  172.         return false;
  173.     }
  174.     FILE *fp;
  175.     bool IsEof;
  176.     int i;
  177.     fp = fopen(filename, "r");
  178.     if (NULL == fp)
  179.     {
  180.         return false;
  181.     }
  182.     if (!feof(fp))
  183.     {
  184.         fscanf( fp, "%d", &m_iCoeffLen);
  185.     }
  186.     i=0; // initialize i
  187.     int coeff;
  188.     while(!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
  189.     {
  190.         fscanf( fp, "%d", &coeff);
  191.         m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i] = (short) coeff;
  192.         i++;
  193.     }
  194.     for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  195.     {
  196.         m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i]=0;
  197.     }
  198.     fclose(fp);
  199.     return true;
  200. }
  201. //---------------------------------------------------------------------------
  202. bool CSPCOEF::REQ_Write_16k_FIR2_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  203. {
  204.     m_eAudioParamType = e_audio_para_type;
  205.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  206.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  207.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  208.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  209.         )
  210.     {
  211.         return false;
  212.     }
  213.     FILE *fp;
  214.     int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
  215.     fp = fopen(filename, "w");
  216.     if(fp == NULL)
  217.     return false;
  218.     for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  219.     {
  220.        if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i])
  221.        {
  222.           CoeffLength = i;
  223.           break;
  224.        }
  225.     }
  226.     fprintf(fp, "%dn", CoeffLength);
  227.     for (int i=0; i<CoeffLength; i++)
  228.     {
  229.        fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i] );
  230.     }
  231.     fclose(fp);
  232.     return true;
  233. }
  234. //===========================================================================
  235. bool CSPCOEF::REQ_Read_16k_FIR2_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  236. {
  237.     m_eAudioParamType = e_audio_para_type;
  238.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  239.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  240.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  241.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  242.         )
  243.     {
  244.         return false;
  245.     }
  246.     FILE *fp;
  247.     bool IsEof;
  248.     int i=0;
  249.     fp = fopen(filename, "r");
  250.     if (NULL == fp)
  251.     {
  252.         return false;
  253.     }
  254.     if (!feof(fp))
  255.     {
  256.        fscanf( fp, "%d", &m_iCoeffLen);
  257.     }
  258.     i=0; // initialize i
  259.     int coeff;
  260.     while(!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
  261.     {
  262.         fscanf(fp, "%d", &coeff);
  263.         m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i] = (short) coeff;
  264.         i++;
  265.     }
  266.     for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  267.     {
  268.         m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i] = 0;
  269.     }
  270.     fclose(fp);
  271.     return true;
  272. }
  273. //===========================================================================
  274. bool CSPCOEF::REQ_Write_16k_FIR2_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  275. {
  276.     m_eAudioParamType = e_audio_para_type;
  277.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  278.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  279.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  280.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  281.         )
  282.     {
  283.         return false;
  284.     }
  285.     FILE *fp;
  286.     int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
  287.     fp = fopen(filename, "w");
  288.     if(fp == NULL)
  289.     return false;
  290.     for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  291.     {
  292.        if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i])
  293.        {
  294.             CoeffLength = i;
  295.             break;
  296.        }
  297.     }
  298.     fprintf(fp, "%dn", CoeffLength);
  299.     for (int i=0; i<CoeffLength; i++)
  300.     {
  301.        fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i]);
  302.     }
  303.     fclose(fp);
  304.     return true;
  305. }
  306. //===========================================================================
  307. ///////////////////   Speech input FIR coefficient    ///////////////////////
  308. //===========================================================================
  309. bool CSPCOEF::REQ_Read_Speech_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode)
  310. {
  311.     m_eAudioParamType = e_audio_para_type;
  312.     if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
  313.     {
  314.         return false;
  315.     }
  316.     FILE *fp;
  317.     bool IsEof;
  318.     int i=0;
  319.     fp = fopen(filename, "r");
  320.     if(fp == NULL)
  321.     return false;
  322.     if(!feof(fp))
  323.     {
  324.         fscanf( fp, "%d", &m_iCoeffLen);
  325.     }
  326.     i=0; // initialize i
  327.     int coeff;
  328.     while ((!feof(fp)) && (i< m_iCoeffLen) && (i < SPEECH_FIR_45_TAPS_NUM))
  329.     {
  330.         fscanf(fp, "%d", &coeff);
  331.         m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i] = (short) coeff;
  332.         i++;
  333.     }
  334.     for (i=m_iCoeffLen; i<SPEECH_FIR_45_TAPS_NUM; i++)
  335.     {
  336.         m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i] = 0;
  337.     }
  338.     fclose(fp);
  339.     return true;
  340. }
  341. //--------------------------------------------------------------------------
  342. bool CSPCOEF::REQ_Write_Speech_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode )
  343. {
  344.     m_eAudioParamType = e_audio_para_type;
  345.     if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
  346.     {
  347.         return false;
  348.     }
  349.     FILE *fp;
  350.     fp = fopen(filename, "w");
  351.     if (NULL == fp)
  352.     {
  353.         return false;
  354.     }
  355.     int CoeffLength;
  356.     for (int i=0; i<SPEECH_FIR_45_TAPS_NUM; i++)
  357.     {
  358.         if (0 == m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i])
  359.         {
  360.             CoeffLength = i;
  361.             break;
  362.         }
  363.     }
  364.     fprintf(fp, "%dn", CoeffLength);
  365.     for (int i=0; i<CoeffLength; i++)
  366.     {
  367.         fprintf(fp, "%dn", m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i]);
  368.     }
  369.     fclose(fp);
  370.     return true;
  371. }
  372. //===========================================================================
  373. ///////////////////   Speech output FIR coefficient    ///////////////////////
  374. //===========================================================================
  375. bool CSPCOEF::REQ_Read_Speech_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode)
  376. {
  377.     m_eAudioParamType = e_audio_para_type;
  378.     if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
  379.         (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
  380.         )
  381.     {
  382.         return false;
  383.     }
  384.     FILE *fp;
  385.     bool IsEof;
  386.     int i=0;
  387.     fp = fopen(filename, "r");
  388.     if (NULL == fp)
  389.     {
  390.         return false;
  391.     }
  392.     if (!feof(fp))
  393.     {
  394.         fscanf(fp, "%d", &m_iCoeffLen);
  395.     }
  396.     i=0; // initialize i
  397.     int coeff;
  398.     while (!feof(fp) && (i < m_iCoeffLen) && (i < SPEECH_FIR_45_TAPS_NUM))
  399.     {
  400.         fscanf(fp, "%d", &coeff);
  401.         m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i] = (short) coeff;
  402.         i++;
  403.     }
  404.     for (i=m_iCoeffLen; i<SPEECH_FIR_45_TAPS_NUM; i++)
  405.     {
  406.         m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i] = 0;
  407.     }
  408.     fclose(fp);
  409.     return true;
  410. }
  411. //---------------------------------------------------------------------------
  412. bool CSPCOEF::REQ_Write_Speech_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode)
  413. {
  414.     m_eAudioParamType = e_audio_para_type;
  415.     if ((AUDIO_FIR_VER_ORG   == m_eAudioParamType) ||
  416.         (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
  417.         )
  418.     {
  419.         return false;
  420.     }
  421.     FILE *fp;
  422.     fp = fopen(filename, "w");
  423.     if (fp == NULL)
  424.     {
  425.         return false;
  426.     }
  427.     int CoeffLength = SPEECH_FIR_45_TAPS_NUM;
  428.     for (int i=0; i<SPEECH_FIR_45_TAPS_NUM; i++)
  429.     {
  430.         if (0 == m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i])
  431.         {
  432.             CoeffLength = i;
  433.             break;
  434.         }
  435.     }
  436.     fprintf(fp, "%dn", CoeffLength);
  437.     for (int i=0; i<CoeffLength; i++)
  438.     {
  439.         fprintf(fp, "%dn", m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i]);
  440.     }
  441.     fclose(fp);
  442.     return true;
  443. }
  444. //******************************************************************************
  445. //*******************         Melody                         *******************
  446. //******************************************************************************
  447. //============================================================================
  448. /////////////////////////////////////// FIR 1 ////////////////////////////////
  449. //============================================================================
  450. //===========================================================================
  451. bool CSPCOEF::REQ_Read_Melody_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  452. {
  453.     FILE *fp;
  454.     bool IsEof;
  455.     int i=0;
  456.     fp = fopen(filename, "r");
  457.     if (NULL == fp)
  458.     {
  459.         return false;
  460.     }
  461.     if (!feof(fp))
  462.     {
  463.         fscanf(fp, "%d", &m_iCoeffLen);
  464.     }
  465.     m_eAudioParamType = e_audio_para_type;
  466.     if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
  467.     {
  468.         i=0; // initialize i
  469.         int coeff;
  470.         while ((!feof(fp)) && (i < m_iCoeffLen) && (i < MELODY_FIR_COEFF_45_TAPS_NUM))
  471.         {
  472.             fscanf(fp, "%d", &coeff);
  473.             m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = (short) coeff;
  474.             i++;
  475.         }
  476.         for (i=m_iCoeffLen; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  477.         {
  478.             m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = 0;
  479.         }
  480.     }
  481.     else // W0547_45_TAP, W0712, W0740, W0809
  482.     {
  483.         i=0; // initialize i
  484.         int coeff;
  485.         int tap_num;
  486.         if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  487.         {
  488.             tap_num = MELODY_FIR_COEFF_45_TAPS_NUM;
  489.         }
  490.         else
  491.         {
  492.             tap_num = MELODY_FIR_COEFF_25_TAPS_NUM;
  493.         }
  494.         while ((!feof(fp)) && (i < m_iCoeffLen) && (i < tap_num))
  495.         {
  496.             fscanf(fp, "%d", &coeff);
  497.             m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = (short) coeff;
  498.             i++;
  499.         }
  500.         for (i=m_iCoeffLen; i<tap_num; i++)
  501.         {
  502.             m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = 0;
  503.         }
  504.     }
  505.     fclose(fp);
  506.     return true;
  507. }
  508. //--------------------------------------------------------------------------
  509. bool CSPCOEF::REQ_Write_Melody_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  510. {
  511.     m_eAudioParamType = e_audio_para_type;
  512.     FILE *fp;
  513.     int CoeffLength;
  514.     if ((AUDIO_FIR_VER_ORG          == m_eAudioParamType) ||
  515.         (AUDIO_FIR_VER_W0547        == m_eAudioParamType) ||
  516.         (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  517.        )
  518.     {
  519.         CoeffLength= MELODY_FIR_COEFF_45_TAPS_NUM;
  520.     }
  521.     else // W0712, W0740, W0809
  522.     {
  523.         CoeffLength= MELODY_FIR_COEFF_25_TAPS_NUM;
  524.     }
  525.     fp = fopen(filename, "w");
  526.     if (NULL == fp)
  527.     {
  528.         return false;
  529.     }
  530.     if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
  531.     {
  532.         for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  533.         {
  534.             if (0 == m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i])
  535.             {
  536.                 CoeffLength = i;
  537.                 break;
  538.             }
  539.         }
  540.         fprintf(fp, "%dn", CoeffLength);
  541.         for(int i=0; i<CoeffLength; i++)
  542.         {
  543.             fprintf(fp, "%dn", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
  544.         }
  545.     }
  546.     else // W0547_45_TAP, W0712, W0740, W0809
  547.     {
  548.         short* p_melody_fir;
  549.         int tap_num;
  550.         if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  551.         {
  552.             tap_num = MELODY_FIR_COEFF_45_TAPS_NUM;
  553.         }
  554.         else
  555.         {
  556.             tap_num = MELODY_FIR_COEFF_25_TAPS_NUM;
  557.         }
  558.         for (int i=0; i<tap_num; i++)
  559.         {
  560.             if (0 == m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i])
  561.             {
  562.                 CoeffLength = i;
  563.                 break;
  564.             }
  565.         }
  566.         fprintf(fp, "%dn", CoeffLength);
  567.         for (int i=0; i<CoeffLength; i++)
  568.         {
  569.             fprintf(fp, "%dn", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
  570.         }
  571.     }
  572.     fclose(fp);
  573.     return true;
  574. }
  575. //============================================================================
  576. /////////////////////////////////////// FIR 2 ////////////////////////////////
  577. //============================================================================
  578. bool CSPCOEF::REQ_Read_Melody_FIR2_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  579. {
  580.     m_eAudioParamType = e_audio_para_type;
  581.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  582.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  583.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  584.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  585.         )
  586.     {
  587.         return false;
  588.     }
  589.     FILE *fp;
  590.     bool IsEof;
  591.     int i=0;
  592.     fp = fopen(filename, "r");
  593.     if(fp == NULL)
  594.     {
  595.         return false;
  596.     }
  597.     if (!feof(fp))
  598.     {
  599.         fscanf(fp, "%d", &m_iCoeffLen);
  600.     }
  601.     for (i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  602.     {
  603.         m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = 0;
  604.     }
  605.     i=0; // initialize i
  606.     int coeff;
  607.     while ((!feof(fp)) && (i < m_iCoeffLen) && (i < MELODY_FIR_COEFF_45_TAPS_NUM))
  608.     {
  609.         fscanf(fp, "%d", &coeff);
  610.         m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = (short) coeff;
  611.         i++;
  612.     }
  613.     fclose(fp);
  614.     return true;
  615. }
  616. //---------------------------------------------------------------------------
  617. bool CSPCOEF::REQ_Write_Melody_FIR2_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  618. {
  619.     m_eAudioParamType = e_audio_para_type;
  620.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  621.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  622.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  623.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  624.         )
  625.     {
  626.         return false;
  627.     }
  628.     FILE *fp;
  629.     int CoeffLength = MELODY_FIR_COEFF_45_TAPS_NUM;
  630.     fp = fopen(filename, "w");
  631.     if (NULL == fp)
  632.     {
  633.         return false;
  634.     }
  635.     for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  636.     {
  637.        if (0 == m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i])
  638.        {
  639.           CoeffLength = i;
  640.           break;
  641.        }
  642.     }
  643.     fprintf(fp, "%dn", CoeffLength);
  644.     for (int i=0; i<CoeffLength; i++)
  645.     {
  646.        fprintf(fp, "%dn", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
  647.     }
  648.     fclose(fp);
  649.     return true;
  650. }
  651. //==============================================================================
  652. /////////////////////////////////////// 8k addtional FIR 1 /////////////////////
  653. //==============================================================================
  654. bool  CSPCOEF::REQ_Read_8k_Additional_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, int index)
  655. {
  656.     m_eAudioParamType = e_audio_para_type;
  657.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  658.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  659.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  660.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  661.         )
  662.     {
  663.         return false;
  664.     }
  665.     FILE *fp;
  666.     bool IsEof;
  667.     fp = fopen(filename, "r");
  668.     if (fp == NULL)
  669.     {
  670.         return false;
  671.     }
  672.     for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
  673.     {
  674.         m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i]=0;
  675.     }
  676.     if (!feof(fp))
  677.     {
  678.         fscanf(fp, "%d", &m_iCoeffLen);
  679.     }
  680.     int i=0;
  681.     int coeff;
  682.     while((!feof(fp)) && (i < m_iCoeffLen))
  683.     {
  684.         fscanf( fp, "%d", &coeff);
  685.         m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i] = (short)coeff;
  686.         i++;
  687.     }
  688.    fclose(fp);
  689.    return true;
  690. }
  691. //--------------------------------------------------------------------------
  692. bool CSPCOEF::REQ_Write_8k_Additional_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, int index)
  693. {
  694.     m_eAudioParamType = e_audio_para_type;
  695.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  696.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  697.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  698.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  699.         )
  700.     {
  701.         return false;
  702.     }
  703.     FILE *fp;
  704.     int CoeffLength = SPEECH_FIR_30_TAPS_NUM;
  705.     fp = fopen(filename, "w");
  706.     if (fp == NULL)
  707.     {
  708.         return false;
  709.     }
  710.     for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
  711.     {
  712.         if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i])
  713.         {
  714.             CoeffLength = i;
  715.             break;
  716.         }
  717.     }
  718.     fprintf(fp, "%dn", CoeffLength);
  719.     for (int i=0; i<CoeffLength; i++)
  720.     {
  721.         fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i]);
  722.     }
  723.     fclose(fp);
  724.     return true;
  725. }
  726. //===========================================================================
  727. /////////////////////////////// audio compensation //////////////////////////
  728. //===========================================================================
  729. bool CSPCOEF::REQ_Read_Audio_Compensation_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, E_AUDIO_COMPENSATION_IDX_T type)
  730. {
  731.     m_eAudioParamType = e_audio_para_type;
  732.     if ((AUDIO_FIR_VER_ORG          == m_eAudioParamType) ||
  733.         (AUDIO_FIR_VER_W0547        == m_eAudioParamType) ||
  734.         (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  735.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType)
  736.         )
  737.     {
  738.         return false;
  739.     }
  740.     FILE *fp;
  741.     bool IsEof;
  742.     fp = fopen(filename, "r");
  743.     if (NULL == fp)
  744.     {
  745.         return false;
  746.     }
  747.     for (int i=0; i<AUDIO_COMPENSATION_TAPS_NUM; i++)
  748.     {
  749.         m_sFirCoeff.s_audio_compensation_coeff[type][i] = 0;
  750.     }
  751.     if (!feof(fp))
  752.     {
  753.         fscanf(fp, "%d", &m_iCoeffLen);
  754.     }
  755.     int i=0; // initialize i
  756.     int coeff;
  757.     while((!feof(fp)) && (i < m_iCoeffLen))
  758.     {
  759.         fscanf(fp, "%d", &coeff);
  760.         m_sFirCoeff.s_audio_compensation_coeff[type][i] = (short)coeff;
  761.         i++;
  762.     }
  763.     fclose(fp);
  764.     return true;
  765. }
  766. //---------------------------------------------------------------------------
  767. bool CSPCOEF::REQ_Write_Audio_Compensation_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, E_AUDIO_COMPENSATION_IDX_T type)
  768. {
  769.     m_eAudioParamType = e_audio_para_type;
  770.     if ((AUDIO_FIR_VER_ORG          == m_eAudioParamType) ||
  771.         (AUDIO_FIR_VER_W0547        == m_eAudioParamType) ||
  772.         (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  773.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType)
  774.         )
  775.     {
  776.         return false;
  777.     }
  778.     FILE *fp;
  779.     int CoeffLength = AUDIO_COMPENSATION_TAPS_NUM;
  780.     fp = fopen(filename, "w");
  781.     if (NULL == fp)
  782.     {
  783.         return false;
  784.     }
  785.     for (int i=0; i<AUDIO_COMPENSATION_TAPS_NUM; i++)
  786.     {
  787.         if (0 == m_sFirCoeff.s_audio_compensation_coeff[type][i])
  788.         {
  789.             CoeffLength = i;
  790.             break;
  791.         }
  792.     }
  793.     fprintf(fp, "%dn", CoeffLength);
  794.     for (int i=0; i<CoeffLength; i++)
  795.     {
  796.         fprintf(fp, "%dn", m_sFirCoeff.s_audio_compensation_coeff[type][i]);
  797.     }
  798.     fclose(fp);
  799.     return true;
  800. }
  801. //---------------------------------------------------------------------------
  802. bool CSPCOEF::REQ_Write_To_AudcoeffC(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  803. {
  804.     m_eAudioParamType = e_audio_para_type;
  805.     FILE *fs;
  806.     fs = fopen(filename, "w");
  807.     if (NULL == fs)
  808.     {
  809.         return false;
  810.     }
  811.    // fprintf( fs, "#include "l1audio.h"nn");
  812.    // if (AUDIO_FIR_VER_ORG != m_eAudioParamType)
  813.    // {
  814.    //     fprintf( fs, "#include "audcoeff_default.h"nn");
  815.    // }
  816.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  817.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  818.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType) ||
  819.         (AUDIO_FIR_VER_W0809        == m_eAudioParamType)
  820.         )
  821.     {
  822.       //  fprintf(fs, "const unsigned char  L1SP_MICROPHONE1  = L1SP_LNA_0;n");
  823.       //  fprintf(fs, "const unsigned char  L1SP_MICROPHONE2  = L1SP_LNA_1;nn");
  824.       //  fprintf(fs, "const unsigned char  L1SP_SPEAKER1     = L1SP_BUFFER_0;n");
  825.       //  fprintf(fs, "const unsigned char  L1SP_SPEAKER2     = L1SP_BUFFER_ST;n");
  826.       //  fprintf(fs, "const unsigned char  L1SP_LOUD_SPEAKER = L1SP_BUFFER_ST|L1SP_BUFFER_EXT;nn");
  827.         // SIFC
  828.         char SIFC_comment[][128] =
  829.         {
  830.             "   { /* 0: Input FIR coefficients for 2G/3G Normal mode */n",
  831.             "   { /* 1: Input FIR coefficients for 2G/3G/VoIP Headset mode */n",
  832.             "   { /* 2: Input FIR coefficients for 2G/3G Handfree mode */n",
  833.             "   { /* 3: Input FIR coefficients for 2G/3G/VoIP BT mode */n",
  834.             "   { /* 4: Input FIR coefficients for VoIP Normal mode */n",
  835.             "   { /* 5: Input FIR coefficients for VoIP Handfree mode */n"
  836.         };
  837.         fprintf(fs, "const signed short Speech_Input_FIR_Coeff[6][45] = {n");
  838.         for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
  839.         {
  840.             fprintf(fs, "%s", SIFC_comment[i]);
  841.             for (int j=0; j<SPEECH_FIR_45_TAPS_NUM; j++)
  842.             {
  843.                 if (j % 5 == 0)
  844.                 {
  845.                     fprintf(fs, "   ");
  846.                 }
  847.                 fprintf(fs, "%6d", m_sFirCoeff.s_speech_input_FIR_coeffs[i][j]);
  848.                 if (j != SPEECH_FIR_45_TAPS_NUM - 1)
  849.                 {
  850.                     fprintf(fs, ",");
  851.                 }
  852.                 if (j % 5 == 4)
  853.                 {
  854.                     fprintf(fs, "n");
  855.                 }
  856.             }
  857.             if (i != SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM-1 )
  858.             {
  859.                 fprintf(fs, "   },n");
  860.             }
  861.             else
  862.             {
  863.                 fprintf(fs, "   }n");
  864.             }
  865.         }
  866.         fprintf(fs, "};nn");
  867.         // SOFC
  868.         char SOFC_comment[][128] =
  869.         {
  870.             "   { /* 0: Output FIR coefficients for 2G/3G Normal mode */n",
  871.             "   { /* 1: Output FIR coefficients for 2G/3G/VoIP Headset mode */n",
  872.             "   { /* 2: Output FIR coefficients for 2G/3G Handfree mode */n",
  873.             "   { /* 3: Output FIR coefficients for 2G/3G/VoIP BT mode */n",
  874.             "   { /* 4: Output FIR coefficients for VoIP Normal mode */n",
  875.             "   { /* 5: Output FIR coefficients for VoIP Handfree mode */n"
  876.         };
  877.         fprintf(fs, "const signed short Speech_Output_FIR_Coeff[6][45] = {n");
  878.         for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
  879.         {
  880.             fprintf(fs, "%s", SOFC_comment[i]);
  881.             for (int j=0; j<SPEECH_FIR_45_TAPS_NUM; j++)
  882.             {
  883.                 if (j % 5 == 0)
  884.                 {
  885.                     fprintf(fs, "   ");
  886.                 }
  887.                 fprintf(fs, "%6d", m_sFirCoeff.s_speech_output_FIR_coeffs[i][j]);
  888.                 if (j != SPEECH_FIR_45_TAPS_NUM - 1)
  889.                 {
  890.                     fprintf(fs, ",");
  891.                 }
  892.                 if (j % 5 == 4)
  893.                 {
  894.                     fprintf(fs, "n");
  895.                 }
  896.             }
  897.             if (i != SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM-1)
  898.             {
  899.                 fprintf(fs, "   },n");
  900.             }
  901.             else
  902.             {
  903.                 fprintf(fs, "   }n");
  904.             }
  905.         }
  906.         fprintf(fs, "};nn");
  907.         // melody
  908.         //int melody_tap_num;
  909.         //if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  910.         //{
  911.         //    fprintf(fs, "const unsigned short Media_Playback_Maximum_Swing   = %d;nn", m_sFirCoef45Tap.Media_Playback_Maximum_Swing);
  912.         //}
  913.     }
  914.     else // AUDIO_FIR_VER_ORG, AUDIO_FIR_VER_W0547
  915.     {
  916.         char Output_Coeff_Name[5][128] =
  917.         {
  918.             "const signed short Audio_FIR_Output_Coeff_a[30] = {n",
  919.             "const signed short Audio_FIR_Output_Coeff_b[30] = {n",
  920.             "const signed short Audio_FIR_Output_Coeff_c[30] = {n",
  921.             "const signed short Audio_FIR_Output_Coeff_d[30] = {n",
  922.             "const signed short Audio_FIR_Output_Coeff_e[30] = {n",
  923.         };
  924.         //int i, j;
  925.         //fprintf( fs, "const unsigned char  L1SP_MICROPHONE1  = L1SP_LNA_0;n");
  926.         //fprintf( fs, "const unsigned char  L1SP_MICROPHONE2  = L1SP_LNA_1;nn");
  927.         //fprintf( fs, "const unsigned char  L1SP_SPEAKER1     = L1SP_BUFFER_0;n");
  928.         //fprintf( fs, "const unsigned char  L1SP_SPEAKER2     = L1SP_BUFFER_1;n");
  929.         //fprintf( fs, "const unsigned char  L1SP_LOUD_SPEAKER = L1SP_BUFFER_0;nn");
  930.         // 8k FIR1
  931.         fprintf(fs, "const signed short Audio_FIR_Input_Coeff[30] = {n");
  932.         for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
  933.         {
  934.             if (i % 5 == 0)
  935.             {
  936.                 fprintf(fs, "  ");
  937.             }
  938.             fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i]);
  939.             if (i != SPEECH_FIR_30_TAPS_NUM - 1)
  940.             {
  941.                 fprintf(fs, ",");
  942.             }
  943.             if (i % 5 == 4)
  944.             {
  945.                 fprintf(fs, "n");
  946.             }
  947.         }
  948.         fprintf(fs, "};nn");
  949.         fprintf(fs, "const signed short Audio_FIR_Output_Coeff[30] = {n");
  950.         for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
  951.         {
  952.             if (i % 5 == 0)
  953.             {
  954.                 fprintf(fs, "  ");
  955.             }
  956.             fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i]);
  957.             if (i != SPEECH_FIR_30_TAPS_NUM - 1)
  958.             {
  959.                 fprintf(fs, ",");
  960.             }
  961.             if (i % 5 == 4)
  962.             {
  963.                 fprintf(fs, "n");
  964.             }
  965.         }
  966.         fprintf(fs, "};nn");
  967.         // additional 8k
  968.         for (int i=0; i<5; i++)
  969.         {
  970.             fprintf(fs, Output_Coeff_Name[i]);
  971.             for (int j=0; j<SPEECH_FIR_30_TAPS_NUM; j++)
  972.             {
  973.                 if (i % 5 == 0)
  974.                 {
  975.                     fprintf(fs, "  ");
  976.                 }
  977.                 fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[i][j]);
  978.                 if (j != SPEECH_FIR_30_TAPS_NUM - 1)
  979.                 {
  980.                     fprintf(fs, ",");
  981.                 }
  982.                 if (j % 5 == 4)
  983.                 {
  984.                     fprintf( fs, "n");
  985.                 }
  986.             }
  987.             fprintf(fs, "};nn");
  988.         }
  989.         // 8k FIR2
  990.         fprintf(fs, "const signed short Audio_FIR_Input_Coeff2[30] = {n");
  991.         for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
  992.         {
  993.             if (i % 5 == 0)
  994.             {
  995.                 fprintf(fs, "  ");
  996.             }
  997.             fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i]);
  998.             if (i != SPEECH_FIR_30_TAPS_NUM - 1)
  999.             {
  1000.                 fprintf(fs, ",");
  1001.             }
  1002.             if (i % 5 == 4)
  1003.             {
  1004.                 fprintf(fs, "n");
  1005.             }
  1006.         }
  1007.         fprintf(fs, "};nn");
  1008.         fprintf(fs, "const signed short Audio_FIR_Output_Coeff2[30] = {n");
  1009.         for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
  1010.         {
  1011.             if (i % 5 == 0)
  1012.             {
  1013.                 fprintf(fs, "  ");
  1014.             }
  1015.             fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i]);
  1016.             if (i != SPEECH_FIR_30_TAPS_NUM - 1)
  1017.             {
  1018.                 fprintf(fs, ",");
  1019.             }
  1020.             if (i % 5 == 4)
  1021.             {
  1022.                 fprintf( fs, "n");
  1023.             }
  1024.         }
  1025.         fprintf(fs, "};nn");
  1026.         // const
  1027.         if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
  1028.         {
  1029.             if (m_sFirCoeff.us_ES_TimeConst < 4096)
  1030.             {
  1031.                 fprintf(fs, "const unsigned short ES_TimeConst   = 0x0%x;", m_sFirCoeff.us_ES_TimeConst);
  1032.             }
  1033.             else
  1034.             {
  1035.                 fprintf(fs, "const unsigned short ES_TimeConst   = 0x%x;", m_sFirCoeff.us_ES_TimeConst);
  1036.             }
  1037.             if (m_sFirCoeff.us_ES_VolConst < 4096)
  1038.             {
  1039.                 fprintf(fs, "nconst unsigned short ES_VolConst    = 0x0%x;", m_sFirCoeff.us_ES_VolConst);
  1040.             }
  1041.             else
  1042.             {
  1043.                 fprintf(fs, "nconst unsigned short ES_VolConst    = 0x%x;", m_sFirCoeff.us_ES_VolConst);
  1044.             }
  1045.             if (m_sFirCoeff.us_ES_TimeConst2 < 4096)
  1046.             {
  1047.                 fprintf(fs, "nconst unsigned short ES_TimeConst2  = 0x0%x;", m_sFirCoeff.us_ES_TimeConst2);
  1048.             }
  1049.             else
  1050.             {
  1051.                 fprintf(fs, "nconst unsigned short ES_TimeConst2  = 0x%x;", m_sFirCoeff.us_ES_TimeConst2);
  1052.             }
  1053.             if (m_sFirCoeff.us_ES_VolConst2 < 4096)
  1054.             {
  1055.                 fprintf(fs, "nconst unsigned short ES_VolConst2   = 0x0%x;", m_sFirCoeff.us_ES_VolConst2 );
  1056.             }
  1057.             else
  1058.             {
  1059.                 fprintf(fs, "nconst unsigned short ES_VolConst2   = 0x%x;", m_sFirCoeff.us_ES_VolConst2 );
  1060.             }
  1061.         }
  1062.         fprintf(fs, "nconst unsigned short Media_Playback_Maximum_Swing   = %d;nn", m_sFirCoeff.us_Media_Playback_Maximum_Swing);
  1063. //        if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
  1064.         {
  1065. #if 0
  1066.             // AMR
  1067.             fprintf(fs, "const signed short Media_FIR_Speech_Output1_16K_Default[62] = {n");
  1068.             for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  1069.             {
  1070.                 fprintf(fs, "%6d", p_speech_coef[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i]);
  1071.                 if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
  1072.                 {
  1073.                     fprintf( fs, ",");
  1074.                 }
  1075.                 if (i % 9 == 8)
  1076.                 {
  1077.                     fprintf(fs, "n");
  1078.                 }
  1079.             }
  1080.             fprintf(fs, "n};nn");
  1081.             fprintf(fs, "const signed short Media_FIR_Speech_Input1_16K_Default[62] = {n");
  1082.             for (i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  1083.             {
  1084.                 fprintf(fs, "%6d", p_speech_coef[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i]);
  1085.                 if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
  1086.                 {
  1087.                     fprintf(fs, ",");
  1088.                 }
  1089.                 if (i % 9 == 8)
  1090.                 {
  1091.                     fprintf(fs, "n");
  1092.                 }
  1093.             }
  1094.             fprintf(fs, "n};nn");
  1095.             fprintf(fs, "const signed short Media_FIR_Speech_Output2_16K_Default[62] = {n");
  1096.             for (i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  1097.             {
  1098.                 fprintf(fs, "%6d", p_speech_coef[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i]);
  1099.                 if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
  1100.                 {
  1101.                     fprintf( fs, ",");
  1102.                 }
  1103.                 if (i % 9 == 8)
  1104.                 {
  1105.                     fprintf(fs, "n");
  1106.                 }
  1107.             }
  1108.             fprintf(fs, "n};nn");
  1109.             fprintf(fs, "const signed short Media_FIR_Speech_Input2_16K_Default[62] = {n");
  1110.             for (i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
  1111.             {
  1112.                 fprintf(fs, "%6d", p_speech_coef[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i]);
  1113.                 if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
  1114.                 {
  1115.                     fprintf(fs, ",");
  1116.                 }
  1117.                 if (i % 9 == 8)
  1118.                 {
  1119.                     fprintf(fs, "n");
  1120.                 }
  1121.             }
  1122.             fprintf(fs, "n};nn");
  1123. #endif
  1124.             // melody
  1125.             fprintf(fs, "const signed short Media_FIR_Melody_Output1_32K_Default[45] = {n");
  1126.             for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  1127.             {
  1128.                 fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] );
  1129.                 if (i != MELODY_FIR_COEFF_45_TAPS_NUM - 1)
  1130.                 {
  1131.                     fprintf(fs, ",");
  1132.                 }
  1133.                 if (i % 9 == 8)
  1134.                 {
  1135.                     fprintf(fs, "n");
  1136.                 }
  1137.             }
  1138.             fprintf(fs, "n};nn");
  1139.             fprintf(fs, "const signed short Media_FIR_Melody_Output2_32K_Default[45] = {n");
  1140.             for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  1141.             {
  1142.                 fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] );
  1143.                 if (i != MELODY_FIR_COEFF_45_TAPS_NUM - 1)
  1144.                 {
  1145.                     fprintf(fs, ",");
  1146.                 }
  1147.                 if (i % 9 == 8)
  1148.                 {
  1149.                     fprintf( fs, "n");
  1150.                 }
  1151.             }
  1152.             fprintf( fs, "n};nn");
  1153.         }//  AUDIO_FIR_VER_ORG
  1154.         // speech enhancement
  1155.         if (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
  1156.         {
  1157.             char Speech_Mode_Dependent[][124] =
  1158.             {
  1159.                 "const unsigned short Speech_Normal_Mode_Para[8] = n{n",
  1160.                 "const unsigned short Speech_Earphone_Mode_Para[8] = n{n",
  1161.                 "const unsigned short Speech_LoudSpk_Mode_Para[8] = n{n",
  1162.                 "const unsigned short Speech_BT_Earphone_Mode_Para[8] = n{n",
  1163.                 "const unsigned short Speech_BT_Cordless_Mode_Para[8] = n{n",
  1164.                 "const unsigned short Speech_AUX1_Mode_Para[8] = n{n",
  1165.                 "const unsigned short Speech_AUX2_Mode_Para[8] = n{n",
  1166.                 "const unsigned short Speech_AUX3_Mode_Para[8] = n{n"
  1167.             };
  1168.             fprintf(fs, "const unsigned short Speech_Common_Para[12] = n{n");
  1169.             for (int i=0; i<SE_SPEECH_COMMON_NUM_12; i++)
  1170.             {
  1171.                 fprintf(fs, "%6d", m_sFirCoeff.us_speech_common_para[i]);
  1172.                 if(i != SE_SPEECH_COMMON_NUM_12 - 1)
  1173.                 {
  1174.                     fprintf(fs, ",");
  1175.                 }
  1176.             }
  1177.             fprintf(fs, "n};nn");
  1178.             // speech dependent
  1179.             for(int i=0; i<SE_MODE_NUM; i++)
  1180.             {
  1181.                 fprintf(fs, Speech_Mode_Dependent[i]);
  1182.                 for (int j=0; j<SE_MODE_PARA_NUM_8; j++)
  1183.                 {
  1184.                     fprintf(fs, "%6d", m_sFirCoeff.us_speech_mode_para[i][j]);
  1185.                     if (j != SE_MODE_PARA_NUM_8 - 1)
  1186.                     {
  1187.                         fprintf(fs, ",");
  1188.                     }
  1189.                 }
  1190.                 fprintf(fs, "n};nn");
  1191.             }
  1192.         }
  1193.     }
  1194.     fclose(fs);
  1195.     return true;
  1196. }
  1197. //---------------------------------------------------------------------------
  1198. bool CSPCOEF::REQ_Write_To_AudCommonC(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  1199. {
  1200.     m_eAudioParamType = e_audio_para_type;
  1201.     FILE *fs;
  1202.     fs = fopen(filename, "w");
  1203.     if (NULL == fs)
  1204.     {
  1205.         return false;
  1206.     }
  1207.     if ((AUDIO_FIR_VER_ORG          == m_eAudioParamType) ||
  1208.         (AUDIO_FIR_VER_W0547        == m_eAudioParamType) ||
  1209.         (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  1210.         )
  1211.     {
  1212.         return false;
  1213.     }
  1214.     fprintf(fs, "const unsigned short Media_Playback_Maximum_Swing   = %d;nn", m_sFirCoeff.us_Media_Playback_Maximum_Swing);
  1215.     fprintf(fs, "const signed short Melody_FIR[25] = n");
  1216.     fprintf(fs, "{n");
  1217.     for (int i=0; i<MELODY_FIR_COEFF_25_TAPS_NUM; i++)
  1218.     {
  1219.         fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
  1220.         if (i != MELODY_FIR_COEFF_25_TAPS_NUM - 1)
  1221.         {
  1222.             fprintf(fs, ",");
  1223.         }
  1224.         if (i % 10 == 9)
  1225.         {
  1226.             fprintf( fs, "n");
  1227.         }
  1228.     }
  1229.     fprintf( fs, "n};nn");
  1230.     switch (m_eAudioParamType)
  1231.     {
  1232.         case AUDIO_FIR_VER_W0740:
  1233.         case AUDIO_FIR_VER_W0809:
  1234.         {
  1235.             // audio compensation
  1236.             fprintf(fs, "/* Audio Compensation Filter */n");
  1237.             fprintf(fs, "const signed short Audio_Compensation_Filter[2][45] =n");
  1238.             fprintf(fs, "{n");
  1239.             AnsiString as_type[] =
  1240.             {
  1241.                 "    { /* 0: Compensation Filter for loud speaker mode */n",
  1242.                 "    { /* 1: Compensation Filter for earphone mode */n"
  1243.             };
  1244.             for (E_AUDIO_COMPENSATION_IDX_T type = AUDIO_COMPENSATION_LOUD_SPEAKER_IDX; type <= AUDIO_COMPENSATION_EARPHONE_IDX; type++)
  1245.             {
  1246.                 fprintf(fs, as_type[type].c_str());
  1247.                 for (int i=0; i<AUDIO_COMPENSATION_TAPS_NUM; i++)
  1248.                 {
  1249.                     if (i % 5 == 0)
  1250.                     {
  1251.                         fprintf(fs, "    ");
  1252.                     }
  1253.                     fprintf(fs, "%6d", m_sFirCoeff.s_audio_compensation_coeff[type][i]);
  1254.                     if (i != AUDIO_COMPENSATION_TAPS_NUM - 1)
  1255.                     {
  1256.                         fprintf(fs, ",");
  1257.                     }
  1258.                     if (i % 5 == 4)
  1259.                     {
  1260.                         fprintf(fs, "n");
  1261.                     }
  1262.                 }
  1263.                 if (AUDIO_COMPENSATION_LOUD_SPEAKER_IDX == type)
  1264.                 {
  1265.                     fprintf(fs, "    },n");
  1266.                 }
  1267.                 else
  1268.                 {
  1269.                     fprintf(fs, "    }n");
  1270.                 }
  1271.             }
  1272.             fprintf(fs, "};nn");
  1273.         }
  1274.         break;
  1275.     }
  1276.     fclose(fs);
  1277.     return true;
  1278. }
  1279. //---------------------------------------------------------------------------
  1280. bool CSPCOEF::REQ_Write_To_AudCoeffDefaultH(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  1281. {
  1282.     m_eAudioParamType = e_audio_para_type;
  1283.     FILE *fs;
  1284.     fs = fopen(filename, "w");
  1285.     if (NULL == fs)
  1286.     {
  1287.         return false;
  1288.     }
  1289.     if ((AUDIO_FIR_VER_ORG   == m_eAudioParamType) ||
  1290.         (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
  1291.         )
  1292.     {
  1293.         return false;
  1294.     }
  1295.     if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  1296.     {
  1297.         fprintf(fs, "#define DEFAULT_MEDIA_FIR_MELODY_OUTPUT1_32K_DEFAULT \ n");
  1298.         fprintf(fs, "{ \ n");
  1299.         for (int i = 0; i < MELODY_FIR_COEFF_45_TAPS_NUM; i++)
  1300.         {
  1301.             fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
  1302.             if (i != MELODY_FIR_COEFF_45_TAPS_NUM - 1)
  1303.             {
  1304.                 fprintf(fs, ",");
  1305.             }
  1306.             if (i % 10 == 9)
  1307.             {
  1308.                 fprintf(fs, " \ n");
  1309.             }
  1310.         }
  1311.         fprintf(fs, " \n}nn");
  1312.     }
  1313.     char Speech_Mode_Dependent[][124] =
  1314.     {
  1315.         "#define DEFAULT_SPEECH_NORMAL_MODE_PARA \",
  1316.         "#define DEFAULT_SPEECH_EARPHONE_MODE_PARA \",
  1317.         "#define DEFAULT_SPEECH_LOUDSPK_MODE_PARA \",
  1318.         "#define DEFAULT_SPEECH_BT_EARPHONE_MODE_PARA \",
  1319.         "#define DEFAULT_SPEECH_BT_CORDLESS_MODE_PARA \",
  1320.         "#define DEFAULT_SPEECH_AUX1_MODE_PARA \",
  1321.         "#define DEFAULT_SPEECH_AUX2_MODE_PARA \",
  1322.         "#define DEFAULT_SPEECH_AUX3_MODE_PARA \"
  1323.     };
  1324.     int i_se_mode_para_num;
  1325.     if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
  1326.         (AUDIO_FIR_VER_W0712        == m_eAudioParamType) ||
  1327.         (AUDIO_FIR_VER_W0740        == m_eAudioParamType)
  1328.        )
  1329.     {
  1330.         i_se_mode_para_num = SE_MODE_PARA_NUM_8;
  1331.     }
  1332.     else
  1333.     {
  1334.         i_se_mode_para_num = SE_MODE_PARA_NUM_16;
  1335.     }
  1336.     for (int mode = 0; mode < SE_MODE_NUM; mode++)
  1337.     {
  1338.         fprintf(fs, "%sn", Speech_Mode_Dependent[mode]);
  1339.         fprintf(fs, "{ \n");
  1340.         for (int i=0; i < i_se_mode_para_num; i++)
  1341.         {
  1342.             fprintf(fs, "%6d", m_sFirCoeff.us_speech_mode_para[mode][i]);
  1343.             if (i != i_se_mode_para_num - 1)
  1344.             {
  1345.                 fprintf(fs, ",");
  1346.             }
  1347.         }
  1348.         fprintf(fs, " \n");
  1349.         fprintf(fs, "}n");
  1350.     }
  1351.     // speech common
  1352.     if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  1353.     {
  1354.         fprintf(fs, "#define DEFAULT_SPEECH_COMMON_PARA \ n");
  1355.         fprintf(fs, "{ \n");
  1356.         for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
  1357.         {
  1358.             fprintf(fs, "%6d", m_sFirCoeff.us_speech_common_para[i]);
  1359.             if (i != SE_SPEECH_COMMON_NUM_12 - 1)
  1360.             {
  1361.                 fprintf(fs, ",");
  1362.             }
  1363.             if (i % 10 == 9)
  1364.             {
  1365.                 fprintf(fs, " \n");
  1366.             }
  1367.         }
  1368.         fprintf(fs, " \n");
  1369.         fprintf(fs, "}n");
  1370.     }
  1371.     fclose(fs);
  1372.     return true;
  1373. }
  1374. //---------------------------------------------------------------------------
  1375. bool CSPCOEF::REQ_Write_To_SpEnhanceC(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
  1376. {
  1377.     m_eAudioParamType = e_audio_para_type;
  1378.     FILE *fs;
  1379.     fs = fopen(filename, "w");
  1380.     if (NULL == fs)
  1381.     {
  1382.         return false;
  1383.     }
  1384.     if ((AUDIO_FIR_VER_ORG          == m_eAudioParamType) ||
  1385.         (AUDIO_FIR_VER_W0547        == m_eAudioParamType) ||
  1386.         (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
  1387.         )
  1388.     {
  1389.         return false;
  1390.     }
  1391.     int i_se_speech_common_num;
  1392.     if ((AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
  1393.         (AUDIO_FIR_VER_W0740 == m_eAudioParamType)
  1394.        )
  1395.     {
  1396.         i_se_speech_common_num = SE_SPEECH_COMMON_NUM_12;
  1397.         fprintf(fs, "const unsigned short Speech_Common_Para[12] =n");
  1398.     }
  1399.     else
  1400.     {
  1401.         i_se_speech_common_num = SE_SPEECH_COMMON_NUM_12;
  1402.         fprintf(fs, "const unsigned short Speech_Common_Para[8] =n");
  1403.     }
  1404.     fprintf(fs, "{n");
  1405.     for (int i=0; i < i_se_speech_common_num; i++)
  1406.     {
  1407.         fprintf(fs, "%6d", m_sFirCoeff.us_speech_common_para[i]);
  1408.         if (i != i_se_speech_common_num - 1)
  1409.         {
  1410.             fprintf(fs, ",");
  1411.         }
  1412.         if (i % 10 == 9)
  1413.         {
  1414.             fprintf(fs, "n");
  1415.         }
  1416.     }
  1417.     fprintf(fs, "n};n");
  1418.     fclose(fs);
  1419.     return true;
  1420. }
  1421. //===========================================================================
  1422. ////////////////////////////       Query          ///////////////////////////
  1423. //===========================================================================
  1424. bool CSPCOEF::Query_AudioParam45Tap_Start(void)
  1425. {
  1426.     META_RESULT  MetaResult = META_QueryIfTargetSupportAudioParam45Tap_r(m_META_HANDLE_Obj.Get_MainHandle(), 300);
  1427.     if(MetaResult!=META_SUCCESS)
  1428.     {
  1429.         return false;
  1430.     }
  1431.     return true;
  1432. }
  1433. //--------------------------------------------------------------------------
  1434. bool CSPCOEF::Query_AudioParamRuntime_Support_Start(void)
  1435. {
  1436.     META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 300, "META_Audio_Get_Audio_Param_Settings_0809_r");
  1437.     if(MetaResult!=META_SUCCESS)
  1438.     {
  1439.         return false;
  1440.     }
  1441.     return true;
  1442. }
  1443. //===========================================================================
  1444. ////////////////////////////  Export information  ///////////////////////////
  1445. //===========================================================================
  1446. E_METAAPP_RESULT_T CSPCOEF::Get_ConfirmState(void)
  1447. {
  1448.     return  m_eConfirmState;
  1449. }
  1450. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1451. void CSPCOEF::Get_FirCoef(S_FIR_COEFF_T& fir_coef)
  1452. {
  1453.     fir_coef = m_sFirCoeff;
  1454. }
  1455. //---------------------------------------------------------------------------
  1456. void CSPCOEF::Set_FirCoef(S_FIR_COEFF_T fir_coef)
  1457. {
  1458.     m_sFirCoeff = fir_coef;
  1459. }
  1460. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1461. unsigned short CSPCOEF::Get_SpeechModeDependentPara(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
  1462. {
  1463.     unsigned short coef;
  1464.     coef = m_sFirCoeff.us_speech_mode_para[mode][idx];
  1465.     return coef;
  1466. }
  1467. //---------------------------------------------------------------------------
  1468. void CSPCOEF::Set_SpeechModeDependentPara(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, unsigned short speech_mode_dep_para )
  1469. {
  1470.     m_sFirCoeff.us_speech_mode_para[mode][idx] = speech_mode_dep_para;
  1471. }
  1472. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1473. unsigned short CSPCOEF::Get_TimeConst(void)
  1474. {
  1475.     return  m_sFirCoeff.us_ES_TimeConst;
  1476. }
  1477. //---------------------------------------------------------------------------
  1478. void CSPCOEF::Set_TimeConst(unsigned short time_const)
  1479. {
  1480.     m_sFirCoeff.us_ES_TimeConst = time_const;
  1481. }
  1482. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1483. unsigned short CSPCOEF::Get_VolConst(void)
  1484. {
  1485.     return  m_sFirCoeff.us_ES_VolConst;
  1486. }
  1487. //---------------------------------------------------------------------------
  1488. void CSPCOEF::Set_VolConst(unsigned short vol_const)
  1489. {
  1490.     m_sFirCoeff.us_ES_VolConst = vol_const;
  1491. }
  1492. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1493. unsigned short CSPCOEF::Get_TimeConst2(void)
  1494. {
  1495.     return m_sFirCoeff.us_ES_TimeConst2;
  1496. }
  1497. //---------------------------------------------------------------------------
  1498. void CSPCOEF::Set_TimeConst2(unsigned short time_const2)
  1499. {
  1500.     m_sFirCoeff.us_ES_TimeConst2 = time_const2;
  1501. }
  1502. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1503. unsigned short CSPCOEF::Get_VolConst2(void)
  1504. {
  1505.     return  m_sFirCoeff.us_ES_VolConst2;
  1506. }
  1507. //---------------------------------------------------------------------------
  1508. void CSPCOEF::Set_VolConst2(unsigned short vol_const2)
  1509. {
  1510.     m_sFirCoeff.us_ES_VolConst2 = vol_const2;
  1511. }
  1512. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1513. unsigned short CSPCOEF::Get_MediaPlaybackMaximumSwing(E_AUDIO_FIR_VER_T e_audio_para_type)
  1514. {
  1515.     return m_sFirCoeff.us_Media_Playback_Maximum_Swing;
  1516. }
  1517. //---------------------------------------------------------------------------
  1518. void  CSPCOEF::Set_MediaPlaybackMaximumSwing(E_AUDIO_FIR_VER_T e_audio_para_type, unsigned short Media_Playback_Maximum_Swing )
  1519. {
  1520.     m_sFirCoeff.us_Media_Playback_Maximum_Swing = Media_Playback_Maximum_Swing;
  1521. }
  1522. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1523. short  CSPCOEF::Get_Speech8kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
  1524. {
  1525.     short speech_8k_coef;
  1526.     m_eAudioParamType = e_audio_para_type;
  1527.     switch (m_eAudioParamType)
  1528.     {
  1529.         case AUDIO_FIR_VER_ORG:
  1530.         case AUDIO_FIR_VER_W0547:
  1531.         {
  1532.             speech_8k_coef = m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Input_Coeff[idx];
  1533.         }
  1534.         break;
  1535.         case AUDIO_FIR_VER_W0547_45_TAP:
  1536.         case AUDIO_FIR_VER_W0712:
  1537.         case AUDIO_FIR_VER_W0740:
  1538.         case AUDIO_FIR_VER_W0809:
  1539.         {
  1540.             speech_8k_coef = m_sFirCoeff.s_speech_input_FIR_coeffs[mode][idx];
  1541.         }
  1542.         break;
  1543.     }
  1544.     return  speech_8k_coef;
  1545. }
  1546. //---------------------------------------------------------------------------
  1547. void  CSPCOEF::Set_Speech8kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_8k_coef )
  1548. {
  1549.     m_eAudioParamType = e_audio_para_type;
  1550.     switch (m_eAudioParamType)
  1551.     {
  1552.         case AUDIO_FIR_VER_ORG:
  1553.         case AUDIO_FIR_VER_W0547:
  1554.         {
  1555.             m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Input_Coeff[idx] = speech_8k_coef;
  1556.         }
  1557.         break;
  1558.         case AUDIO_FIR_VER_W0547_45_TAP:
  1559.         case AUDIO_FIR_VER_W0712:
  1560.         case AUDIO_FIR_VER_W0740:
  1561.         case AUDIO_FIR_VER_W0809:
  1562.         {
  1563.             m_sFirCoeff.s_speech_input_FIR_coeffs[mode][idx] = speech_8k_coef;
  1564.         }
  1565.         break;
  1566.     }
  1567. }
  1568. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1569. short  CSPCOEF::Get_Speech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
  1570. {
  1571.     short speech_8k_coef;
  1572.     m_eAudioParamType = e_audio_para_type;
  1573.     switch (m_eAudioParamType)
  1574.     {
  1575.         case AUDIO_FIR_VER_ORG:
  1576.         case AUDIO_FIR_VER_W0547:
  1577.         {
  1578.             speech_8k_coef = m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff[idx];
  1579.         }
  1580.         break;
  1581.         case AUDIO_FIR_VER_W0547_45_TAP:
  1582.         case AUDIO_FIR_VER_W0712:
  1583.         case AUDIO_FIR_VER_W0740:
  1584.         case AUDIO_FIR_VER_W0809:
  1585.         {
  1586.             speech_8k_coef = m_sFirCoeff.s_speech_output_FIR_coeffs[mode][idx];
  1587.         }
  1588.         break;
  1589.     }
  1590.     return  speech_8k_coef;
  1591. }
  1592. //---------------------------------------------------------------------------
  1593. void  CSPCOEF::Set_Speech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_8k_coef )
  1594. {
  1595.     m_eAudioParamType = e_audio_para_type;
  1596.     switch (m_eAudioParamType)
  1597.     {
  1598.         case AUDIO_FIR_VER_ORG:
  1599.         case AUDIO_FIR_VER_W0547:
  1600.         {
  1601.             m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff[idx] = speech_8k_coef;
  1602.         }
  1603.         break;
  1604.         case AUDIO_FIR_VER_W0547_45_TAP:
  1605.         case AUDIO_FIR_VER_W0712:
  1606.         case AUDIO_FIR_VER_W0740:
  1607.         case AUDIO_FIR_VER_W0809:
  1608.         {
  1609.             m_sFirCoeff.s_speech_output_FIR_coeffs[mode][idx] = speech_8k_coef;
  1610.         }
  1611.         break;
  1612.     }
  1613. }
  1614. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1615. short CSPCOEF::Get_Speech16kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
  1616. {
  1617.     return m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Input_Coeff[idx];
  1618. }
  1619. //---------------------------------------------------------------------------
  1620. void CSPCOEF::Set_Speech16kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_16k_coef )
  1621. {
  1622.     m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Input_Coeff[idx] = speech_16k_coef;
  1623. }
  1624. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1625. short  CSPCOEF::Get_Speech16kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx )
  1626. {
  1627.     return m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Output_Coeff[idx];
  1628. }
  1629. //---------------------------------------------------------------------------
  1630. void CSPCOEF::Set_Speech16kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_16k_coef )
  1631. {
  1632.     m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Output_Coeff[idx] = speech_16k_coef;
  1633. }
  1634. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1635. short CSPCOEF::Get_AdditionalSpeech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int Output_Coeff_Index, int idx )
  1636. {
  1637.     return m_sFirCoeff.s_Speech_FIR[mode].Additional_Speech_8k_Output_Coeff[Output_Coeff_Index][idx];;
  1638. }
  1639. //---------------------------------------------------------------------------
  1640. void CSPCOEF::Set_AdditionalSpeech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int Output_Coeff_Index, int idx, short speech_8k_coef )
  1641. {
  1642.     m_sFirCoeff.s_Speech_FIR[mode].Additional_Speech_8k_Output_Coeff[Output_Coeff_Index][idx] = speech_8k_coef;
  1643. }
  1644. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1645. short CSPCOEF::Get_Speech8kOutputCoeffIndex(E_AUDIO_FIR_VER_T e_audio_para_type, int mode)
  1646. {
  1647.     unsigned short output_coef_idx;
  1648.     m_eAudioParamType = e_audio_para_type;
  1649.     switch (m_eAudioParamType)
  1650.     {
  1651.         case AUDIO_FIR_VER_ORG:
  1652.         case AUDIO_FIR_VER_W0547:
  1653.         {
  1654.             output_coef_idx = m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff_Index;
  1655.         }
  1656.         break;
  1657.         case AUDIO_FIR_VER_W0547_45_TAP:
  1658.         case AUDIO_FIR_VER_W0712:
  1659.         case AUDIO_FIR_VER_W0740:
  1660.         case AUDIO_FIR_VER_W0809:
  1661.         {
  1662.             output_coef_idx = m_sFirCoeff.us_selected_FIR_output_index;
  1663.         }
  1664.         break;
  1665.     }
  1666.     return output_coef_idx;
  1667. }
  1668. //---------------------------------------------------------------------------
  1669. void CSPCOEF::Set_Speech8kOutputCoeffIndex(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, unsigned short output_coef_idx )
  1670. {
  1671.     m_eAudioParamType = e_audio_para_type;
  1672.     switch (m_eAudioParamType)
  1673.     {
  1674.         case AUDIO_FIR_VER_ORG:
  1675.         case AUDIO_FIR_VER_W0547:
  1676.         {
  1677.             m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff_Index = output_coef_idx;
  1678.         }
  1679.         break;
  1680.         case AUDIO_FIR_VER_W0547_45_TAP:
  1681.         case AUDIO_FIR_VER_W0712:
  1682.         case AUDIO_FIR_VER_W0740:
  1683.         case AUDIO_FIR_VER_W0809:
  1684.         {
  1685.             m_sFirCoeff.us_selected_FIR_output_index = output_coef_idx;
  1686.         }
  1687.         break;
  1688.     }
  1689. }
  1690. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1691. short CSPCOEF::Get_MelodyCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
  1692. {
  1693.     short melody_coef;
  1694.     m_eAudioParamType = e_audio_para_type;
  1695.     switch (m_eAudioParamType)
  1696.     {
  1697.         case AUDIO_FIR_VER_ORG:
  1698.         case AUDIO_FIR_VER_W0547:
  1699.         {
  1700.             melody_coef = m_sFirCoeff.s_Melody_FIR[mode].Melody_32k_Output_Coeff[idx];
  1701.         }
  1702.         break;
  1703.         case AUDIO_FIR_VER_W0547_45_TAP:
  1704.         case AUDIO_FIR_VER_W0712:
  1705.         case AUDIO_FIR_VER_W0740:
  1706.         case AUDIO_FIR_VER_W0809:
  1707.         {
  1708.             melody_coef = m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[idx];
  1709.         }
  1710.         break;
  1711.     }
  1712.     return  melody_coef;
  1713. }
  1714. //---------------------------------------------------------------------------
  1715. void CSPCOEF::Set_MelodyCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short melody_coef )
  1716. {
  1717.     m_eAudioParamType = e_audio_para_type;
  1718.     switch (m_eAudioParamType)
  1719.     {
  1720.         case AUDIO_FIR_VER_ORG:
  1721.         case AUDIO_FIR_VER_W0547:
  1722.         {
  1723.             m_sFirCoeff.s_Melody_FIR[mode].Melody_32k_Output_Coeff[idx] = melody_coef;
  1724.         }
  1725.         break;
  1726.         case AUDIO_FIR_VER_W0547_45_TAP:
  1727.         case AUDIO_FIR_VER_W0712:
  1728.         case AUDIO_FIR_VER_W0740:
  1729.         case AUDIO_FIR_VER_W0809:
  1730.         {
  1731.             m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[idx] = melody_coef;
  1732.         }
  1733.         break;
  1734.     }
  1735. }
  1736. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1737. unsigned char CSPCOEF::Get_SpeechCommonParameterNum(E_AUDIO_FIR_VER_T e_audio_para_type)
  1738. {
  1739.     m_eAudioParamType = e_audio_para_type;
  1740.     unsigned char num;
  1741.     switch (m_eAudioParamType)
  1742.     {
  1743.         case AUDIO_FIR_VER_ORG:
  1744.         {
  1745.             num = 0;
  1746.         }
  1747.         break;
  1748.         case AUDIO_FIR_VER_W0547:
  1749.         case AUDIO_FIR_VER_W0547_45_TAP:
  1750.         case AUDIO_FIR_VER_W0712:
  1751.         case AUDIO_FIR_VER_W0740:
  1752.         case AUDIO_FIR_VER_W0809:
  1753.         {
  1754.             num = SE_SPEECH_COMMON_NUM_12;
  1755.         }
  1756.         break;
  1757.     }
  1758.     return num;
  1759. }
  1760. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1761. unsigned  short CSPCOEF::Get_SpeechCommonParameter(int idx)
  1762. {
  1763.     return m_sFirCoeff.us_speech_common_para[idx];
  1764. }
  1765. //---------------------------------------------------------------------------
  1766. void CSPCOEF::Set_SpeechCommonParameter(int idx, unsigned short sc)
  1767. {
  1768.     m_sFirCoeff.us_speech_common_para[idx] = sc;
  1769. }
  1770. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1771. unsigned char CSPCOEF::Get_SpeechModeDependentParameterNum(E_AUDIO_FIR_VER_T e_audio_para_type)
  1772. {
  1773.     m_eAudioParamType = e_audio_para_type;
  1774.     unsigned char num;
  1775.     switch (m_eAudioParamType)
  1776.     {
  1777.         case AUDIO_FIR_VER_ORG:
  1778.         {
  1779.             num = 0;
  1780.         }
  1781.         break;
  1782.         case AUDIO_FIR_VER_W0547:
  1783.         case AUDIO_FIR_VER_W0547_45_TAP:
  1784.         case AUDIO_FIR_VER_W0712:
  1785.         case AUDIO_FIR_VER_W0740:
  1786.         {
  1787.             num = SE_MODE_PARA_NUM_8;
  1788.         }
  1789.         break;
  1790.         case AUDIO_FIR_VER_W0809:
  1791.         {
  1792.             num = SE_MODE_PARA_NUM_16;
  1793.         }
  1794.         break;
  1795.     }
  1796.     return num;
  1797. }
  1798. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1799. unsigned short CSPCOEF::Get_SpeechModeDependentParameter(int mode, int idx )
  1800. {
  1801.     return m_sFirCoeff.us_speech_mode_para[mode][idx];
  1802. }
  1803. //---------------------------------------------------------------------------
  1804. void CSPCOEF::Set_SpeechModeDependentParameter(int mode, int idx, unsigned short smd)
  1805. {
  1806.     m_sFirCoeff.us_speech_mode_para[mode][idx] = smd;
  1807. }
  1808. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1809. unsigned short CSPCOEF::Get_SpeechVolumeParameter(int mode, int level, int idx)
  1810. {
  1811.     return m_sFirCoeff.us_speech_volume_para[mode][level][idx];
  1812. }
  1813. //--------------------------------------------------------------------------
  1814. void CSPCOEF::Set_SpeechVolumeParameter(int mode, int level, int idx, unsigned short sp_vol)
  1815. {
  1816.     m_sFirCoeff.us_speech_volume_para[mode][level][idx] = sp_vol;
  1817. }
  1818. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1819. short CSPCOEF::Get_AudioCompensationCoef(E_AUDIO_COMPENSATION_IDX_T type, int idx)
  1820. {
  1821.     return m_sFirCoeff.s_audio_compensation_coeff[type][idx];
  1822. }
  1823. //--------------------------------------------------------------------------
  1824. void CSPCOEF::Set_AudioCompensationCoef(E_AUDIO_COMPENSATION_IDX_T type, int idx, short coef)
  1825. {
  1826.     m_sFirCoeff.s_audio_compensation_coeff[type][idx] = coef;
  1827. }