diff --git a/src/hub/hub_knob.hh b/src/hub/hub_knob.hh index c04e95e..d2ae50a 100644 --- a/src/hub/hub_knob.hh +++ b/src/hub/hub_knob.hh @@ -3,6 +3,9 @@ #include "mapping/map_marks.hh" #include "mapping/map_palette.hh" +namespace MetaModule +{ + template class HubKnob : public BaseKnobT { public: @@ -46,8 +49,7 @@ public: APP->scene->rack->setTouchedParam(this); } e.consume(this); - } - else if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { + } else if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { mapBut.start_mapping(); } } @@ -89,3 +91,5 @@ private: MetaModuleHubBase *hub; HubKnobMapButton &mapBut; }; + +} // namespace MetaModule diff --git a/src/hub/hub_knob_map_button.hh b/src/hub/hub_knob_map_button.hh index 9765435..77ae38f 100644 --- a/src/hub/hub_knob_map_button.hh +++ b/src/hub/hub_knob_map_button.hh @@ -6,6 +6,9 @@ #include "mapping/knob_alias_menu.hh" #include "mapping/range_slider.hh" +namespace MetaModule +{ + class HubKnobMapButton : public HubMapButton { rack::ParamQuantity *paramQuantity = nullptr; MetaModuleHubBase *hub; @@ -140,3 +143,5 @@ public: } }; }; + +} // namespace MetaModule diff --git a/src/hub/hub_knob_mappings.hh b/src/hub/hub_knob_mappings.hh index 26477bc..218b26d 100644 --- a/src/hub/hub_knob_mappings.hh +++ b/src/hub/hub_knob_mappings.hh @@ -12,6 +12,8 @@ // 5) which will notice the paramHandle is gone, and thus delete the map // 6) Then, hub::encodeJson is called and writes out json without that map +namespace MetaModule +{ enum class ShouldLock { No, Yes }; @@ -422,3 +424,5 @@ public: KnobMultiMap nullmap{}; }; + +} // namespace MetaModule diff --git a/src/hub/hub_map_button.cc b/src/hub/hub_map_button.cc index 209b30f..60127b3 100644 --- a/src/hub/hub_map_button.cc +++ b/src/hub/hub_map_button.cc @@ -2,6 +2,9 @@ #include "mapping/map_palette.hh" #include +namespace MetaModule +{ + void HubMapButton::draw(const DrawArgs &args) { hubParamObj.moduleID = parent.module ? parent.module->id : -1; @@ -90,3 +93,5 @@ void HubMapButton::onEnter(const rack::event::Enter &e) { } e.consume(this); } + +} // namespace MetaModule diff --git a/src/hub/hub_map_button.hh b/src/hub/hub_map_button.hh index 1e9c4b3..86dc03c 100644 --- a/src/hub/hub_map_button.hh +++ b/src/hub/hub_map_button.hh @@ -2,6 +2,9 @@ #include "hub/hub_module.hh" #include +namespace MetaModule +{ + class HubMapButton : public rack::Button { public: @@ -26,3 +29,5 @@ protected: rack::app::ModuleWidget &parent; MetaModuleHubBase *hub; }; + +} // namespace MetaModule diff --git a/src/hub/hub_medium.cc b/src/hub/hub_medium.cc index df8d6bd..6f1dd7f 100644 --- a/src/hub/hub_medium.cc +++ b/src/hub/hub_medium.cc @@ -12,8 +12,11 @@ using namespace rack; +namespace MetaModule +{ + struct HubMedium : MetaModuleHubBase { - using INFO = MetaModule::HubMediumInfo; + using INFO = HubMediumInfo; static constexpr unsigned num_extra_params = 1; //Save Button @@ -24,7 +27,7 @@ struct HubMedium : MetaModuleHubBase { config(cnt.num_params + num_extra_params, cnt.num_inputs, cnt.num_outputs, cnt.num_lights); // Configure elements with VCV - MetaModule::VCVModuleParamCreator creator{this}; + VCVModuleParamCreator creator{this}; for (auto &element : INFO::Elements) { std::visit([&creator](auto &el) { creator.config_element(el); }, element); } @@ -48,7 +51,7 @@ struct HubMedium : MetaModuleHubBase { struct HubMediumWidget : MetaModuleHubWidget { - using INFO = MetaModule::HubMediumInfo; + using INFO = HubMediumInfo; LedDisplayTextField *patchName; LedDisplayTextField *patchDesc; @@ -73,7 +76,7 @@ struct HubMediumWidget : MetaModuleHubWidget { addChild(createWidget( rack::math::Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - patchName = createWidget(rack::mm2px(rack::math::Vec(36.1, 9.5))); + patchName = createWidget(rack::mm2px(rack::math::Vec(36.1, 9.5))); if (hubModule != nullptr && hubModule->patchNameText.length() > 0) patchName->setText(this->hubModule->patchNameText); else @@ -92,7 +95,7 @@ struct HubMediumWidget : MetaModuleHubWidget { addChild(statusText); #endif - patchDesc = createWidget(rack::mm2px(rack::math::Vec(36.4, 18.f))); + patchDesc = createWidget(rack::mm2px(rack::math::Vec(36.4, 18.f))); if (hubModule != nullptr && hubModule->patchDescText.length() > 0) patchDesc->setText(this->hubModule->patchDescText); else @@ -109,11 +112,11 @@ struct HubMediumWidget : MetaModuleHubWidget { knobSetTitle->fontSize = 10; addChild(knobSetTitle); - knobSetNameField = new MetaModule::TextField{[this](std::string &text) { - auto idx = hubModule->mappings.getActiveKnobSetIdx(); - hubModule->mappings.setKnobSetName(idx, text); - }, - kMaxKnobSetNameChars}; + knobSetNameField = new TextField{[this](std::string &text) { + auto idx = hubModule->mappings.getActiveKnobSetIdx(); + hubModule->mappings.setKnobSetName(idx, text); + }, + kMaxKnobSetNameChars}; knobSetNameField->box.pos = rack::mm2px(rack::math::Vec(52.0, 49.0)); knobSetNameField->box.size = {rack::mm2px(rack::math::Vec(40.f, 7.f))}; knobSetNameField->text = ""; @@ -131,7 +134,7 @@ struct HubMediumWidget : MetaModuleHubWidget { updateKnobSetLabel(); // create widgets from all elements - MetaModule::HubWidgetCreator creator(this, module); + HubWidgetCreator creator(this, module); for (auto &element : INFO::Elements) { std::visit([&creator](auto &el) { creator.create(el); }, element); } @@ -210,4 +213,6 @@ struct HubMediumWidget : MetaModuleHubWidget { }; }; -rack::Model *modelHubMedium = rack::createModel("HubMedium"); +} // namespace MetaModule + +rack::Model *modelHubMedium = rack::createModel("HubMedium"); diff --git a/src/hub/hub_midi.hh b/src/hub/hub_midi.hh index d614ce3..08e9348 100644 --- a/src/hub/hub_midi.hh +++ b/src/hub/hub_midi.hh @@ -1,6 +1,9 @@ #pragma once #include "hub_knob.hh" +namespace MetaModule +{ + class HubMidiMapButton : public HubKnobMapButton { MetaModuleHubBase *hub; @@ -114,3 +117,5 @@ private: MetaModuleHubBase *hub; HubKnobMapButton &mapBut; }; + +} // namespace MetaModule diff --git a/src/hub/hub_module.hh b/src/hub/hub_module.hh index 8f8de29..8442622 100644 --- a/src/hub/hub_module.hh +++ b/src/hub/hub_module.hh @@ -10,6 +10,9 @@ #include #include +namespace MetaModule +{ + struct MetaModuleHubBase : public rack::Module { std::function updatePatchName; @@ -157,3 +160,5 @@ struct MetaModuleHubBase : public rack::Module { mappings.refreshParamHandles(ShouldLock::No); } }; + +} // namespace MetaModule diff --git a/src/hub/hub_module_widget.hh b/src/hub/hub_module_widget.hh index a60295d..0375dec 100644 --- a/src/hub/hub_module_widget.hh +++ b/src/hub/hub_module_widget.hh @@ -1,21 +1,15 @@ #pragma once -#include "../comm/comm_module.hh" -#include "CoreModules/moduleFactory.hh" #include "hub/knob_set_buttons.hh" #include "hub/knob_set_menu.hh" #include "hub/text_field.hh" #include "hub_knob.hh" -#include "hub_midi.hh" #include "hub_module.hh" -#include "mapping/ModuleID.h" -#include "mapping/map_palette.hh" -#include "mapping/module_directory.hh" -#include "mapping/patch_writer.hh" -#include "util/math.hh" -#include "util/string_util.hh" #include #include +namespace MetaModule +{ + struct MetaModuleHubWidget : rack::app::ModuleWidget { MetaModuleHubWidget() = default; @@ -23,7 +17,7 @@ struct MetaModuleHubWidget : rack::app::ModuleWidget { rack::Label *statusText; KnobSetButtonGroup *knobSetButtons; - MetaModule::TextField *knobSetNameField; + TextField *knobSetNameField; static constexpr float kKnobSpacingY = 17; static constexpr float kKnobSpacingX = 18; @@ -102,3 +96,5 @@ struct MetaModuleHubWidget : rack::app::ModuleWidget { knobSetButtons->active_idx = activeKnobSetIdx; } }; + +} // namespace MetaModule diff --git a/src/hub/knob_set_menu.hh b/src/hub/knob_set_menu.hh index 383d5b0..361a40f 100644 --- a/src/hub/knob_set_menu.hh +++ b/src/hub/knob_set_menu.hh @@ -2,6 +2,9 @@ #include "hub/hub_module.hh" #include +namespace MetaModule +{ + struct KnobSetNameTextBox : rack::ui::TextField { using CallbackT = std::function; CallbackT onChangeCallback; @@ -48,3 +51,5 @@ struct KnobSetNameMenuItem : rack::widget::Widget { Widget::draw(args); } }; + +} // namespace MetaModule diff --git a/src/mapping/knob_alias_menu.hh b/src/mapping/knob_alias_menu.hh index 6b16528..8195050 100644 --- a/src/mapping/knob_alias_menu.hh +++ b/src/mapping/knob_alias_menu.hh @@ -2,6 +2,9 @@ #include "hub/hub_module.hh" #include +namespace MetaModule +{ + struct KnobAliasTextBox : rack::ui::TextField { MappableObj src; MetaModuleHubBase *hub; @@ -39,3 +42,5 @@ struct KnobAliasMenuItem : rack::widget::Widget { Widget::draw(args); } }; + +} // namespace MetaModule diff --git a/src/mapping/patch_writer.cc b/src/mapping/patch_writer.cc index 767d5fb..8e05ce1 100644 --- a/src/mapping/patch_writer.cc +++ b/src/mapping/patch_writer.cc @@ -3,9 +3,11 @@ #include "mapping/midi_modules.hh" #include "mapping/module_directory.hh" #include "patch-serial/patch_to_yaml.hh" -#include "patch-serial/ryml/ryml_serial.hh" #include +namespace MetaModule +{ + PatchFileWriter::PatchFileWriter(std::vector modules, int64_t hubModuleId) : hubModuleId{hubModuleId} { setModuleList(modules); @@ -24,7 +26,7 @@ void PatchFileWriter::setPatchDesc(std::string patchDesc) { pd.description = patchDesc.c_str(); } -void PatchFileWriter::setMidiSettings(MetaModule::MIDI::ModuleIds &ids, MetaModule::MIDI::Settings const &settings) { +void PatchFileWriter::setMidiSettings(MIDI::ModuleIds &ids, MIDI::Settings const &settings) { midiModuleIds = ids; midiSettings = settings; @@ -298,7 +300,7 @@ void PatchFileWriter::mapMidiCVPolySplitJack(CableMap &cable, unsigned monoJackI } void PatchFileWriter::mapMidiCVJack(CableMap &cable) { - using enum MetaModule::MIDI::CoreMidiJacks; + using enum MIDI::CoreMidiJacks; if (cable.sendingJackId == VoctJack) cable.sendingJackId = MidiMonoNoteJack; @@ -373,6 +375,8 @@ std::map PatchFileWriter::squash_ids(std::vector ids return s; } -MetaModule::PatchData &PatchFileWriter::get_data() { +PatchData &PatchFileWriter::get_data() { return pd; } + +} // namespace MetaModule diff --git a/src/mapping/patch_writer.hh b/src/mapping/patch_writer.hh index 4a36bbe..b72055d 100644 --- a/src/mapping/patch_writer.hh +++ b/src/mapping/patch_writer.hh @@ -2,16 +2,17 @@ #include "JackMap.hh" #include "ModuleID.h" #include "ParamMap.hh" -#include "jansson.h" #include "mapping/mapping.hh" #include "mapping/midi_modules.hh" -#include "patch-serial/patch_to_yaml.hh" -#include "patch/patch.hh" +#include "patch/patch_data.hh" #include #include #include #include +namespace MetaModule +{ + class PatchFileWriter { public: PatchFileWriter(std::vector modules, int64_t hubModuleId); @@ -21,7 +22,7 @@ public: void setPatchDesc(std::string patchDesc); void setCableList(std::vector &cables); void setParamList(std::vector ¶ms); - void setMidiSettings(MetaModule::MIDI::ModuleIds &ids, MetaModule::MIDI::Settings const &settings); + void setMidiSettings(MIDI::ModuleIds &ids, MIDI::Settings const &settings); void addModuleStateJson(rack::Module *module); void addKnobMaps(unsigned panelKnobId, unsigned knobSetId, const std::span maps); @@ -29,7 +30,7 @@ public: std::string printPatchYAML(); - MetaModule::PatchData &get_data(); + PatchData &get_data(); static std::map squash_ids(std::vector ids); private: @@ -43,11 +44,13 @@ private: void setModuleList(std::vector &modules); - MetaModule::PatchData pd; + PatchData pd; int64_t hubModuleId = -1; - MetaModule::MIDI::ModuleIds midiModuleIds; - MetaModule::MIDI::Settings midiSettings; + MIDI::ModuleIds midiModuleIds; + MIDI::Settings midiSettings; std::map idMap; // idMap[64 bit VCV module id] -> 16 bit MM-patch module id }; + +} // namespace MetaModule diff --git a/src/mapping/range_slider.hh b/src/mapping/range_slider.hh index b11ec9a..8e800ba 100644 --- a/src/mapping/range_slider.hh +++ b/src/mapping/range_slider.hh @@ -3,6 +3,9 @@ #include "hub/hub_module.hh" #include +namespace MetaModule +{ + enum class RangePart { Min, Max }; template @@ -57,3 +60,5 @@ public: delete quantity; } }; + +} // namespace MetaModule diff --git a/src/mapping/vcv_patch_file_writer.hh b/src/mapping/vcv_patch_file_writer.hh index 97bebb4..0ffc3fd 100644 --- a/src/mapping/vcv_patch_file_writer.hh +++ b/src/mapping/vcv_patch_file_writer.hh @@ -12,6 +12,9 @@ #include #include +namespace MetaModule +{ + // Adpats VCVRack-format of patch data to a format PatchFileWriter can use template struct VCVPatchFileWriter { @@ -31,7 +34,7 @@ struct VCVPatchFileWriter { std::vector moduleData; std::vector paramData; std::vector splitModuleIds; - MetaModule::MIDI::Modules midimodules; + MIDI::Modules midimodules; auto moduleIDs = engine->getModuleIds(); for (auto moduleID : moduleIDs) { @@ -165,3 +168,5 @@ struct VCVPatchFileWriter { myfile.close(); } }; + +} // namespace MetaModule diff --git a/src/widgets/vcv_widget_creator.hh b/src/widgets/vcv_widget_creator.hh index 8444696..060591a 100644 --- a/src/widgets/vcv_widget_creator.hh +++ b/src/widgets/vcv_widget_creator.hh @@ -36,7 +36,7 @@ struct VCVWidgetCreator { template void create(const EL &element) { // alt parameters do not have a widget - if constexpr (not std::derived_from) { + if constexpr (not std::derived_from) { // forward to implementation together with current context if (auto indices = ElementCount::get_indices(element)) { VCVImplementation::Widget::do_create(element, indices.value(), context); @@ -47,7 +47,7 @@ struct VCVWidgetCreator { template void renderToContextMenu(const EL &element, rack::ui::Menu *menu) { // only alt parameters are considered for rendering to menu for now - if constexpr (std::derived_from) { + if constexpr (std::derived_from) { // forward to implementation with required context if (auto indices = ElementCount::get_indices(element)) { VCVImplementation::Widget::do_render_to_menu(element, menu, indices.value(), context);