diff options
author | David Robillard <d@drobilla.net> | 2015-01-06 23:04:28 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-01-06 23:04:28 -0500 |
commit | 4d202d9157bef5b6325fe54b7874080952f86a37 (patch) | |
tree | 2269b30b9cecab70bbd21f2510721faf6236dea6 | |
parent | 82c5349e6178de2b682346709c9c75b3171cca8e (diff) |
Add modulus operator to MIDI transformer.
Useful for doing things like making alternating bowing patterns.
-rw-r--r-- | gtk2_ardour/transform_dialog.cc | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/transform.h | 3 | ||||
-rw-r--r-- | libs/ardour/transform.cc | 6 |
3 files changed, 9 insertions, 2 deletions
diff --git a/gtk2_ardour/transform_dialog.cc b/gtk2_ardour/transform_dialog.cc index 35df027187..762f504aa2 100644 --- a/gtk2_ardour/transform_dialog.cc +++ b/gtk2_ardour/transform_dialog.cc @@ -69,7 +69,7 @@ TransformDialog::Model::Model() } static const char* operator_labels[] = { - /* no PUSH */ "+", "-", "*", "/", NULL + /* no PUSH */ "+", "-", "*", "/", "mod", NULL }; for (int o = 0; operator_labels[o]; ++o) { Gtk::TreeModel::Row row = *(operator_list->append()); diff --git a/libs/ardour/ardour/transform.h b/libs/ardour/ardour/transform.h index 2b63bb6af0..08e4a43521 100644 --- a/libs/ardour/ardour/transform.h +++ b/libs/ardour/ardour/transform.h @@ -106,7 +106,8 @@ public: ADD, ///< Add top two values SUB, ///< Subtract top from second-top MULT, ///< Multiply top two values - DIV ///< Divide second-top by top + DIV, ///< Divide second-top by top + MOD ///< Modulus (division remainder) }; Operation(Operator o, const Value& a=Value()) : op(o), arg(a) {} diff --git a/libs/ardour/transform.cc b/libs/ardour/transform.cc index 9a91a65731..3b4f53c860 100644 --- a/libs/ardour/transform.cc +++ b/libs/ardour/transform.cc @@ -106,6 +106,12 @@ Transform::Operation::eval(Context& ctx) const } value /= rhs.to_double(); break; + case MOD: + if (rhs.to_double() == 0.0) { + return; // Program will fail safely + } + value = fmod(value, rhs.to_double()); + break; default: break; } |