// Copyright (c) 2026 Robin Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #pragma once #include #include "json.hpp" #include "Pedalboard.hpp" #include namespace pipedal { class ChannelRouterSettings { protected: bool configured_ = false; int64_t channelRouterPresetId_ = -1; bool changed_ = false; std::vector mainInputChannels_ = {1, 1}; std::vector mainOutputChannels_ = {0, 1}; std::vector auxInputChannels_ = {-1, -1}; std::vector auxOutputChannels_ = {-1, -1}; public: using self = ChannelRouterSettings; using ptr = std::shared_ptr; ChannelRouterSettings(); uint64_t numberOfAudioInputChannels() const; uint64_t numberOfAudioOutputChannels() const; JSON_GETTER_SETTER(configured) JSON_GETTER_SETTER(channelRouterPresetId) JSON_GETTER_SETTER(changed) JSON_GETTER_SETTER_REF(mainInputChannels) JSON_GETTER_SETTER_REF(mainOutputChannels) JSON_GETTER_SETTER_REF(auxInputChannels) JSON_GETTER_SETTER_REF(auxOutputChannels) DECLARE_JSON_MAP(ChannelRouterSettings); }; // just the channel selecttions. class ChannelSelection { public: ChannelSelection() = default; ChannelSelection(ChannelRouterSettings &settings); ChannelSelection(const ChannelSelection &other) = default; ChannelSelection(ChannelSelection &&other) = default; ChannelSelection &operator=(const ChannelSelection &other) = default; ChannelSelection &operator=(ChannelSelection &&other) = default; ~ChannelSelection() = default; const std::vector &mainInputChannels() const { return mainInputChannels_; } const std::vector &mainOutputChannels() const { return mainOutputChannels_; } const std::vector &auxInputChannels() const { return auxInputChannels_; } const std::vector &auxOutputChannels() const { return auxOutputChannels_; } std::vector &mainInputChannels() { return mainInputChannels_; } std::vector &mainOutputChannels() { return mainOutputChannels_; } std::vector &auxInputChannels() { return auxInputChannels_; } std::vector &auxOutputChannels() { return auxOutputChannels_; } bool IsValid() const; private: void normalizeChannelSelection(); std::vector mainInputChannels_; std::vector mainOutputChannels_; std::vector auxInputChannels_; std::vector auxOutputChannels_; }; class ChannelRouterPresetIndexEntry { private: int64_t id_ = -1; std::string name_; public: ChannelRouterPresetIndexEntry() = default; ChannelRouterPresetIndexEntry(const ChannelRouterPresetIndexEntry&other) = default; ChannelRouterPresetIndexEntry(ChannelRouterPresetIndexEntry&&other) = default; ChannelRouterPresetIndexEntry&operator=(const ChannelRouterPresetIndexEntry&other) = default; ChannelRouterPresetIndexEntry&operator=(ChannelRouterPresetIndexEntry&&other) = default; ChannelRouterPresetIndexEntry(int64_t id, const std::string&name) : id_(id),name_(name) { } JSON_GETTER_SETTER(id) JSON_GETTER_SETTER_REF(name) DECLARE_JSON_MAP(ChannelRouterPresetIndexEntry); }; class ChannelRouterPresetBankEntry { private: int64_t id_; std::string name_; ChannelRouterSettings channelRouterSettings_; public: JSON_GETTER_SETTER(id) JSON_GETTER_SETTER_REF(name) JSON_GETTER_SETTER_REF(channelRouterSettings) DECLARE_JSON_MAP(ChannelRouterPresetBankEntry); }; class ChannelRouterPresetBank { private: int64_t nextId_ = 1; int64_t version_ = 1; std::vector> entries_; public: JSON_GETTER_SETTER(nextId) JSON_GETTER_SETTER(version) JSON_GETTER_SETTER_REF(entries) std::vector getIndexEntries(); DECLARE_JSON_MAP(ChannelRouterPresetBank); }; }