summaryrefslogtreecommitdiffhomepage
path: root/filter-tom/filter_tom.h
diff options
context:
space:
mode:
Diffstat (limited to 'filter-tom/filter_tom.h')
-rw-r--r--filter-tom/filter_tom.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/filter-tom/filter_tom.h b/filter-tom/filter_tom.h
new file mode 100644
index 00000000..0f6d07c2
--- /dev/null
+++ b/filter-tom/filter_tom.h
@@ -0,0 +1,93 @@
+/* Copyright (c) 2023 Tom Brazier <tom_github@firstsolo.net>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+#pragma once
+
+#include "ui_tom_filtercontrols.h"
+
+#include "api/plugin-api.hpp"
+#include "compat/timer.hpp"
+#include "options/options.hpp"
+
+using namespace options;
+
+struct settings_tom : opts
+{
+ value<slider_value> responsiveness[6];
+ value<slider_value> drift_speeds[6];
+
+ settings_tom() :
+ opts("tom-filter"),
+ responsiveness{ value<slider_value>(b, "x-responsiveness", { 10.0, .0, 20.0 }),
+ value<slider_value>(b, "y-responsiveness", { 10.0, .0, 20.0 }),
+ value<slider_value>(b, "z-responsiveness", { 10.0, .0, 20.0 }),
+ value<slider_value>(b, "yaw-responsiveness", { 10.0, .0, 20.0 }),
+ value<slider_value>(b, "pitch-responsiveness", { 10.0, .0, 20.0 }),
+ value<slider_value>(b, "roll-responsiveness", { 10.0, .0, 20.0 }) },
+ drift_speeds{ value<slider_value>(b, "x-drift-speed", { 50.0, 1.0, 200.0 }),
+ value<slider_value>(b, "y-drift-speed", { 50.0, 1.0, 200.0 }),
+ value<slider_value>(b, "z-drift-speed", { 50.0, 1.0, 200.0 }),
+ value<slider_value>(b, "yaw-drift-speed", { 100.0, 1.0, 400.0 }),
+ value<slider_value>(b, "pitch-drift-speed", { 100.0, 1.0, 400.0 }),
+ value<slider_value>(b, "roll-drift-speed", { 100.0, 1.0, 400.0 }) }
+ {
+ }
+
+ /* value<slider_value> kMinSmoothing, kMaxSmoothing, kSmoothingScaleCurve;
+ settings()
+ : opts("ewma-filter"),
+ kMinSmoothing(b, "min-smoothing", { .02, .01, 1 }),
+ kMaxSmoothing(b, "max-smoothing", { .7, .01, 1 }),
+ kSmoothingScaleCurve(b, "smoothing-scale-curve", { .8, .1, 5 })
+ {
+ }
+*/
+};
+
+struct tom : IFilter
+{
+ tom();
+ void filter(const double* input, double* output) override;
+ void center() override { first_run = true; }
+ module_status initialize() override { return status_ok(); }
+
+private:
+ double last_input[6]{};
+ double speeds[6]{};
+ double filtered_output[6]{};
+ Timer t;
+ settings_tom s;
+ bool first_run = true;
+};
+
+class dialog_tom : public IFilterDialog
+{
+ Q_OBJECT
+public:
+ dialog_tom();
+ void register_filter(IFilter*) override {}
+ void unregister_filter() override {}
+ void save() override;
+ void reload() override;
+ bool embeddable() noexcept override { return true; }
+ void set_buttons_visible(bool x) override;
+
+private:
+ Ui::UICdialog_tom ui;
+ settings_tom s;
+
+private slots:
+ void doOK();
+ void doCancel();
+};
+
+class tomDll : public Metadata
+{
+ Q_OBJECT
+
+ QString name() override { return tr("Tom"); }
+ QIcon icon() override { return QIcon(":/images/filter-16.png"); }
+};