From a18022d4243de7b2093507c574689c7a17c82bb9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 11 Oct 2008 21:02:10 +0000 Subject: Add control randomize feature (node context menu). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1648 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/NodeModel.cpp | 2 +- src/client/NodeModel.hpp | 10 +- src/gui/NodeMenu.cpp | 57 ++- src/gui/NodeMenu.hpp | 3 +- src/gui/NodeModule.cpp | 1 + src/gui/NodeModule.hpp | 2 +- src/gui/ingen_gui.glade | 1009 +++++++++++++++++++++++----------------------- 7 files changed, 546 insertions(+), 538 deletions(-) (limited to 'src') diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index af1f959e..ad04892f 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -171,7 +171,7 @@ NodeModel::port(uint32_t index) const void -NodeModel::port_value_range(SharedPtr port, float& min, float& max) +NodeModel::port_value_range(SharedPtr port, float& min, float& max) const { assert(port->parent().get() == this); diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index 03afc17c..9b6efde8 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -62,7 +62,7 @@ public: uint32_t num_ports() const { return _ports.size(); } const Ports& ports() const { return _ports; } - void port_value_range(SharedPtr port, float& min, float& max); + void port_value_range(SharedPtr port, float& min, float& max) const; // Signals sigc::signal > signal_new_port; @@ -89,9 +89,11 @@ protected: Ports _ports; ///< Vector of ports (not a Table to preserve order) string _plugin_uri; ///< Plugin URI (if PluginModel is unknown) SharedPtr _plugin; ///< The plugin this node is an instance of - uint32_t _num_values; ///< Size of _min_values and _max_values - float* _min_values; ///< Port min values (cached for LV2) - float* _max_values; ///< Port max values (cached for LV2) + +private: + mutable uint32_t _num_values; ///< Size of _min_values and _max_values + mutable float* _min_values; ///< Port min values (cached for LV2) + mutable float* _max_values; ///< Port max values (cached for LV2) }; diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 529eb52c..43c0bf75 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -39,10 +39,14 @@ NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtrget_widget("node_controls_menuitem", _controls_menuitem); xml->get_widget("node_popup_gui_menuitem", _popup_gui_menuitem); xml->get_widget("node_embed_gui_menuitem", _embed_gui_menuitem); + xml->get_widget("node_randomize_menuitem", _randomize_menuitem); node_menu->remove(*_controls_menuitem); node_menu->remove(*_popup_gui_menuitem); node_menu->remove(*_embed_gui_menuitem); + node_menu->remove(*_randomize_menuitem); + + insert(*_randomize_menuitem, 0); items().push_front(Gtk::Menu_Helpers::SeparatorElem()); insert(*_controls_menuitem, 0); insert(*_popup_gui_menuitem, 0); @@ -63,6 +67,8 @@ NodeMenu::init(SharedPtr node) &sigc::signal::emit)); _embed_gui_menuitem->signal_toggled().connect(sigc::mem_fun(this, &NodeMenu::on_menu_embed_gui)); + _randomize_menuitem->signal_activate().connect(sigc::mem_fun(this, + &NodeMenu::on_menu_randomize)); const PluginModel* plugin = dynamic_cast(node->plugin()); if (plugin && plugin->type() == PluginModel::LV2 && plugin->has_ui()) { @@ -73,6 +79,11 @@ NodeMenu::init(SharedPtr node) _embed_gui_menuitem->hide(); } + if (has_control_inputs()) + _randomize_menuitem->show(); + else + _randomize_menuitem->hide(); + _enable_signal = true; } @@ -85,41 +96,21 @@ NodeMenu::on_menu_embed_gui() void -NodeMenu::on_menu_clone() +NodeMenu::on_menu_randomize() { - cerr << "[NodeMenu] FIXME: clone broken\n"; - /* - assert(_node); - //assert(_parent != NULL); - //assert(_parent->model() != NULL); - - string clone_name = _node->name(); - int i = 2; // postfix number (ie oldname_2) - - // Check if name already has a number postfix - if (clone_name.find_last_of("_") != string::npos) { - string name_postfix = clone_name.substr(clone_name.find_last_of("_")+1); - clone_name = clone_name.substr(0, clone_name.find_last_of("_")); - if (sscanf(name_postfix.c_str(), "%d", &i)) - ++i; - } - - char clone_postfix[4]; - for ( ; i < 100; ++i) { - snprintf(clone_postfix, 4, "_%d", i); - if (_node->parent_patch()->get_node(clone_name + clone_postfix) == NULL) - break; + App::instance().engine()->bundle_begin(); + + const NodeModel* const nm = (NodeModel*)_object.get(); + for (NodeModel::Ports::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) { + if ((*i)->is_input() && (*i)->type().is_control()) { + float min = 0.0f, max = 1.0f; + nm->port_value_range(*i, min, max); + const float val = ((rand() / (float)RAND_MAX) * (max - min) + min); + App::instance().engine()->set_port_value((*i)->path(), val); + } } - - clone_name = clone_name + clone_postfix; - - const string path = _node->parent_patch()->base() + clone_name; - NodeModel* nm = new NodeModel(_node->plugin(), path); - nm->polyphonic(_node->polyphonic()); - nm->x(_node->x() + 20); - nm->y(_node->y() + 20); - App::instance().engine()->create_node_from_model(nm); - */ + + App::instance().engine()->bundle_end(); } diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp index 2a10e473..67bed69a 100644 --- a/src/gui/NodeMenu.hpp +++ b/src/gui/NodeMenu.hpp @@ -56,13 +56,14 @@ protected: virtual void disable_controls_menuitem(); void on_menu_disconnect(); - void on_menu_clone(); void on_menu_learn(); void on_menu_embed_gui(); + void on_menu_randomize(); Gtk::MenuItem* _controls_menuitem; Gtk::MenuItem* _popup_gui_menuitem; Gtk::CheckMenuItem* _embed_gui_menuitem; + Gtk::MenuItem* _randomize_menuitem; }; diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index ee6b61d9..7f891a51 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -32,6 +32,7 @@ #include "SubpatchModule.hpp" #include "WindowFactory.hpp" #include "Configuration.hpp" +#include "NodeMenu.hpp" using namespace std; diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index de9556fd..5747bf30 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -22,7 +22,6 @@ #include #include #include "Port.hpp" -#include "NodeMenu.hpp" class Atom; @@ -37,6 +36,7 @@ namespace GUI { class PatchCanvas; class Port; +class NodeMenu; /** A module in a patch. diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index aa0680ea..a86a4b4a 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -497,62 +497,53 @@ 3 12 - + True - True - Clear filter text (show all plugins) - gtk-clear - True - 0 + 1 + Node Name: + True - 2 - 3 + 2 + 3 GTK_FILL - + True - Name contains: + 1 + 2 + 1 + 2 GTK_FILL - - + True - True - True - Search string to filter plugin list - * - 1 - 2 - 6 + 1 + 2 + GTK_FILL + GTK_FILL - + True - False - True - Add selected plugin to patch - gtk-add - True - 0 2 3 - 2 - 3 + 1 + 2 GTK_FILL - + GTK_FILL @@ -595,51 +586,60 @@ - + True + False + True + Add selected plugin to patch + gtk-add + True + 0 2 3 - 1 - 2 + 2 + 3 GTK_FILL - GTK_FILL + - + True + True + True + Search string to filter plugin list + * - 1 - 2 - GTK_FILL - GTK_FILL + 1 + 2 + 6 - + True + Name contains: - 1 - 2 - 1 - 2 GTK_FILL + - + True - 1 - Node Name: - True + True + Clear filter text (show all plugins) + gtk-clear + True + 0 - 2 - 3 + 2 + 3 GTK_FILL @@ -670,61 +670,61 @@ 2 2 - + True - True - True - * - True + 0 + Name: - 1 - 2 - - 4 + GTK_FILL + GTK_EXPAND + 5 - + True - True - 1 0 100 1 10 10 - 1 + 0 + Polyphony: - 1 - 2 1 2 GTK_FILL - - 4 + GTK_EXPAND + 5 - + True - 0 - Polyphony: + True + 1 0 100 1 10 10 + 1 + 1 + 2 1 2 GTK_FILL - GTK_EXPAND - 5 + + 4 - + True - 0 - Name: + True + True + * + True - GTK_FILL - GTK_EXPAND - 5 + 1 + 2 + + 4 @@ -826,71 +826,63 @@ 12 4 - + True - - - True - True - Specify the name for the new patch - Specify: - True - 0 - True - load_subpatch_name_from_file_radio - - - False - False - - - - - True - False - True - Specify the name for the new patch - * - True - - - False - 1 - - + 0 + <b>Name: </b> + True - 3 - 4 - GTK_FILL + GTK_FILL + - + True 0 + <b>Polyphony: </b> + True - 2 - 3 + 1 + 2 GTK_FILL - + True True - Set polyphony to the same value as the parent (containing) patch - Same as parent (?) + Use the name stored in the patch file + Load from file True 0 + True True - load_subpatch_poly_from_file_radio - 2 - 3 + 1 + 2 + GTK_FILL + + + + + + True + True + Use the polyphony value stored in the patch file + Load from file + True + 0 + True + True + + + 1 + 2 1 2 GTK_FILL @@ -941,19 +933,19 @@ - + True True - Use the polyphony value stored in the patch file - Load from file + Set polyphony to the same value as the parent (containing) patch + Same as parent (?) True 0 - True True + load_subpatch_poly_from_file_radio - 1 - 2 + 2 + 3 1 2 GTK_FILL @@ -961,47 +953,55 @@ - - True - True - Use the name stored in the patch file - Load from file - True - 0 - True - True - - - 1 - 2 - GTK_FILL - - - - - + True 0 - <b>Polyphony: </b> - True - 1 - 2 + 2 + 3 GTK_FILL - + True - 0 - <b>Name: </b> - True + + + True + True + Specify the name for the new patch + Specify: + True + 0 + True + load_subpatch_name_from_file_radio + + + False + False + + + + + True + False + True + Specify the name for the new patch + * + True + + + False + 1 + + - GTK_FILL - + 3 + 4 + GTK_FILL @@ -1062,6 +1062,54 @@ 4 12 4 + + + True + 0 + <b>Polyphony: </b> + True + + + GTK_FILL + + + + + + True + True + Use the same polyphony as the current patch + Keep current + True + 0 + True + True + + + 1 + 2 + GTK_FILL + + + + + + True + True + Use the polyphony value stored in the patch file + Load from file + True + 0 + True + load_patch_poly_from_current_radio + + + 2 + 3 + GTK_FILL + + + True @@ -1102,54 +1150,6 @@ GTK_FILL - - - True - True - Use the polyphony value stored in the patch file - Load from file - True - 0 - True - load_patch_poly_from_current_radio - - - 2 - 3 - GTK_FILL - - - - - - True - True - Use the same polyphony as the current patch - Keep current - True - 0 - True - True - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - <b>Polyphony: </b> - True - - - GTK_FILL - - - False @@ -1216,15 +1216,15 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True 0 1 @@ -1239,74 +1239,145 @@ - + + True + 1 + 0 + 1 + 1 + 4 + + + True + + + + + 1 + + + + + True + True + 0 + True + + + False + 2 + + + + + False + False + + + + + 4 + 5 + 8 + + + + + True + + + True + 0 + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + + + True + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + + + + + + + True + True + + + True + True + Apply changed controls to all voices + All Voices + True + 0 + True + + + False + False + + + + True - 1 - 0 - 1 - 1 - 4 + 5 - + + True + True + Apply changed controls to one voice only + Specific Voice: + True + 0 + True + control_panel_all_voices_radio + + + False + False + + + + True + False + True + Voice control changes are applied to + 1 1 100 1 10 10 + 1 + True + + 1 + - - 1 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 12 - 0 -9.9999999999999999e+45 1.0000000000000001e+63 1 10 10 - 4 - True - False - 2 + False + 1 False - False - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 9.0923076923076922e+136 -1e+113 1e+137 0 0 0 - 63 - False - - - False + 5 1 - - 3 - 4 - 8 - - - - - True - - - 1 - 2 - GTK_FILL - @@ -1569,113 +1640,25 @@ - + True - - - True - 0 - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - - - True - GTK_SHADOW_NONE - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - - - - - - - - - True - True - - - True - True - Apply changed controls to all voices - All Voices - True - 0 - True - - - False - False - - - - - True - 5 - - - True - True - Apply changed controls to one voice only - Specific Voice: - True - 0 - True - control_panel_all_voices_radio - - - False - False - - - - - True - False - True - Voice control changes are applied to - 1 1 100 1 10 10 - 1 - True - - - 1 - - - - - False - False - 1 - - - - - False - 5 - 1 - - + + 1 + 2 + GTK_FILL + - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True 0 1 @@ -1690,7 +1673,7 @@ - + True 1 0 @@ -1698,7 +1681,7 @@ 1 4 - + True @@ -1708,11 +1691,14 @@ - + True True - 0 - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + 0 -9.9999999999999999e+45 1.0000000000000001e+63 1 10 10 + 4 + True False @@ -1725,10 +1711,24 @@ False + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 9.0923076923076922e+136 -1e+113 1e+137 0 0 0 + 63 + False + + + False + 1 + + - 4 - 5 + 3 + 4 8 @@ -1820,51 +1820,51 @@ 2 2 - + True - 0 + <b>Patch Search Path: </b> + True - 1 - 2 GTK_FILL - + True - <i>Example: /foo/bar:/home/john/patches:/usr/share/om/patches</i> - True + True + * 1 2 - 1 - 2 - GTK_FILL - + True - True - * + <i>Example: /foo/bar:/home/john/patches:/usr/share/om/patches</i> + True 1 2 + 1 + 2 + GTK_FILL - + True - <b>Patch Search Path: </b> - True + 0 + 1 + 2 GTK_FILL @@ -2241,7 +2241,7 @@ 10 6 - + True 0 - @@ -2249,34 +2249,28 @@ 1 2 - 2 - 3 GTK_FILL - + True 0 - Name: + Type: - 2 - 3 GTK_FILL - + True 0 - - + URI: - 1 - 2 1 2 GTK_FILL @@ -2284,12 +2278,14 @@ - + True 0 - URI: + - + 1 + 2 1 2 GTK_FILL @@ -2297,18 +2293,20 @@ - + True 0 - Type: + Name: + 2 + 3 GTK_FILL - + True 0 - @@ -2316,6 +2314,8 @@ 1 2 + 2 + 3 GTK_FILL @@ -2468,33 +2468,64 @@ Contributors: 2 8 - + True - 0 + + + True + False + True + 16180 1 65535 1 10 10 + 1 + True + + + False + False + + + + + 1 + 2 + 1 + 2 + GTK_FILL + 8 + + + + + True + + + True + True + * + True + 28 + osc.udp://localhost:16180 + + 1 2 - 2 - 3 GTK_FILL - + GTK_FILL + 8 - + True - False True - Use internal engine + Connect to running server at: True 0 True - connect_server_radiobutton - 2 - 3 GTK_FILL @@ -2517,66 +2548,35 @@ Contributors: - + True + False True - Connect to running server at: + Use internal engine True 0 True + connect_server_radiobutton + 2 + 3 GTK_FILL - + True - - - True - True - * - True - 28 - osc.udp://localhost:16180 - - + 0 1 2 + 2 + 3 GTK_FILL - GTK_FILL - 8 - - - - - True - - - True - False - True - 16180 1 65535 1 10 10 - 1 - True - - - False - False - - - - - 1 - 2 - 1 - 2 - GTK_FILL - 8 + @@ -2935,26 +2935,19 @@ Contributors: 2 8 - - True - 0 - Short Name: - - - 1 - 2 - GTK_FILL - - - - - + True - 0 - Symbol: + True + Enter a short name suitable for use as an identifier or filename. + +The first character must be one of _, a-z or A-Z and subsequenct characters can be from _, a-z, A-Z or 0-9. + + * + True - GTK_FILL + 1 + 2 @@ -2975,19 +2968,26 @@ Contributors: - + True - True - Enter a short name suitable for use as an identifier or filename. - -The first character must be one of _, a-z or A-Z and subsequenct characters can be from _, a-z, A-Z or 0-9. - - * - True + 0 + Symbol: - 1 - 2 + GTK_FILL + + + + + + True + 0 + Short Name: + + + 1 + 2 + GTK_FILL @@ -3130,26 +3130,17 @@ Thank you for contributing. 2 4 - - True - 0 - Maximum Value: - - - 1 - 2 - GTK_FILL - - - - - + True - 0 - Minimum Value: + True + 0 -100000000 100000000 1 10 10 + 1 + 5 + True - GTK_FILL + 1 + 2 @@ -3171,17 +3162,26 @@ Thank you for contributing. - + True - True - 0 -100000000 100000000 1 10 10 - 1 - 5 - True + 0 + Minimum Value: - 1 - 2 + GTK_FILL + + + + + + True + 0 + Maximum Value: + + + 1 + 2 + GTK_FILL @@ -3333,5 +3333,18 @@ Thank you for contributing. True + + + True + Set all controls on this node to random values + Randomize + True + + + gtk-dialog-warning + + + + -- cgit v1.2.1