Changeset 162 in flair-src for trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp
- Timestamp:
- Mar 6, 2017, 8:30:06 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp
r148 r162 31 31 ButterworthLowPass_impl::ButterworthLowPass_impl(ButterworthLowPass *self, 32 32 const LayoutPosition *position, 33 string name, int order) {33 string name, uint32_t order,uint32_t nbRow,uint32_t nbCol) { 34 34 // init UI 35 35 GroupBox *reglages_groupbox = new GroupBox(position, name); … … 39 39 " Hz", 0, 10000, 0.1, 2, 1); 40 40 41 cvmatrix_descriptor *desc = new cvmatrix_descriptor( 1, 1);42 desc->SetElementName(0, 0, "output");41 cvmatrix_descriptor *desc = new cvmatrix_descriptor(nbRow, nbCol); 42 //desc->SetElementName(0, 0, "output"); 43 43 output = new cvmatrix(self, desc, floatType, name); 44 44 delete desc; 45 45 46 f = new PoleFilter(order); 47 48 if (T->Value() != 0) { 49 f->setup(1. / T->Value(), cutoff->Value()); 46 f=(PoleFilter**)malloc(sizeof(PoleFilter*)*nbRow*nbCol); 47 48 for(uint32_t i=0;i<nbRow;i++) { 49 for(uint32_t j=0;j<nbCol;j++) { 50 f[i*nbCol+j] = new PoleFilter(order); 51 if (T->Value() != 0) { 52 f[i*nbCol+j]->setup(1. / T->Value(), cutoff->Value()); 53 } 54 f[i*nbCol+j]->reset(); 55 } 50 56 } 51 52 f->reset();53 57 54 58 first_update = true; 55 59 this->order=order; 60 this->nbRow=nbRow; 61 this->nbCol=nbCol; 56 62 } 57 63 58 ButterworthLowPass_impl::~ButterworthLowPass_impl() { delete f; } 64 ButterworthLowPass_impl::~ButterworthLowPass_impl() { 65 for(uint32_t i=0;i<nbRow;i++) { 66 for(uint32_t j=0;j<nbCol;j++) { 67 delete f[i*nbCol+j]; 68 } 69 } 70 free(f); 71 } 59 72 60 73 void ButterworthLowPass_impl::UpdateFrom(const io_data *data) { 61 float result;62 74 cvmatrix *input = (cvmatrix *)data; 63 75 float delta_t; 64 76 65 if (T->ValueChanged()) { 66 if (T->Value() != 0) { 67 f->setup(1. / T->Value(), cutoff->Value()); 68 settingsChanged(input->Value(0, 0)); 77 if (T->ValueChanged() && T->Value() != 0) { 78 for(uint32_t i=0;i<nbRow;i++) { 79 for(uint32_t j=0;j<nbCol;j++) { 80 f[i*nbCol+j]->setup(1. / T->Value(), cutoff->Value()); 81 settingsChanged(f[i*nbCol+j],input->Value(i, j)); 82 } 69 83 } 70 84 } … … 72 86 if (T->Value() == 0) { 73 87 delta_t = (float)(data->DataTime() - previous_time) / 1000000000.; 74 f->setup(1. / delta_t, cutoff->Value()); 88 for(uint32_t i=0;i<nbRow;i++) { 89 for(uint32_t j=0;j<nbCol;j++) { 90 f[i*nbCol+j]->setup(1. / delta_t, cutoff->Value()); 91 } 92 } 75 93 } else { 76 94 delta_t=T->Value(); … … 82 100 83 101 if (cutoff->ValueChanged()) { 84 f->setup(1. / delta_t, cutoff->Value()); 85 settingsChanged(input->ValueNoMutex(0, 0)); 102 for(uint32_t i=0;i<nbRow;i++) { 103 for(uint32_t j=0;j<nbCol;j++) { 104 f[i*nbCol+j]->setup(1. / delta_t, cutoff->Value()); 105 settingsChanged(f[i*nbCol+j],input->ValueNoMutex(i, j)); 106 } 107 } 86 108 } 87 109 … … 89 111 first_update = false; 90 112 } else { 91 result = f->filter(input->ValueNoMutex(0, 0)); 92 output->SetValueNoMutex(0, 0, result); 113 for(uint32_t i=0;i<nbRow;i++) { 114 for(uint32_t j=0;j<nbCol;j++) { 115 float result = f[i*nbCol+j]->filter(input->ValueNoMutex(i, j)); 116 output->SetValueNoMutex(i, j, result); 117 } 118 } 93 119 } 94 120 … … 101 127 102 128 //ne gere pas les oscillations (s'arrete des qu'une valeure est bonne a 5%) 103 void ButterworthLowPass_impl::settingsChanged( float inputValue) {129 void ButterworthLowPass_impl::settingsChanged(PoleFilter*f,float inputValue) { 104 130 float result=f->filter(inputValue); 105 131
Note:
See TracChangeset
for help on using the changeset viewer.