/******************************************************************************* * モジュール名称 :APP EWO Common - Decimation filter * * モジュールラベル :app_EWO_PIs * * タスク区分 :Application EWO Common task * * 機能 : * * コーリングシーケンス:void app_EWO_(PI) * * 引数 :なし * * 戻り値 :なし * * 使用上の注意 :グローバル変数はアプリケーション01でまとめて初期化 * * エラー処理 :なし * * 注意 : EDIT権限は、EWO組 * * 作成日・作成者 :2012/09/19 Y.Kasaba * *******************************************************************************/ #include "app_common.h" #include "app_EWO.h" // ****************** // *** Macro: local // ****************** int app_EWO_decimation ( double *f_data, int i_data_num, double *f_work, int i_down_sample_rate, double *f_h, int i_filter_num ); // ****************************************************************************************************************** // EWO: Decimation Fiters --- 1/2 decimation filter with down sampling // ------------------------------------------------------------------------------------------------------------------ // int app_EWO_decimation_2( double *f_data, // [IN/OUT] 元波形および変換後の波形 // int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] // double *f_work, // [INPUT] ワークエリアの先頭ポインタ // int i_down_sample_rate ) // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // // 戻り値: 変換後のデータ点数. // // ダウンサンプル無: i_data_num-(フィルタ係数の数[31])/2 // // ダウンサンプリング時: 上記 / i_down_sample_rate // // Filter係数 31個 // ****************************************************************************************************************** /* ---- comment out 2012.09.19 Kasaba int app_EWO_decimation_2( double *f_data, // [IN/OUT] 元波形および変換後の波形 int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] double *f_work, // [INPUT] ワークエリアの先頭ポインタ int i_down_sample_rate ) // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // 戻り値: 変換後のデータ点数. // ダウンサンプル無: i_data_num-(フィルタ係数の数[31])/2 // ダウンサンプリング時: 上記 / i_down_sample_rate // Filter係数 31個 { return app_EWO_decimation( f_data, // [IN/OUT] 元Data -> 変換後Data i_data_num, // [INPUT] 元Dataの点数 f_work, // [INPUT] ワークエリアの先頭ポインタ i_down_sample_rate, // [INPUT] Down-sampling rate Gf_EWO_DEC_h2, // [INPUT] Filter係数 [31個] (defined in 'app_EWO_variable.c') 31 ); // [INPUT] Filter Number [31] // 戻り値:変換後のデータ点数. } */ // フィルタ係数改良型 2012.08.07 Imachi int app_EWO_decimation_2_2( double *f_data, // [IN/OUT] 元波形および変換後の波形 int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] double *f_work, // [INPUT] ワークエリアの先頭ポインタ int i_down_sample_rate ) // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // 戻り値: 変換後のデータ点数. // ダウンサンプル無: i_data_num-(フィルタ係数の数[31])/2 // ダウンサンプリング時: 上記 / i_down_sample_rate // Filter係数 31個 { return app_EWO_decimation( f_data, // [IN/OUT] 元Data -> 変換後Data i_data_num, // [INPUT] 元Dataの点数 f_work, // [INPUT] ワークエリアの先頭ポインタ i_down_sample_rate, // [INPUT] Down-sampling rate Gf_EWO_DEC_h2_2, // [INPUT] Filter係数 [31個] (defined in 'app_EWO_variable.c') 25 ); // [INPUT] Filter Number [31] // 戻り値:変換後のデータ点数. } // EFD 用 2012.08.22 Imachi int app_EWO_decimation_2_efd( double *f_data, // [IN/OUT] 元波形および変換後の波形 int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] double *f_work, // [INPUT] ワークエリアの先頭ポインタ int i_down_sample_rate ) // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // 戻り値: 変換後のデータ点数. // ダウンサンプル無: i_data_num-(フィルタ係数の数[31])/2 // ダウンサンプリング時: 上記 / i_down_sample_rate // Filter係数 31個 { return app_EWO_decimation( f_data, // [IN/OUT] 元Data -> 変換後Data i_data_num, // [INPUT] 元Dataの点数 f_work, // [INPUT] ワークエリアの先頭ポインタ i_down_sample_rate, // [INPUT] Down-sampling rate Gf_EWO_DEC_h2_efd, // [INPUT] Filter係数 [31個] (defined in 'app_EWO_variable.c') 27 ); // [INPUT] Filter Number [31] // 戻り値:変換後のデータ点数. } // ****************************************************************************************************************** // EWO: Decimation Fiters --- 1/32 decimation filter with down sampling // ------------------------------------------------------------------------------------------------------------------ // int app_EWO_decimation_32( double *f_data, // [IN/OUT] 元波形および変換後の波形 // int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] // double *f_work, // [INPUT] ワークエリアの先頭ポインタ // int i_down_sample_rate ) // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // // 戻り値: 変換後のデータ点数 // // ダウンサンプル無: i_data_num-(フィルタ係数の数[150])/2 // // ダウンサンプリング時: 上記 / i_down_sample_rate // // Filter係数 150個 // ****************************************************************************************************************** int app_EWO_decimation_32( double *f_data, // [IN/OUT] 元波形および変換後の波形 int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] double *f_work, // [INPUT] ワークエリアの先頭ポインタ int i_down_sample_rate ) // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // 戻り値: 変換後のデータ点数 // ダウンサンプル無: i_data_num-(フィルタ係数の数[150])/2 // ダウンサンプリング時: 上記 / i_down_sample_rate // Filter係数 150個 { /* return app_EWO_decimation( f_data, // [IN/OUT] 元Data -> 変換後Data i_data_num, // [INPUT] 元Dataの点数 f_work, // [INPUT] ワークエリアの先頭ポインタ i_down_sample_rate, // [INPUT] Down-sampling rate Gf_EWO_DEC_h32, // [INPUT] Filter係数 [31個] (defined in 'app_EWO_variable.c') 150 ); // [INPUT] Filter Number [31] // 戻り値:変換後のデータ点数. */ // フィルタ係数改良(タップ数変更) 2012.08.07 Imachi return app_EWO_decimation( f_data, // [IN/OUT] 元Data -> 変換後Data i_data_num, // [INPUT] 元Dataの点数 f_work, // [INPUT] ワークエリアの先頭ポインタ i_down_sample_rate, // [INPUT] Down-sampling rate Gf_EWO_DEC_h32, // [INPUT] Filter係数 [31個] (defined in 'app_EWO_variable.c') 156 ); // [INPUT] Filter Number [31] // 戻り値:変換後のデータ点数. } // ****************************************************************************************************************** // EWO: Decimation Fiters --- General decimation filter with down sampling // ------------------------------------------------------------------------------------------------------------------ // int app_EWO_decimation ( double *f_data, // [IN/OUT] 元波形および変換後の波形 // int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] // double *f_work, // [INPUT] ワークエリアの先頭ポインタ // int i_down_sample_rate, // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) // double *f_h, // [INPUT] Filter係数 // int i_filter_num ) // [INPUT] Filter係数の数 (1/2: 31, 1/32: 150) // // 戻り値: 変換後のデータ点数 // // ダウンサンプル無: i_data_num-(フィルタ係数の数)/2 // // ダウンサンプリング時: 上記 / i_down_sample_rate // ****************************************************************************************************************** int app_EWO_decimation ( double *f_data, // [IN/OUT] 元波形および変換後の波形 int i_data_num, // [INPUT] 元波形のデータ点数 [MAX: 8192] double *f_work, // [INPUT] ワークエリアの先頭ポインタ int i_down_sample_rate, // [INPUT] ダウンサンプリングレート (1:ダウンサンプルしない) double *f_h, // [INPUT] Filter係数 int i_filter_num ) // [INPUT] Filter係数の数 (1/2: 31, 1/32: 150) // 戻り値: 変換後のデータ点数 // ダウンサンプル無: i_data_num-(フィルタ係数の数)/2 // ダウンサンプリング時: 上記 / i_down_sample_rate { int shift; int i, j; // *** Check the length *** // if (i_data_num > Gd_EWO_DEC_MAX) return(0); // ***8192*** // *** Error check and initialize *** if( i_down_sample_rate < 1 ) i_down_sample_rate = 1; for( i=0; i= j ){ f_work[i/i_down_sample_rate] += f_h[j] * f_data[i-j]; } } } // *** Produce output *** // 間引きありの場合で,フィルタ係数が奇数の場合,1点ずらす. if( i_down_sample_rate != 1 && ( i_filter_num %2 ) != 0 ) shift = 1; else shift = 0; // 出力データの生成 for( i=0, j=0; i<(i_data_num - i_filter_num)/i_down_sample_rate; i++ ){ f_data[j++] = f_work[i + ( i_filter_num - 1 ) / i_down_sample_rate + shift]; } // *** Return the number of the data *** return (j); }