Index: trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp
===================================================================
--- trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp	(revision 137)
+++ trunk/lib/FlairFilter/src/ButterworthLowPass_impl.cpp	(revision 147)
@@ -47,9 +47,12 @@
   f = new PoleFilter(order);
 
-  if (T->Value() != 0)
+  if (T->Value() != 0) {
     f->setup(1. / T->Value(), cutoff->Value());
+  }
+  
   f->reset();
 
   first_update = true;
+  this->order=order;
 }
 
@@ -59,20 +62,27 @@
   float result;
   cvmatrix *input = (cvmatrix *)data;
-
-  if (T->ValueChanged() || cutoff->ValueChanged()) {
+  float delta_t;
+  
+  if (T->ValueChanged()) {
     if (T->Value() != 0) {
       f->setup(1. / T->Value(), cutoff->Value());
-    } else {
-      first_update = true;
+      settingsChanged(input->Value(0, 0));
     }
   }
 
+  if (T->Value() == 0) {
+    delta_t = (float)(data->DataTime() - previous_time) / 1000000000.;
+    f->setup(1. / delta_t, cutoff->Value());
+  } else {
+    delta_t=T->Value();
+  }
+  
   // on prend une fois pour toute les mutex et on fait des accès directs
   output->GetMutex();
   input->GetMutex();
 
-  if (T->Value() == 0) {
-    float delta_t = (float)(data->DataTime() - previous_time) / 1000000000.;
+  if (cutoff->ValueChanged()) {
     f->setup(1. / delta_t, cutoff->Value());
+    settingsChanged(input->ValueNoMutex(0, 0));
   }
 
@@ -90,2 +100,11 @@
   previous_time = data->DataTime();
 }
+
+//ne gere pas les oscillations (s'arrete des qu'une valeure est bonne a 5%)
+void ButterworthLowPass_impl::settingsChanged(float inputValue) {
+  float result=f->filter(inputValue);
+  
+  while(result<inputValue*0.95 || result>inputValue*1.05) {
+      result=f->filter(inputValue);
+  }
+}
Index: trunk/lib/FlairFilter/src/EulerDerivative.h
===================================================================
--- trunk/lib/FlairFilter/src/EulerDerivative.h	(revision 137)
+++ trunk/lib/FlairFilter/src/EulerDerivative.h	(revision 147)
@@ -45,5 +45,5 @@
   * IODevice::ProcessUpdate is called. \n
   * The optional init_value parameters allow to specify
-  * the size of the input datas and its inital values.
+  * the size of the input datas and output inital values.
   * If unspecified, a 1*1 size is used, and values are
   * initialized with 0.
@@ -52,5 +52,5 @@
   * \param position position to display settings
   * \param name name
-  * \param init_value initial value
+  * \param init_value initial value, it is safe to destroy it after calling this constructor
   */
   EulerDerivative(const core::IODevice *parent,
Index: trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp
===================================================================
--- trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp	(revision 137)
+++ trunk/lib/FlairFilter/src/EulerDerivative_impl.cpp	(revision 147)
@@ -33,14 +33,32 @@
                                            const cvmatrix *init_value) {
   first_update = true;
+  
+  if (init_value != NULL) {
+    // init output matrix of same size as init
+    cvmatrix_descriptor *desc =new cvmatrix_descriptor(init_value->Rows(), init_value->Cols());
 
-  if (init_value != NULL) {
-    prev_value = (cvmatrix *)init_value;
+    for (int i = 0; i < init_value->Rows(); i++) {
+      for (int j = 0; j < init_value->Cols(); j++) {
+        desc->SetElementName(i, j, init_value->Name(i, j));
+      }
+    }
+    output = new cvmatrix(self, desc,init_value->GetDataType().GetElementDataType(), name);
+    for (int i = 0; i < init_value->Rows(); i++) {
+      for (int j = 0; j < init_value->Cols(); j++) {
+        output->SetValue(i, j, init_value->Value(i,j));
+      }
+    }
   } else {
     // if NULL, assume dimension 1, and init=0
     cvmatrix_descriptor *desc = new cvmatrix_descriptor(1, 1);
     desc->SetElementName(0, 0, "output");
-    prev_value = new cvmatrix(self, desc, floatType, name);
-    prev_value->SetValue(0, 0, 0);
+    output = new cvmatrix(self, desc, floatType, name);
+    output->SetValue(0, 0, 0);
   }
+  
+ 
+  cvmatrix_descriptor *desc = new cvmatrix_descriptor(output->Rows(), output->Cols());
+  prev_value = new cvmatrix(self, desc, output->GetDataType().GetElementDataType(), name);
+
 
   // init UI
@@ -48,17 +66,4 @@
   T = new DoubleSpinBox(reglages_groupbox->NewRow(), "period, 0 for auto:",
                         " s", 0, 1, 0.01);
-
-  // init output matrix of same size as init
-  cvmatrix_descriptor *desc =
-      new cvmatrix_descriptor(prev_value->Rows(), prev_value->Cols());
-
-  for (int i = 0; i < prev_value->Rows(); i++) {
-    for (int j = 0; j < prev_value->Cols(); j++) {
-      desc->SetElementName(i, j, prev_value->Name(i, j));
-    }
-  }
-
-  output = new cvmatrix(self, desc,
-                        prev_value->GetDataType().GetElementDataType(), name);
 }
 
@@ -76,5 +81,4 @@
     for (int i = 0; i < input->Rows(); i++) {
       for (int j = 0; j < input->Cols(); j++) {
-        output->SetValueNoMutex(i, j, prev_value->ValueNoMutex(i, j));
         prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
       }
Index: trunk/lib/FlairFilter/src/LowPassFilter.h
===================================================================
--- trunk/lib/FlairFilter/src/LowPassFilter.h	(revision 137)
+++ trunk/lib/FlairFilter/src/LowPassFilter.h	(revision 147)
@@ -52,5 +52,5 @@
   * \param position position to display settings
   * \param name name
-  * \param init_value initial value
+  * \param init_value initial value, it is safe to destroy it after calling this constructor
   */
   LowPassFilter(const core::IODevice *parent,
Index: trunk/lib/FlairFilter/src/LowPassFilter_impl.cpp
===================================================================
--- trunk/lib/FlairFilter/src/LowPassFilter_impl.cpp	(revision 137)
+++ trunk/lib/FlairFilter/src/LowPassFilter_impl.cpp	(revision 147)
@@ -35,14 +35,26 @@
                                        string name,
                                        const cvmatrix *init_value) {
-  first_update = true;
 
   if (init_value != NULL) {
-    prev_value = (cvmatrix *)init_value;
+    // init output matrix of same size as init
+    cvmatrix_descriptor *desc =new cvmatrix_descriptor(init_value->Rows(), init_value->Cols());
+
+    for (int i = 0; i < init_value->Rows(); i++) {
+      for (int j = 0; j < init_value->Cols(); j++) {
+        desc->SetElementName(i, j, init_value->Name(i, j));
+      }
+    }
+    output = new cvmatrix(self, desc,init_value->GetDataType().GetElementDataType(), name);
+    for (int i = 0; i < init_value->Rows(); i++) {
+      for (int j = 0; j < init_value->Cols(); j++) {
+        output->SetValue(i, j, init_value->Value(i,j));
+      }
+    }
   } else {
     // if NULL, assume dimension 1, and init=0
     cvmatrix_descriptor *desc = new cvmatrix_descriptor(1, 1);
     desc->SetElementName(0, 0, "output");
-    prev_value = new cvmatrix(self, desc, floatType, name);
-    prev_value->SetValue(0, 0, 0);
+    output = new cvmatrix(self, desc, floatType, name);
+    output->SetValue(0, 0, 0);
   }
 
@@ -53,19 +65,6 @@
   freq = new DoubleSpinBox(reglages_groupbox->NewRow(), "cutoff frequency",
                            " Hz", 0, 10000, 0.1, 2, 1);
-
-  // init output matrix of same size as init
-  cvmatrix_descriptor *desc =
-      new cvmatrix_descriptor(prev_value->Rows(), prev_value->Cols());
-
-  for (int i = 0; i < prev_value->Rows(); i++) {
-    for (int j = 0; j < prev_value->Cols(); j++) {
-      desc->SetElementName(i, j, prev_value->Name(i, j));
-    }
-  }
-
-  output = new cvmatrix(self, desc,
-                        prev_value->GetDataType().GetElementDataType(), name);
-
-  output->SetValue(0, 0, 0);
+                           
+  previous_time=GetTime();
 }
 
@@ -74,5 +73,4 @@
 void LowPassFilter_impl::UpdateFrom(const io_data *data) {
   float delta_t;
-  float result;
   cvmatrix *input = (cvmatrix *)data;
 
@@ -81,33 +79,23 @@
   input->GetMutex();
 
-  if (first_update == true) {
-    for (int i = 0; i < input->Rows(); i++) {
-      for (int j = 0; j < input->Cols(); j++) {
-        output->SetValueNoMutex(i, j, prev_value->ValueNoMutex(i, j));
-        prev_value->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
-      }
-    }
-    first_update = false;
+  if (T->Value() == 0) {
+    delta_t = (float)(data->DataTime() - previous_time) / 1000000000.;
   } else {
-    if (T->Value() == 0) {
-      delta_t = (float)(data->DataTime() - previous_time) / 1000000000.;
-    } else {
-      delta_t = T->Value();
-    }
-    for (int i = 0; i < input->Rows(); i++) {
-      for (int j = 0; j < input->Cols(); j++) {
-
-        if (freq->Value() != 0) {
-          output->SetValueNoMutex(i, j, (1 - 2 * PI * freq->Value() * delta_t) *
-                                                prev_value->ValueNoMutex(i, j) +
-                                            2 * PI * freq->Value() * delta_t *
-                                                input->ValueNoMutex(i, j));
-        } else {
-          output->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
-        }
-        prev_value->SetValueNoMutex(i, j, output->ValueNoMutex(i, j));
+    delta_t = T->Value();
+  }
+  for (int i = 0; i < input->Rows(); i++) {
+    for (int j = 0; j < input->Cols(); j++) {
+      float cutoff=freq->Value();
+      if (cutoff == 0 || freq->ValueChanged()) {
+        output->SetValueNoMutex(i, j, input->ValueNoMutex(i, j));
+      } else {
+        output->SetValueNoMutex(i, j, (1 - 2 * PI * cutoff * delta_t) *
+                                              output->ValueNoMutex(i, j) +
+                                          2 * PI * cutoff * delta_t *
+                                              input->ValueNoMutex(i, j));
       }
     }
   }
+ 
   input->ReleaseMutex();
   output->ReleaseMutex();
Index: trunk/lib/FlairFilter/src/unexported/ButterworthLowPass_impl.h
===================================================================
--- trunk/lib/FlairFilter/src/unexported/ButterworthLowPass_impl.h	(revision 137)
+++ trunk/lib/FlairFilter/src/unexported/ButterworthLowPass_impl.h	(revision 147)
@@ -128,8 +128,10 @@
 
 private:
+  void settingsChanged(float inputValue);
   flair::gui::DoubleSpinBox *cutoff, *T;
   PoleFilter *f;
   bool first_update;
   flair::core::Time previous_time;
+  int order;
 };
 
Index: trunk/lib/FlairFilter/src/unexported/LowPassFilter_impl.h
===================================================================
--- trunk/lib/FlairFilter/src/unexported/LowPassFilter_impl.h	(revision 137)
+++ trunk/lib/FlairFilter/src/unexported/LowPassFilter_impl.h	(revision 147)
@@ -43,6 +43,4 @@
 private:
   flair::core::Time previous_time;
-  bool first_update;
-  flair::core::cvmatrix *prev_value;
   flair::gui::DoubleSpinBox *freq, *T;
 };
