Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
patcher.h
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include <cstdint>
22#include <span>
23
24struct CableGroup;
25
26class Sound;
28class PatchCableSet;
29struct Destination;
30class ParamManager;
31class PatchCable;
32
33enum Globality {
34 GLOBALITY_LOCAL = 0,
35 GLOBALITY_GLOBAL = 1,
36};
37
38class Patcher {
39public:
40 struct Config {
41 uint8_t firstParam;
42 uint8_t firstNonVolumeParam;
43 uint8_t firstHybridParam;
44 uint8_t firstExpParam;
45 uint8_t endParams;
46 uint8_t globality;
47 };
48
49 Patcher(const Config& config, std::span<int32_t> source_values, std::span<int32_t> param_final_values)
50 : config(config), source_values_(source_values), param_final_values_(param_final_values) {};
51 void performInitialPatching(Sound& sound, ParamManager& param_manager);
52 void performPatching(uint32_t sources_changed, Sound& sound, ParamManagerForTimeline& param_manager);
53 void recalculateFinalValueForParamWithNoCables(int32_t param, Sound& sound, ParamManagerForTimeline& param_manager);
54
55private:
56 int32_t combineCablesLinearForRangeParam(Destination const* destination, ParamManager& param_manager);
57 int32_t combineCablesLinear(Destination const* destination, uint32_t param, Sound& sound,
58 ParamManager& param_manager);
59 int32_t combineCablesExp(Destination const* destination, uint32_t param, Sound& sound, ParamManager& param_manager);
60 static int32_t cableToLinearParamWithoutRangeAdjustment(int32_t running_total, int32_t source_value,
61 int32_t cable_strength);
62 static int32_t cableToLinearParam(int32_t running_total, const PatchCable& cable, int32_t source_value,
63 int32_t cable_strength);
64 static int32_t cableToExpParamWithoutRangeAdjustment(int32_t running_total, int32_t source_value,
65 int32_t cable_strength);
66 static int32_t cableToExpParam(int32_t running_total, const PatchCable& cable, int32_t source_value,
67 int32_t cable_strength);
68
69 const Config& config;
70 std::span<int32_t> source_values_;
71 std::span<int32_t> param_final_values_;
72};
Definition param_manager.h:174
Definition param_manager.h:45
Definition patch_cable_set.h:41
Definition patch_cable.h:29
Definition sound.h:71
Definition patch_cable_set.h:29
Definition patch_cable_set.h:34
Definition patcher.h:40