![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ReSpeaker DSP V02
Dependencies: mbed MbedJSONValue
Diff: main.cpp
- Revision:
- 11:07981b0d28d3
- Parent:
- 10:273127efdc6e
- Child:
- 12:9d30df1529be
--- a/main.cpp Mon Aug 27 10:32:08 2018 +0000 +++ b/main.cpp Mon Aug 27 11:22:46 2018 +0000 @@ -30,7 +30,7 @@ Digital output PA_5 --> led (DigitalOut) PA_10 --> DSP_Trigger - + Digital Input PC_13 --> BTN (Blue) @@ -155,13 +155,13 @@ // Filter variables //SOS Matrix limited to order 10 int FilterSections=1; -float SOSMat[5][6]={ // Predefined SOS Matrix (second order 5Khz filter - 1, -2, 1, 1, -1.961, 0.9624, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 - }; +float SOSMat[5][6]= { // Predefined SOS Matrix (second order 5Khz filter + 1, -2, 1, 1, -1.961, 0.9624, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; float Gscale = 0.9810f; float filterCurrInput[6] = {0}; float filterLastInput[6] = {0}; @@ -262,7 +262,7 @@ #endif // Frequency counter toggleCounter++; - if (toggleCounter == TICKS2TOGGLE){ + if (toggleCounter == TICKS2TOGGLE) { toggleCounter=0; toggleCounterState = !toggleCounterState; dsp_trigger.write(toggleCounterState); @@ -483,7 +483,7 @@ }// end dspPacket // DSP Param Packet Handler void dspParamPacket(void) -{ +{ // get values. signalGain = ((float)guiCmd["gain"].get<int>())/1000; // issue in parsing doubles when the number is round trigTresh = ((float)guiCmd["trigTresh"].get<int>()) / 100.0f; @@ -501,22 +501,22 @@ // DSP Filter Packet Handler void dspFilterPacket(void) -{ +{ // get values. FilterSections = (guiCmd["Sections"].get<int>()); Gscale = ((float)(guiCmd["Gscale"].get<int>()))/10000.0f; // issue in parsing doubles - + // get SOSMat - for (int jj=0 ; jj < FilterSections ; jj++){ - for (int ii=0 ; ii < 5 ; ii++) { - SOSMat[jj][ii] = ((float)guiCmd["SOSMat"][jj][ii].get<int>())/10000.0f; + for (int jj=0 ; jj < FilterSections ; jj++) { + for (int ii=0 ; ii < 6 ; ii++) { + SOSMat[jj][ii] = ((float)guiCmd["SOSMat"][ii+jj*6].get<int>())/10000.0f; } } #ifdef DEBUG_MOD10 // send parsed values pc.printf("FilterSections: %d , Gscale: %.3f\r\n", FilterSections , Gscale); pc.printf("SOSMat \r\n"); - for (int jj=0 ; jj < FilterSections ; jj++){ + for (int jj=0 ; jj < FilterSections ; jj++) { pc.printf("%.3f , %.3f , %.3f , %.3f , %.3f , %.3f \r\n",SOSMat[jj][0] ,SOSMat[jj][1],SOSMat[jj][2],SOSMat[jj][3] ,SOSMat[jj][4] ,SOSMat[jj][5]); } #endif