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

Function option_f32_list

src/models/ace_step/request_parser.cpp:41–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41std::vector<float> option_f32_list(const runtime::TaskRequest &request, std::string_view key) {
42 const auto value = runtime::find_option(request.options, {key});
43 if (!value.has_value()) {
44 return {};
45 }
46 std::string raw = *value;
47 raw.erase(std::remove_if(raw.begin(), raw.end(),
48 [](unsigned char ch) { return std::isspace(ch) != 0 || ch == '[' || ch == ']'; }),
49 raw.end());
50 if (raw.empty()) {
51 return {};
52 }
53 std::vector<float> out;
54 size_t start = 0;
55 while (start < raw.size()) {
56 const size_t end = raw.find(',', start);
57 const std::string_view piece(raw.data() + static_cast<std::ptrdiff_t>(start),
58 (end == std::string::npos ? raw.size() : end) - start);
59 if (!piece.empty()) {
60 out.push_back(std::stof(std::string(piece)));
61 }
62 if (end == std::string::npos) {
63 break;
64 }
65 start = end + 1;
66 }
67 return out;
68}
69
70float clamp_repaint_strength(float strength) {
71 return std::max(0.0F, std::min(1.0F, strength));

Callers 1

ace_step_parse_requestFunction · 0.85

Calls 9

find_optionFunction · 0.85
stringFunction · 0.50
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected