sp_coef.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:141k
- fprintf( fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i] );
- }
- fclose(fp);
- return true;
- }
- //==============================================================================
- ////////////////////// 16k //////////////////////////////////
- //==============================================================================
- //=============================================================================
- /////////////////////////////////////// FIR 1 /////////////////////////////////
- //=============================================================================
- bool CSPCOEF::REQ_Read_16k_FIR1_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while(!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i]=0;
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_16k_FIR1_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
- fp = fopen(filename, "w");
- if(fp == NULL)
- return false;
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Read_16k_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf( fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while (!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
- {
- fscanf( fp, "%d", &coeff );
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i] = 0;
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Write_16k_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
- fp = fopen(filename, "w");
- if (NULL == fp)
- {
- return false;
- }
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //==============================================================================
- /////////////////////////////////////// FIR 2 //////////////////////////////////
- //==============================================================================
- bool CSPCOEF::REQ_Read_16k_FIR2_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf( fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while(!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
- {
- fscanf( fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i]=0;
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_16k_FIR2_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
- fp = fopen(filename, "w");
- if(fp == NULL)
- return false;
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i] );
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Read_16k_FIR2_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf( fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while(!feof(fp) && i< m_iCoeffLen && i<ACOUSTIC_FIR_COEFF_16K_NUM)
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i] = 0;
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Write_16k_FIR2_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = ACOUSTIC_FIR_COEFF_16K_NUM;
- fp = fopen(filename, "w");
- if(fp == NULL)
- return false;
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- /////////////////// Speech input FIR coefficient ///////////////////////
- //===========================================================================
- bool CSPCOEF::REQ_Read_Speech_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if(fp == NULL)
- return false;
- if(!feof(fp))
- {
- fscanf( fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while ((!feof(fp)) && (i< m_iCoeffLen) && (i < SPEECH_FIR_45_TAPS_NUM))
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<SPEECH_FIR_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i] = 0;
- }
- fclose(fp);
- return true;
- }
- //--------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_Speech_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode )
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- return false;
- }
- FILE *fp;
- fp = fopen(filename, "w");
- if (NULL == fp)
- {
- return false;
- }
- int CoeffLength;
- for (int i=0; i<SPEECH_FIR_45_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_speech_input_FIR_coeffs[mode][i]);
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- /////////////////// Speech output FIR coefficient ///////////////////////
- //===========================================================================
- bool CSPCOEF::REQ_Read_Speech_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while (!feof(fp) && (i < m_iCoeffLen) && (i < SPEECH_FIR_45_TAPS_NUM))
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<SPEECH_FIR_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i] = 0;
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_Speech_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, unsigned int mode)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- fp = fopen(filename, "w");
- if (fp == NULL)
- {
- return false;
- }
- int CoeffLength = SPEECH_FIR_45_TAPS_NUM;
- for (int i=0; i<SPEECH_FIR_45_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_speech_output_FIR_coeffs[mode][i]);
- }
- fclose(fp);
- return true;
- }
- //******************************************************************************
- //******************* Melody *******************
- //******************************************************************************
- //============================================================================
- /////////////////////////////////////// FIR 1 ////////////////////////////////
- //============================================================================
- //===========================================================================
- bool CSPCOEF::REQ_Read_Melody_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- i=0; // initialize i
- int coeff;
- while ((!feof(fp)) && (i < m_iCoeffLen) && (i < MELODY_FIR_COEFF_45_TAPS_NUM))
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = 0;
- }
- }
- else // W0547_45_TAP, W0712, W0740, W0809
- {
- i=0; // initialize i
- int coeff;
- int tap_num;
- if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- {
- tap_num = MELODY_FIR_COEFF_45_TAPS_NUM;
- }
- else
- {
- tap_num = MELODY_FIR_COEFF_25_TAPS_NUM;
- }
- while ((!feof(fp)) && (i < m_iCoeffLen) && (i < tap_num))
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<tap_num; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = 0;
- }
- }
- fclose(fp);
- return true;
- }
- //--------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_Melody_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- FILE *fp;
- int CoeffLength;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- )
- {
- CoeffLength= MELODY_FIR_COEFF_45_TAPS_NUM;
- }
- else // W0712, W0740, W0809
- {
- CoeffLength= MELODY_FIR_COEFF_25_TAPS_NUM;
- }
- fp = fopen(filename, "w");
- if (NULL == fp)
- {
- return false;
- }
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for(int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
- }
- }
- else // W0547_45_TAP, W0712, W0740, W0809
- {
- short* p_melody_fir;
- int tap_num;
- if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- {
- tap_num = MELODY_FIR_COEFF_45_TAPS_NUM;
- }
- else
- {
- tap_num = MELODY_FIR_COEFF_25_TAPS_NUM;
- }
- for (int i=0; i<tap_num; i++)
- {
- if (0 == m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
- }
- }
- fclose(fp);
- return true;
- }
- //============================================================================
- /////////////////////////////////////// FIR 2 ////////////////////////////////
- //============================================================================
- bool CSPCOEF::REQ_Read_Melody_FIR2_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if(fp == NULL)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- for (i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = 0;
- }
- i=0; // initialize i
- int coeff;
- while ((!feof(fp)) && (i < m_iCoeffLen) && (i < MELODY_FIR_COEFF_45_TAPS_NUM))
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_Melody_FIR2_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = MELODY_FIR_COEFF_45_TAPS_NUM;
- fp = fopen(filename, "w");
- if (NULL == fp)
- {
- return false;
- }
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //==============================================================================
- /////////////////////////////////////// 8k addtional FIR 1 /////////////////////
- //==============================================================================
- bool CSPCOEF::REQ_Read_8k_Additional_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, int index)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- fp = fopen(filename, "r");
- if (fp == NULL)
- {
- return false;
- }
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i]=0;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- int i=0;
- int coeff;
- while((!feof(fp)) && (i < m_iCoeffLen))
- {
- fscanf( fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i] = (short)coeff;
- i++;
- }
- fclose(fp);
- return true;
- }
- //--------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_8k_Additional_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type, int index)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = SPEECH_FIR_30_TAPS_NUM;
- fp = fopen(filename, "w");
- if (fp == NULL)
- {
- return false;
- }
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[index][i]);
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- /////////////////////////////// audio compensation //////////////////////////
- //===========================================================================
- 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)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- for (int i=0; i<AUDIO_COMPENSATION_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_audio_compensation_coeff[type][i] = 0;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- int i=0; // initialize i
- int coeff;
- while((!feof(fp)) && (i < m_iCoeffLen))
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_audio_compensation_coeff[type][i] = (short)coeff;
- i++;
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- 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)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = AUDIO_COMPENSATION_TAPS_NUM;
- fp = fopen(filename, "w");
- if (NULL == fp)
- {
- return false;
- }
- for (int i=0; i<AUDIO_COMPENSATION_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_audio_compensation_coeff[type][i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (int i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_audio_compensation_coeff[type][i]);
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_To_AudcoeffC(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- FILE *fs;
- fs = fopen(filename, "w");
- if (NULL == fs)
- {
- return false;
- }
- // fprintf( fs, "#include "l1audio.h"nn");
- // if (AUDIO_FIR_VER_ORG != m_eAudioParamType)
- // {
- // fprintf( fs, "#include "audcoeff_default.h"nn");
- // }
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- // fprintf(fs, "const unsigned char L1SP_MICROPHONE1 = L1SP_LNA_0;n");
- // fprintf(fs, "const unsigned char L1SP_MICROPHONE2 = L1SP_LNA_1;nn");
- // fprintf(fs, "const unsigned char L1SP_SPEAKER1 = L1SP_BUFFER_0;n");
- // fprintf(fs, "const unsigned char L1SP_SPEAKER2 = L1SP_BUFFER_ST;n");
- // fprintf(fs, "const unsigned char L1SP_LOUD_SPEAKER = L1SP_BUFFER_ST|L1SP_BUFFER_EXT;nn");
- // SIFC
- char SIFC_comment[][128] =
- {
- " { /* 0: Input FIR coefficients for 2G/3G Normal mode */n",
- " { /* 1: Input FIR coefficients for 2G/3G/VoIP Headset mode */n",
- " { /* 2: Input FIR coefficients for 2G/3G Handfree mode */n",
- " { /* 3: Input FIR coefficients for 2G/3G/VoIP BT mode */n",
- " { /* 4: Input FIR coefficients for VoIP Normal mode */n",
- " { /* 5: Input FIR coefficients for VoIP Handfree mode */n"
- };
- fprintf(fs, "const signed short Speech_Input_FIR_Coeff[6][45] = {n");
- for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- fprintf(fs, "%s", SIFC_comment[i]);
- for (int j=0; j<SPEECH_FIR_45_TAPS_NUM; j++)
- {
- if (j % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_speech_input_FIR_coeffs[i][j]);
- if (j != SPEECH_FIR_45_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (j % 5 == 4)
- {
- fprintf(fs, "n");
- }
- }
- if (i != SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM-1 )
- {
- fprintf(fs, " },n");
- }
- else
- {
- fprintf(fs, " }n");
- }
- }
- fprintf(fs, "};nn");
- // SOFC
- char SOFC_comment[][128] =
- {
- " { /* 0: Output FIR coefficients for 2G/3G Normal mode */n",
- " { /* 1: Output FIR coefficients for 2G/3G/VoIP Headset mode */n",
- " { /* 2: Output FIR coefficients for 2G/3G Handfree mode */n",
- " { /* 3: Output FIR coefficients for 2G/3G/VoIP BT mode */n",
- " { /* 4: Output FIR coefficients for VoIP Normal mode */n",
- " { /* 5: Output FIR coefficients for VoIP Handfree mode */n"
- };
- fprintf(fs, "const signed short Speech_Output_FIR_Coeff[6][45] = {n");
- for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- fprintf(fs, "%s", SOFC_comment[i]);
- for (int j=0; j<SPEECH_FIR_45_TAPS_NUM; j++)
- {
- if (j % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_speech_output_FIR_coeffs[i][j]);
- if (j != SPEECH_FIR_45_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (j % 5 == 4)
- {
- fprintf(fs, "n");
- }
- }
- if (i != SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM-1)
- {
- fprintf(fs, " },n");
- }
- else
- {
- fprintf(fs, " }n");
- }
- }
- fprintf(fs, "};nn");
- // melody
- //int melody_tap_num;
- //if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- //{
- // fprintf(fs, "const unsigned short Media_Playback_Maximum_Swing = %d;nn", m_sFirCoef45Tap.Media_Playback_Maximum_Swing);
- //}
- }
- else // AUDIO_FIR_VER_ORG, AUDIO_FIR_VER_W0547
- {
- char Output_Coeff_Name[5][128] =
- {
- "const signed short Audio_FIR_Output_Coeff_a[30] = {n",
- "const signed short Audio_FIR_Output_Coeff_b[30] = {n",
- "const signed short Audio_FIR_Output_Coeff_c[30] = {n",
- "const signed short Audio_FIR_Output_Coeff_d[30] = {n",
- "const signed short Audio_FIR_Output_Coeff_e[30] = {n",
- };
- //int i, j;
- //fprintf( fs, "const unsigned char L1SP_MICROPHONE1 = L1SP_LNA_0;n");
- //fprintf( fs, "const unsigned char L1SP_MICROPHONE2 = L1SP_LNA_1;nn");
- //fprintf( fs, "const unsigned char L1SP_SPEAKER1 = L1SP_BUFFER_0;n");
- //fprintf( fs, "const unsigned char L1SP_SPEAKER2 = L1SP_BUFFER_1;n");
- //fprintf( fs, "const unsigned char L1SP_LOUD_SPEAKER = L1SP_BUFFER_0;nn");
- // 8k FIR1
- fprintf(fs, "const signed short Audio_FIR_Input_Coeff[30] = {n");
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (i % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i]);
- if (i != SPEECH_FIR_30_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 5 == 4)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "};nn");
- fprintf(fs, "const signed short Audio_FIR_Output_Coeff[30] = {n");
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (i % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i]);
- if (i != SPEECH_FIR_30_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 5 == 4)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "};nn");
- // additional 8k
- for (int i=0; i<5; i++)
- {
- fprintf(fs, Output_Coeff_Name[i]);
- for (int j=0; j<SPEECH_FIR_30_TAPS_NUM; j++)
- {
- if (i % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[i][j]);
- if (j != SPEECH_FIR_30_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (j % 5 == 4)
- {
- fprintf( fs, "n");
- }
- }
- fprintf(fs, "};nn");
- }
- // 8k FIR2
- fprintf(fs, "const signed short Audio_FIR_Input_Coeff2[30] = {n");
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (i % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i]);
- if (i != SPEECH_FIR_30_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 5 == 4)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "};nn");
- fprintf(fs, "const signed short Audio_FIR_Output_Coeff2[30] = {n");
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (i % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i]);
- if (i != SPEECH_FIR_30_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 5 == 4)
- {
- fprintf( fs, "n");
- }
- }
- fprintf(fs, "};nn");
- // const
- if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
- {
- if (m_sFirCoeff.us_ES_TimeConst < 4096)
- {
- fprintf(fs, "const unsigned short ES_TimeConst = 0x0%x;", m_sFirCoeff.us_ES_TimeConst);
- }
- else
- {
- fprintf(fs, "const unsigned short ES_TimeConst = 0x%x;", m_sFirCoeff.us_ES_TimeConst);
- }
- if (m_sFirCoeff.us_ES_VolConst < 4096)
- {
- fprintf(fs, "nconst unsigned short ES_VolConst = 0x0%x;", m_sFirCoeff.us_ES_VolConst);
- }
- else
- {
- fprintf(fs, "nconst unsigned short ES_VolConst = 0x%x;", m_sFirCoeff.us_ES_VolConst);
- }
- if (m_sFirCoeff.us_ES_TimeConst2 < 4096)
- {
- fprintf(fs, "nconst unsigned short ES_TimeConst2 = 0x0%x;", m_sFirCoeff.us_ES_TimeConst2);
- }
- else
- {
- fprintf(fs, "nconst unsigned short ES_TimeConst2 = 0x%x;", m_sFirCoeff.us_ES_TimeConst2);
- }
- if (m_sFirCoeff.us_ES_VolConst2 < 4096)
- {
- fprintf(fs, "nconst unsigned short ES_VolConst2 = 0x0%x;", m_sFirCoeff.us_ES_VolConst2 );
- }
- else
- {
- fprintf(fs, "nconst unsigned short ES_VolConst2 = 0x%x;", m_sFirCoeff.us_ES_VolConst2 );
- }
- }
- fprintf(fs, "nconst unsigned short Media_Playback_Maximum_Swing = %d;nn", m_sFirCoeff.us_Media_Playback_Maximum_Swing);
- // if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
- {
- #if 0
- // AMR
- fprintf(fs, "const signed short Media_FIR_Speech_Output1_16K_Default[62] = {n");
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- fprintf(fs, "%6d", p_speech_coef[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i]);
- if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
- {
- fprintf( fs, ",");
- }
- if (i % 9 == 8)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "n};nn");
- fprintf(fs, "const signed short Media_FIR_Speech_Input1_16K_Default[62] = {n");
- for (i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- fprintf(fs, "%6d", p_speech_coef[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i]);
- if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 9 == 8)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "n};nn");
- fprintf(fs, "const signed short Media_FIR_Speech_Output2_16K_Default[62] = {n");
- for (i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- fprintf(fs, "%6d", p_speech_coef[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i]);
- if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
- {
- fprintf( fs, ",");
- }
- if (i % 9 == 8)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "n};nn");
- fprintf(fs, "const signed short Media_FIR_Speech_Input2_16K_Default[62] = {n");
- for (i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- fprintf(fs, "%6d", p_speech_coef[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i]);
- if (i != ACOUSTIC_FIR_COEFF_16K_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 9 == 8)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "n};nn");
- #endif
- // melody
- fprintf(fs, "const signed short Media_FIR_Melody_Output1_32K_Default[45] = {n");
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] );
- if (i != MELODY_FIR_COEFF_45_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 9 == 8)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "n};nn");
- fprintf(fs, "const signed short Media_FIR_Melody_Output2_32K_Default[45] = {n");
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] );
- if (i != MELODY_FIR_COEFF_45_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 9 == 8)
- {
- fprintf( fs, "n");
- }
- }
- fprintf( fs, "n};nn");
- }// AUDIO_FIR_VER_ORG
- // speech enhancement
- if (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- {
- char Speech_Mode_Dependent[][124] =
- {
- "const unsigned short Speech_Normal_Mode_Para[8] = n{n",
- "const unsigned short Speech_Earphone_Mode_Para[8] = n{n",
- "const unsigned short Speech_LoudSpk_Mode_Para[8] = n{n",
- "const unsigned short Speech_BT_Earphone_Mode_Para[8] = n{n",
- "const unsigned short Speech_BT_Cordless_Mode_Para[8] = n{n",
- "const unsigned short Speech_AUX1_Mode_Para[8] = n{n",
- "const unsigned short Speech_AUX2_Mode_Para[8] = n{n",
- "const unsigned short Speech_AUX3_Mode_Para[8] = n{n"
- };
- fprintf(fs, "const unsigned short Speech_Common_Para[12] = n{n");
- for (int i=0; i<SE_SPEECH_COMMON_NUM_12; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.us_speech_common_para[i]);
- if(i != SE_SPEECH_COMMON_NUM_12 - 1)
- {
- fprintf(fs, ",");
- }
- }
- fprintf(fs, "n};nn");
- // speech dependent
- for(int i=0; i<SE_MODE_NUM; i++)
- {
- fprintf(fs, Speech_Mode_Dependent[i]);
- for (int j=0; j<SE_MODE_PARA_NUM_8; j++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.us_speech_mode_para[i][j]);
- if (j != SE_MODE_PARA_NUM_8 - 1)
- {
- fprintf(fs, ",");
- }
- }
- fprintf(fs, "n};nn");
- }
- }
- }
- fclose(fs);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_To_AudCommonC(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- FILE *fs;
- fs = fopen(filename, "w");
- if (NULL == fs)
- {
- return false;
- }
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- )
- {
- return false;
- }
- fprintf(fs, "const unsigned short Media_Playback_Maximum_Swing = %d;nn", m_sFirCoeff.us_Media_Playback_Maximum_Swing);
- fprintf(fs, "const signed short Melody_FIR[25] = n");
- fprintf(fs, "{n");
- for (int i=0; i<MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
- if (i != MELODY_FIR_COEFF_25_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 10 == 9)
- {
- fprintf( fs, "n");
- }
- }
- fprintf( fs, "n};nn");
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- // audio compensation
- fprintf(fs, "/* Audio Compensation Filter */n");
- fprintf(fs, "const signed short Audio_Compensation_Filter[2][45] =n");
- fprintf(fs, "{n");
- AnsiString as_type[] =
- {
- " { /* 0: Compensation Filter for loud speaker mode */n",
- " { /* 1: Compensation Filter for earphone mode */n"
- };
- for (E_AUDIO_COMPENSATION_IDX_T type = AUDIO_COMPENSATION_LOUD_SPEAKER_IDX; type <= AUDIO_COMPENSATION_EARPHONE_IDX; type++)
- {
- fprintf(fs, as_type[type].c_str());
- for (int i=0; i<AUDIO_COMPENSATION_TAPS_NUM; i++)
- {
- if (i % 5 == 0)
- {
- fprintf(fs, " ");
- }
- fprintf(fs, "%6d", m_sFirCoeff.s_audio_compensation_coeff[type][i]);
- if (i != AUDIO_COMPENSATION_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 5 == 4)
- {
- fprintf(fs, "n");
- }
- }
- if (AUDIO_COMPENSATION_LOUD_SPEAKER_IDX == type)
- {
- fprintf(fs, " },n");
- }
- else
- {
- fprintf(fs, " }n");
- }
- }
- fprintf(fs, "};nn");
- }
- break;
- }
- fclose(fs);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_To_AudCoeffDefaultH(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- FILE *fs;
- fs = fopen(filename, "w");
- if (NULL == fs)
- {
- return false;
- }
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- return false;
- }
- if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- {
- fprintf(fs, "#define DEFAULT_MEDIA_FIR_MELODY_OUTPUT1_32K_DEFAULT \ n");
- fprintf(fs, "{ \ n");
- for (int i = 0; i < MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i]);
- if (i != MELODY_FIR_COEFF_45_TAPS_NUM - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 10 == 9)
- {
- fprintf(fs, " \ n");
- }
- }
- fprintf(fs, " \n}nn");
- }
- char Speech_Mode_Dependent[][124] =
- {
- "#define DEFAULT_SPEECH_NORMAL_MODE_PARA \",
- "#define DEFAULT_SPEECH_EARPHONE_MODE_PARA \",
- "#define DEFAULT_SPEECH_LOUDSPK_MODE_PARA \",
- "#define DEFAULT_SPEECH_BT_EARPHONE_MODE_PARA \",
- "#define DEFAULT_SPEECH_BT_CORDLESS_MODE_PARA \",
- "#define DEFAULT_SPEECH_AUX1_MODE_PARA \",
- "#define DEFAULT_SPEECH_AUX2_MODE_PARA \",
- "#define DEFAULT_SPEECH_AUX3_MODE_PARA \"
- };
- int i_se_mode_para_num;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType)
- )
- {
- i_se_mode_para_num = SE_MODE_PARA_NUM_8;
- }
- else
- {
- i_se_mode_para_num = SE_MODE_PARA_NUM_16;
- }
- for (int mode = 0; mode < SE_MODE_NUM; mode++)
- {
- fprintf(fs, "%sn", Speech_Mode_Dependent[mode]);
- fprintf(fs, "{ \n");
- for (int i=0; i < i_se_mode_para_num; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.us_speech_mode_para[mode][i]);
- if (i != i_se_mode_para_num - 1)
- {
- fprintf(fs, ",");
- }
- }
- fprintf(fs, " \n");
- fprintf(fs, "}n");
- }
- // speech common
- if (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- {
- fprintf(fs, "#define DEFAULT_SPEECH_COMMON_PARA \ n");
- fprintf(fs, "{ \n");
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.us_speech_common_para[i]);
- if (i != SE_SPEECH_COMMON_NUM_12 - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 10 == 9)
- {
- fprintf(fs, " \n");
- }
- }
- fprintf(fs, " \n");
- fprintf(fs, "}n");
- }
- fclose(fs);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_To_SpEnhanceC(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- FILE *fs;
- fs = fopen(filename, "w");
- if (NULL == fs)
- {
- return false;
- }
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType)
- )
- {
- return false;
- }
- int i_se_speech_common_num;
- if ((AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType)
- )
- {
- i_se_speech_common_num = SE_SPEECH_COMMON_NUM_12;
- fprintf(fs, "const unsigned short Speech_Common_Para[12] =n");
- }
- else
- {
- i_se_speech_common_num = SE_SPEECH_COMMON_NUM_12;
- fprintf(fs, "const unsigned short Speech_Common_Para[8] =n");
- }
- fprintf(fs, "{n");
- for (int i=0; i < i_se_speech_common_num; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.us_speech_common_para[i]);
- if (i != i_se_speech_common_num - 1)
- {
- fprintf(fs, ",");
- }
- if (i % 10 == 9)
- {
- fprintf(fs, "n");
- }
- }
- fprintf(fs, "n};n");
- fclose(fs);
- return true;
- }
- //===========================================================================
- //////////////////////////// Query ///////////////////////////
- //===========================================================================
- bool CSPCOEF::Query_AudioParam45Tap_Start(void)
- {
- META_RESULT MetaResult = META_QueryIfTargetSupportAudioParam45Tap_r(m_META_HANDLE_Obj.Get_MainHandle(), 300);
- if(MetaResult!=META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //--------------------------------------------------------------------------
- bool CSPCOEF::Query_AudioParamRuntime_Support_Start(void)
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 300, "META_Audio_Get_Audio_Param_Settings_0809_r");
- if(MetaResult!=META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- //////////////////////////// Export information ///////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CSPCOEF::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::Get_FirCoef(S_FIR_COEFF_T& fir_coef)
- {
- fir_coef = m_sFirCoeff;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_FirCoef(S_FIR_COEFF_T fir_coef)
- {
- m_sFirCoeff = fir_coef;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_SpeechModeDependentPara(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
- {
- unsigned short coef;
- coef = m_sFirCoeff.us_speech_mode_para[mode][idx];
- return coef;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_SpeechModeDependentPara(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, unsigned short speech_mode_dep_para )
- {
- m_sFirCoeff.us_speech_mode_para[mode][idx] = speech_mode_dep_para;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_TimeConst(void)
- {
- return m_sFirCoeff.us_ES_TimeConst;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_TimeConst(unsigned short time_const)
- {
- m_sFirCoeff.us_ES_TimeConst = time_const;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_VolConst(void)
- {
- return m_sFirCoeff.us_ES_VolConst;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_VolConst(unsigned short vol_const)
- {
- m_sFirCoeff.us_ES_VolConst = vol_const;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_TimeConst2(void)
- {
- return m_sFirCoeff.us_ES_TimeConst2;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_TimeConst2(unsigned short time_const2)
- {
- m_sFirCoeff.us_ES_TimeConst2 = time_const2;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_VolConst2(void)
- {
- return m_sFirCoeff.us_ES_VolConst2;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_VolConst2(unsigned short vol_const2)
- {
- m_sFirCoeff.us_ES_VolConst2 = vol_const2;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_MediaPlaybackMaximumSwing(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- return m_sFirCoeff.us_Media_Playback_Maximum_Swing;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_MediaPlaybackMaximumSwing(E_AUDIO_FIR_VER_T e_audio_para_type, unsigned short Media_Playback_Maximum_Swing )
- {
- m_sFirCoeff.us_Media_Playback_Maximum_Swing = Media_Playback_Maximum_Swing;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_Speech8kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
- {
- short speech_8k_coef;
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- speech_8k_coef = m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Input_Coeff[idx];
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- speech_8k_coef = m_sFirCoeff.s_speech_input_FIR_coeffs[mode][idx];
- }
- break;
- }
- return speech_8k_coef;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_Speech8kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_8k_coef )
- {
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Input_Coeff[idx] = speech_8k_coef;
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- m_sFirCoeff.s_speech_input_FIR_coeffs[mode][idx] = speech_8k_coef;
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_Speech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
- {
- short speech_8k_coef;
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- speech_8k_coef = m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff[idx];
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- speech_8k_coef = m_sFirCoeff.s_speech_output_FIR_coeffs[mode][idx];
- }
- break;
- }
- return speech_8k_coef;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_Speech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_8k_coef )
- {
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff[idx] = speech_8k_coef;
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- m_sFirCoeff.s_speech_output_FIR_coeffs[mode][idx] = speech_8k_coef;
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_Speech16kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
- {
- return m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Input_Coeff[idx];
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_Speech16kInputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_16k_coef )
- {
- m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Input_Coeff[idx] = speech_16k_coef;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_Speech16kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx )
- {
- return m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Output_Coeff[idx];
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_Speech16kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short speech_16k_coef )
- {
- m_sFirCoeff.s_Speech_FIR[mode].Speech_16k_Output_Coeff[idx] = speech_16k_coef;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_AdditionalSpeech8kOutputCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int Output_Coeff_Index, int idx )
- {
- return m_sFirCoeff.s_Speech_FIR[mode].Additional_Speech_8k_Output_Coeff[Output_Coeff_Index][idx];;
- }
- //---------------------------------------------------------------------------
- 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 )
- {
- m_sFirCoeff.s_Speech_FIR[mode].Additional_Speech_8k_Output_Coeff[Output_Coeff_Index][idx] = speech_8k_coef;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_Speech8kOutputCoeffIndex(E_AUDIO_FIR_VER_T e_audio_para_type, int mode)
- {
- unsigned short output_coef_idx;
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- output_coef_idx = m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff_Index;
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- output_coef_idx = m_sFirCoeff.us_selected_FIR_output_index;
- }
- break;
- }
- return output_coef_idx;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_Speech8kOutputCoeffIndex(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, unsigned short output_coef_idx )
- {
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- m_sFirCoeff.s_Speech_FIR[mode].Speech_8k_Output_Coeff_Index = output_coef_idx;
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- m_sFirCoeff.us_selected_FIR_output_index = output_coef_idx;
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_MelodyCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx)
- {
- short melody_coef;
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- melody_coef = m_sFirCoeff.s_Melody_FIR[mode].Melody_32k_Output_Coeff[idx];
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- melody_coef = m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[idx];
- }
- break;
- }
- return melody_coef;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_MelodyCoef(E_AUDIO_FIR_VER_T e_audio_para_type, int mode, int idx, short melody_coef )
- {
- m_eAudioParamType = e_audio_para_type;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- case AUDIO_FIR_VER_W0547:
- {
- m_sFirCoeff.s_Melody_FIR[mode].Melody_32k_Output_Coeff[idx] = melody_coef;
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[idx] = melody_coef;
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CSPCOEF::Get_SpeechCommonParameterNum(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- unsigned char num;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- {
- num = 0;
- }
- break;
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- num = SE_SPEECH_COMMON_NUM_12;
- }
- break;
- }
- return num;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_SpeechCommonParameter(int idx)
- {
- return m_sFirCoeff.us_speech_common_para[idx];
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_SpeechCommonParameter(int idx, unsigned short sc)
- {
- m_sFirCoeff.us_speech_common_para[idx] = sc;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CSPCOEF::Get_SpeechModeDependentParameterNum(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- unsigned char num;
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_ORG:
- {
- num = 0;
- }
- break;
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- {
- num = SE_MODE_PARA_NUM_8;
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- num = SE_MODE_PARA_NUM_16;
- }
- break;
- }
- return num;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_SpeechModeDependentParameter(int mode, int idx )
- {
- return m_sFirCoeff.us_speech_mode_para[mode][idx];
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Set_SpeechModeDependentParameter(int mode, int idx, unsigned short smd)
- {
- m_sFirCoeff.us_speech_mode_para[mode][idx] = smd;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned short CSPCOEF::Get_SpeechVolumeParameter(int mode, int level, int idx)
- {
- return m_sFirCoeff.us_speech_volume_para[mode][level][idx];
- }
- //--------------------------------------------------------------------------
- void CSPCOEF::Set_SpeechVolumeParameter(int mode, int level, int idx, unsigned short sp_vol)
- {
- m_sFirCoeff.us_speech_volume_para[mode][level][idx] = sp_vol;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- short CSPCOEF::Get_AudioCompensationCoef(E_AUDIO_COMPENSATION_IDX_T type, int idx)
- {
- return m_sFirCoeff.s_audio_compensation_coeff[type][idx];
- }
- //--------------------------------------------------------------------------
- void CSPCOEF::Set_AudioCompensationCoef(E_AUDIO_COMPENSATION_IDX_T type, int idx, short coef)
- {
- m_sFirCoeff.s_audio_compensation_coeff[type][idx] = coef;
- }