MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / apply_repaint_mode_strength

Function apply_repaint_mode_strength

src/models/ace_step/request_parser.cpp:88–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void apply_repaint_mode_strength(AceStepGenerationOptions & options, const runtime::TaskRequest & request) {
89 const auto mode_value = runtime::find_option(request.options, {"repaint_mode"});
90 const auto strength_value = runtime::find_option(request.options, {"repaint_strength"});
91 if (!mode_value.has_value() && !strength_value.has_value()) {
92 return;
93 }
94
95 const std::string mode = mode_value.value_or("balanced");
96 const float strength = clamp_repaint_strength(
97 strength_value.has_value() ? runtime::parse_float_option(request.options, {"repaint_strength"}).value() : 0.5F);
98 if (mode == "aggressive") {
99 options.repaint_injection_ratio = 0.0F;
100 options.repaint_crossfade_frames = 0;
101 return;
102 }
103 if (mode == "conservative") {
104 options.repaint_injection_ratio = 1.0F;
105 options.repaint_crossfade_frames = 25;
106 return;
107 }
108 if (mode != "balanced") {
109 throw std::runtime_error("ACE-Step repaint_mode must be balanced, conservative, or aggressive");
110 }
111 const float inv_strength = 1.0F - strength;
112 options.repaint_injection_ratio = inv_strength;
113 options.repaint_crossfade_frames = python_round_to_int(25.0F * inv_strength);
114}
115
116} // namespace
117

Callers 1

ace_step_parse_requestFunction · 0.85

Calls 4

find_optionFunction · 0.85
clamp_repaint_strengthFunction · 0.85
parse_float_optionFunction · 0.85
python_round_to_intFunction · 0.85

Tested by

no test coverage detected