Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MyFunctions.cpp
00001 //-------------------------------------------------------------- 00002 // フィルタ処理付き SD オーディオプレーヤーで使う大域関数(ヘッダ) 00003 // 00004 // 2016/07/04, Copyright (c) 2016 MIKAMI, Naoki 00005 //-------------------------------------------------------------- 00006 00007 #include "MyFunctions.hpp" 00008 00009 // 1フレーム分の信号処理 (IIR フィルタ) の実行 00010 void IIR_Filtering(SD_WavReader &sdReader, SaiIO &mySai, 00011 float g0, Biquad hn[], 00012 int order, bool filterOn) 00013 { 00014 static int32_t frameSize = mySai.GetLength(); 00015 static Array<int16_t> sn(frameSize); // フレームバッファ 00016 00017 // 1フレーム分のデータを SD から読み込む 00018 sdReader.ReadAndToMono(sn); 00019 00020 while (!mySai.IsXferred()) {} // データの転送が終わるまで待つ 00021 //-------------------------------------------------------------- 00022 // 1フレーム分の信号処理を行い,その結果を出力する 00023 for (int n=0; n<frameSize; n++) 00024 { 00025 // 縦続形の IIR フィルタ 00026 float yn = g0*sn[n]; 00027 for (int k=0; k<order/2; k++) yn = hn[k].Execute(yn); 00028 00029 int16_t value = filterOn ? (int16_t)yn : sn[n]; 00030 00031 // 音響信号の出力,右チャンネルには出力しない 00032 mySai.Output(value, 0); 00033 } 00034 //-------------------------------------------------------------- 00035 mySai.ResetXferred(); // 次のデータ転送に備える 00036 } 00037 00038 // SD カードのファイルのオープン 00039 int32_t SD_Open(SD_WavReader &sdReader, 00040 string fileName, int32_t frameSize) 00041 { 00042 sdReader.Open(fileName); 00043 sdReader.IsWavFile(); 00044 return sdReader.GetSize()/frameSize; 00045 } 00046 00047 // ファイルの選択 00048 // selectedName: 選択されたファイル名 00049 void SelectFile(ButtonGroup &menu, FileSelector &selector, 00050 Label &msg, string &selectedName) 00051 { 00052 selector.DisplayFileList(); 00053 msg.Draw("Chon File"); 00054 do 00055 { 00056 if (selector.Select(selectedName)) 00057 menu.Activate(1); // PLAY 有効 00058 wait_ms(200); 00059 } while (!menu.Touched(1)); // PLAY がタッチされるまで繰り返す 00060 } 00061 00062 // フィルタの変更 00063 void ModifyFilter(DesignerDrawer &drawerObj, 00064 ButtonGroup &lpHp, ButtonGroup &onOff, 00065 Biquad hn[], Biquad::Coefs ck[], 00066 float &g0, bool &filterOn) 00067 { 00068 // フィルタ処理の有効/無効切り替え 00069 int sw = 0; 00070 if (onOff.GetTouchedNumber(sw)) 00071 filterOn = (sw == 0) ? true : false; 00072 00073 // フィルタの周波数特性の変更 00074 static int num = 0; 00075 lpHp.GetTouchedNumber(num); 00076 BilinearDesign::Type typeLH = (BilinearDesign::Type)num; 00077 if (drawerObj.ReDesignAndDraw(ck, g0, typeLH)) 00078 for (int k=0; k<drawerObj.GetOrder()/2; k++) 00079 { 00080 hn[k].SetCoefficients(ck[k]); 00081 hn[k].Clear(); 00082 } 00083 } 00084
Generated on Fri Aug 5 2022 02:03:47 by
1.7.2