Fix wine build
[carla.git] / source / rest / carla-host.cpp
blobd22c7d49a4193bbab97a9a62f45c5914e11bfb15
1 /*
2 * Carla REST API Server
3 * Copyright (C) 2018 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "common.hpp"
20 #include "CarlaHost.h"
21 #include "CarlaBackendUtils.hpp"
23 // -------------------------------------------------------------------------------------------------------------------
25 static bool gEngineRunning = false;
27 // -------------------------------------------------------------------------------------------------------------------
29 static void EngineCallback(void* ptr, EngineCallbackOpcode action, uint pluginId, int value1, int value2, float value3, const char* valueStr)
31 carla_debug("EngineCallback(%p, %u:%s, %u, %i, %i, %f, %s)",
32 ptr, (uint)action, EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valueStr);
34 char msgBuf[1024];
35 std::snprintf(msgBuf, 1023, "Carla: %u %u %i %i %f %s", action, pluginId, value1, value2, value3, valueStr);
36 msgBuf[1023] = '\0';
38 switch (action)
40 case ENGINE_CALLBACK_ENGINE_STARTED:
41 gEngineRunning = true;
42 break;
43 case ENGINE_CALLBACK_ENGINE_STOPPED:
44 case ENGINE_CALLBACK_QUIT:
45 gEngineRunning = false;
46 break;
47 default:
48 break;
51 return send_server_side_message(msgBuf);
53 // maybe unused
54 (void)ptr;
57 static const char* FileCallback(void* ptr, FileCallbackOpcode action, bool isDir, const char* title, const char* filter)
59 carla_stdout("FileCallback(%p, %u:%s, %s, %s, %s)",
60 ptr, (uint)action, FileCallbackOpcode(action), bool2str(isDir), title, filter);
62 char msgBuf[1024];
63 std::snprintf(msgBuf, 1023, "fc %u %i \"%s\" \"%s\"", action, isDir, title, filter);
64 msgBuf[1023] = '\0';
66 send_server_side_message(msgBuf);
68 // FIXME, need to wait for response!
69 return nullptr;
72 // -------------------------------------------------------------------------------------------------------------------
74 void handle_carla_get_engine_driver_count(const std::shared_ptr<Session> session)
76 const char* const buf = str_buf_uint(carla_get_engine_driver_count());
77 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
80 void handle_carla_get_engine_driver_name(const std::shared_ptr<Session> session)
82 const std::shared_ptr<const Request> request = session->get_request();
84 const int index = std::atoi(request->get_query_parameter("index").c_str());
85 CARLA_SAFE_ASSERT_RETURN(index >= 0 /*&& index < INT_MAX*/,)
87 const char* const buf = str_buf_string(carla_get_engine_driver_name(index));
88 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
91 void handle_carla_get_engine_driver_device_names(const std::shared_ptr<Session> session)
93 const std::shared_ptr<const Request> request = session->get_request();
95 const int index = std::atoi(request->get_query_parameter("index").c_str());
96 CARLA_SAFE_ASSERT_RETURN(index >= 0 /*&& index < INT_MAX*/,)
98 const char* const buf = str_buf_string_array(carla_get_engine_driver_device_names(index));
99 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
102 void handle_carla_get_engine_driver_device_info(const std::shared_ptr<Session> session)
104 const std::shared_ptr<const Request> request = session->get_request();
106 const int index = std::atoi(request->get_query_parameter("index").c_str());
107 CARLA_SAFE_ASSERT_RETURN(index >= 0 /*&& index < INT_MAX*/,)
109 const std::string name = request->get_query_parameter("name");
111 const EngineDriverDeviceInfo* const info = carla_get_engine_driver_device_info(index, name.c_str());
113 char* jsonBuf;
114 jsonBuf = json_buf_start();
115 jsonBuf = json_buf_add_uint(jsonBuf, "hints", info->hints);
116 jsonBuf = json_buf_add_uint_array(jsonBuf, "bufferSizes", info->bufferSizes);
117 jsonBuf = json_buf_add_float_array(jsonBuf, "sampleRates", info->sampleRates);
119 const char* const buf = json_buf_end(jsonBuf);
120 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
123 // -------------------------------------------------------------------------------------------------------------------
125 void handle_carla_engine_init(const std::shared_ptr<Session> session)
127 // setup callbacks
128 carla_set_engine_callback(EngineCallback, nullptr);
129 carla_set_file_callback(FileCallback, nullptr);
131 // handle request now
132 const std::shared_ptr<const Request> request = session->get_request();
134 const std::string driverName = request->get_query_parameter("driverName");
135 const std::string clientName = request->get_query_parameter("clientName");
137 const char* const buf = str_buf_bool(carla_engine_init(driverName.c_str(), clientName.c_str()));
138 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
141 void handle_carla_engine_close(const std::shared_ptr<Session> session)
143 const char* const buf = str_buf_bool(carla_engine_close());
144 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
147 void handle_carla_is_engine_running(const std::shared_ptr<Session> session)
149 const char* const buf = str_buf_bool(carla_is_engine_running());
150 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
153 void handle_carla_set_engine_about_to_close(const std::shared_ptr<Session> session)
155 const char* const buf = str_buf_bool(carla_set_engine_about_to_close());
156 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
159 // -------------------------------------------------------------------------------------------------------------------
161 void handle_carla_set_engine_option(const std::shared_ptr<Session> session)
163 const std::shared_ptr<const Request> request = session->get_request();
165 const int option = std::atol(request->get_query_parameter("option").c_str());
166 CARLA_SAFE_ASSERT_RETURN(option >= ENGINE_OPTION_DEBUG && option < ENGINE_OPTION_DEBUG_CONSOLE_OUTPUT,)
168 const int value = std::atol(request->get_query_parameter("value").c_str());
169 CARLA_SAFE_ASSERT_RETURN(value >= 0,)
171 const std::string valueStr = request->get_query_parameter("valueStr");
173 carla_set_engine_option(static_cast<EngineOption>(option), value, valueStr.c_str());
174 session->close(OK);
177 // -------------------------------------------------------------------------------------------------------------------
179 void handle_carla_load_file(const std::shared_ptr<Session> session)
181 const std::shared_ptr<const Request> request = session->get_request();
183 const std::string filename = request->get_query_parameter("filename");
185 const char* const buf = str_buf_bool(carla_load_file(filename.c_str()));
186 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
189 void handle_carla_load_project(const std::shared_ptr<Session> session)
191 const std::shared_ptr<const Request> request = session->get_request();
193 const std::string filename = request->get_query_parameter("filename");
195 const char* const buf = str_buf_bool(carla_load_project(filename.c_str()));
196 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
199 void handle_carla_save_project(const std::shared_ptr<Session> session)
201 const std::shared_ptr<const Request> request = session->get_request();
203 const std::string filename = request->get_query_parameter("filename");
205 const char* const buf = str_buf_bool(carla_save_project(filename.c_str()));
206 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
209 // -------------------------------------------------------------------------------------------------------------------
211 void handle_carla_patchbay_connect(const std::shared_ptr<Session> session)
213 const std::shared_ptr<const Request> request = session->get_request();
215 const int groupIdA = std::atoi(request->get_query_parameter("groupIdA").c_str());
216 CARLA_SAFE_ASSERT_RETURN(groupIdA >= 0,)
218 const int portIdA = std::atoi(request->get_query_parameter("portIdA").c_str());
219 CARLA_SAFE_ASSERT_RETURN(portIdA >= 0,)
221 const int groupIdB = std::atoi(request->get_query_parameter("groupIdB").c_str());
222 CARLA_SAFE_ASSERT_RETURN(groupIdB >= 0,)
224 const int portIdB = std::atoi(request->get_query_parameter("portIdB").c_str());
225 CARLA_SAFE_ASSERT_RETURN(portIdB >= 0,)
227 const char* const buf = str_buf_bool(carla_patchbay_connect(groupIdA, portIdA, groupIdB, portIdB));
228 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
231 void handle_carla_patchbay_disconnect(const std::shared_ptr<Session> session)
233 const std::shared_ptr<const Request> request = session->get_request();
235 const int connectionId = std::atoi(request->get_query_parameter("connectionId").c_str());
236 CARLA_SAFE_ASSERT_RETURN(connectionId >= 0,)
238 const char* const buf = str_buf_bool(carla_patchbay_disconnect(connectionId));
239 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
242 void handle_carla_patchbay_refresh(const std::shared_ptr<Session> session)
244 const std::shared_ptr<const Request> request = session->get_request();
246 const int external = std::atoi(request->get_query_parameter("external").c_str());
247 CARLA_SAFE_ASSERT_RETURN(external == 0 || external == 1,)
249 const char* const buf = str_buf_bool(carla_patchbay_refresh(external));
250 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
253 // -------------------------------------------------------------------------------------------------------------------
255 void handle_carla_transport_play(const std::shared_ptr<Session> session)
257 carla_transport_play();
258 session->close(OK);
261 void handle_carla_transport_pause(const std::shared_ptr<Session> session)
263 carla_transport_pause();
264 session->close(OK);
267 void handle_carla_transport_bpm(const std::shared_ptr<Session> session)
269 const std::shared_ptr<const Request> request = session->get_request();
271 const double bpm = std::atof(request->get_query_parameter("bpm").c_str());
272 CARLA_SAFE_ASSERT_RETURN(bpm > 0.0, session->close(OK)) // FIXME
274 carla_transport_bpm(bpm);
275 session->close(OK);
278 void handle_carla_transport_relocate(const std::shared_ptr<Session> session)
280 const std::shared_ptr<const Request> request = session->get_request();
282 const long int frame = std::atol(request->get_query_parameter("frame").c_str());
283 CARLA_SAFE_ASSERT_RETURN(frame >= 0,)
285 carla_transport_relocate(frame);
286 session->close(OK);
289 void handle_carla_get_current_transport_frame(const std::shared_ptr<Session> session)
291 const char* const buf = str_buf_uint64(carla_get_current_transport_frame());
292 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
295 void handle_carla_get_transport_info(const std::shared_ptr<Session> session)
297 const CarlaTransportInfo* const info = carla_get_transport_info();
299 char* jsonBuf;
300 jsonBuf = json_buf_start();
301 jsonBuf = json_buf_add_bool(jsonBuf, "playing", info->playing);
302 jsonBuf = json_buf_add_uint64(jsonBuf, "frame", info->frame);
303 jsonBuf = json_buf_add_int(jsonBuf, "bar", info->bar);
304 jsonBuf = json_buf_add_int(jsonBuf, "beat", info->beat);
305 jsonBuf = json_buf_add_int(jsonBuf, "tick", info->tick);
306 jsonBuf = json_buf_add_float(jsonBuf, "bpm", info->bpm);
308 const char* const buf = json_buf_end(jsonBuf);
309 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
312 // -------------------------------------------------------------------------------------------------------------------
314 void handle_carla_get_current_plugin_count(const std::shared_ptr<Session> session)
316 const char* const buf = str_buf_uint(carla_get_current_plugin_count());
317 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
320 void handle_carla_get_max_plugin_number(const std::shared_ptr<Session> session)
322 const char* const buf = str_buf_uint(carla_get_max_plugin_number());
323 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
326 void handle_carla_add_plugin(const std::shared_ptr<Session> session)
328 const std::shared_ptr<const Request> request = session->get_request();
330 const long int btype = std::atoi(request->get_query_parameter("btype").c_str());
331 CARLA_SAFE_ASSERT_RETURN(btype >= BINARY_NONE && btype <= BINARY_OTHER,)
333 const long int ptype = std::atoi(request->get_query_parameter("ptype").c_str());
334 CARLA_SAFE_ASSERT_RETURN(ptype >= PLUGIN_NONE && ptype <= PLUGIN_JACK,)
336 const std::string filename = request->get_query_parameter("filename");
337 const std::string name = request->get_query_parameter("name");
338 const std::string label = request->get_query_parameter("label");
340 const long int uniqueId = std::atol(request->get_query_parameter("uniqueId").c_str());
341 CARLA_SAFE_ASSERT_RETURN(uniqueId >= 0,)
343 const int options = std::atoi(request->get_query_parameter("options").c_str());
344 CARLA_SAFE_ASSERT_RETURN(options >= 0,)
346 const char* const buf = str_buf_bool(carla_add_plugin(static_cast<BinaryType>(btype),
347 static_cast<PluginType>(ptype),
348 filename.c_str(),
349 name.c_str(),
350 label.c_str(),
351 uniqueId,
352 nullptr,
353 options));
354 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
357 void handle_carla_remove_plugin(const std::shared_ptr<Session> session)
359 const std::shared_ptr<const Request> request = session->get_request();
361 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
362 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
364 const char* const buf = str_buf_bool(carla_remove_plugin(pluginId));
365 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
368 void handle_carla_remove_all_plugins(const std::shared_ptr<Session> session)
370 const char* const buf = str_buf_bool(carla_remove_all_plugins());
371 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
374 // -------------------------------------------------------------------------------------------------------------------
376 void handle_carla_rename_plugin(const std::shared_ptr<Session> session)
378 const std::shared_ptr<const Request> request = session->get_request();
380 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
381 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
383 const std::string newName = request->get_query_parameter("newName");
385 const char* const buf = carla_rename_plugin(pluginId, newName.c_str());
386 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
389 void handle_carla_clone_plugin(const std::shared_ptr<Session> session)
391 const std::shared_ptr<const Request> request = session->get_request();
393 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
394 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
396 const char* const buf = str_buf_bool(carla_clone_plugin(pluginId));
397 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
400 void handle_carla_replace_plugin(const std::shared_ptr<Session> session)
402 const std::shared_ptr<const Request> request = session->get_request();
404 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
405 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
407 const char* const buf = str_buf_bool(carla_replace_plugin(pluginId));
408 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
411 void handle_carla_switch_plugins(const std::shared_ptr<Session> session)
413 const std::shared_ptr<const Request> request = session->get_request();
415 const int pluginIdA = std::atol(request->get_query_parameter("pluginIdA").c_str());
416 CARLA_SAFE_ASSERT_RETURN(pluginIdA >= 0,)
418 const int pluginIdB = std::atol(request->get_query_parameter("pluginIdB").c_str());
419 CARLA_SAFE_ASSERT_RETURN(pluginIdB >= 0,)
421 const char* const buf = str_buf_bool(carla_switch_plugins(pluginIdA, pluginIdB));
422 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
425 // -------------------------------------------------------------------------------------------------------------------
427 void handle_carla_load_plugin_state(const std::shared_ptr<Session> session)
429 const std::shared_ptr<const Request> request = session->get_request();
431 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
432 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
434 const std::string filename = request->get_query_parameter("filename");
436 const char* const buf = str_buf_bool(carla_load_plugin_state(pluginId, filename.c_str()));
437 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
440 void handle_carla_save_plugin_state(const std::shared_ptr<Session> session)
442 const std::shared_ptr<const Request> request = session->get_request();
444 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
445 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
447 const std::string filename = request->get_query_parameter("filename");
449 const char* const buf = str_buf_bool(carla_save_plugin_state(pluginId, filename.c_str()));
450 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
453 void handle_carla_export_plugin_lv2(const std::shared_ptr<Session> session)
455 const std::shared_ptr<const Request> request = session->get_request();
457 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
458 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
460 const std::string lv2path = request->get_query_parameter("lv2path");
462 const char* const buf = str_buf_bool(carla_export_plugin_lv2(pluginId, lv2path.c_str()));
463 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
466 // -------------------------------------------------------------------------------------------------------------------
468 void handle_carla_get_plugin_info(const std::shared_ptr<Session> session)
470 const std::shared_ptr<const Request> request = session->get_request();
472 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
473 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
475 const CarlaPluginInfo* const info = carla_get_plugin_info(pluginId);
477 // running remotely, so we cannot show custom UI or inline display
478 const uint hints = info->hints & ~(PLUGIN_HAS_CUSTOM_UI|PLUGIN_HAS_INLINE_DISPLAY);
480 char* jsonBuf;
481 jsonBuf = json_buf_start();
482 jsonBuf = json_buf_add_uint(jsonBuf, "type", info->type);
483 jsonBuf = json_buf_add_uint(jsonBuf, "category", info->category);
484 jsonBuf = json_buf_add_uint(jsonBuf, "hints", hints);
485 jsonBuf = json_buf_add_uint(jsonBuf, "optionsAvailable", info->optionsAvailable);
486 jsonBuf = json_buf_add_uint(jsonBuf, "optionsEnabled", info->optionsEnabled);
487 jsonBuf = json_buf_add_string(jsonBuf, "filename", info->filename);
488 jsonBuf = json_buf_add_string(jsonBuf, "name", info->name);
489 jsonBuf = json_buf_add_string(jsonBuf, "label", info->label);
490 jsonBuf = json_buf_add_string(jsonBuf, "maker", info->maker);
491 jsonBuf = json_buf_add_string(jsonBuf, "copyright", info->copyright);
492 jsonBuf = json_buf_add_string(jsonBuf, "iconName", info->iconName);
493 jsonBuf = json_buf_add_int64(jsonBuf, "uniqueId", info->uniqueId);
495 const char* const buf = json_buf_end(jsonBuf);
496 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
499 void handle_carla_get_audio_port_count_info(const std::shared_ptr<Session> session)
501 const std::shared_ptr<const Request> request = session->get_request();
503 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
504 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
506 const CarlaPortCountInfo* const info = carla_get_audio_port_count_info(pluginId);
508 char* jsonBuf;
509 jsonBuf = json_buf_start();
510 jsonBuf = json_buf_add_uint(jsonBuf, "ins", info->ins);
511 jsonBuf = json_buf_add_uint(jsonBuf, "outs", info->outs);
513 const char* const buf = json_buf_end(jsonBuf);
514 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
517 void handle_carla_get_midi_port_count_info(const std::shared_ptr<Session> session)
519 const std::shared_ptr<const Request> request = session->get_request();
521 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
522 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
524 const CarlaPortCountInfo* const info = carla_get_midi_port_count_info(pluginId);
526 char* jsonBuf;
527 jsonBuf = json_buf_start();
528 jsonBuf = json_buf_add_uint(jsonBuf, "ins", info->ins);
529 jsonBuf = json_buf_add_uint(jsonBuf, "outs", info->outs);
531 const char* const buf = json_buf_end(jsonBuf);
532 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
535 void handle_carla_get_parameter_count_info(const std::shared_ptr<Session> session)
537 const std::shared_ptr<const Request> request = session->get_request();
539 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
540 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
542 const CarlaPortCountInfo* const info = carla_get_parameter_count_info(pluginId);
544 char* jsonBuf;
545 jsonBuf = json_buf_start();
546 jsonBuf = json_buf_add_uint(jsonBuf, "ins", info->ins);
547 jsonBuf = json_buf_add_uint(jsonBuf, "outs", info->outs);
549 const char* const buf = json_buf_end(jsonBuf);
550 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
553 void handle_carla_get_parameter_info(const std::shared_ptr<Session> session)
555 const std::shared_ptr<const Request> request = session->get_request();
557 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
558 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
560 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
561 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
563 const CarlaParameterInfo* const info = carla_get_parameter_info(pluginId, parameterId);
565 char* jsonBuf;
566 jsonBuf = json_buf_start();
567 jsonBuf = json_buf_add_string(jsonBuf, "name", info->name);
568 jsonBuf = json_buf_add_string(jsonBuf, "symbol", info->symbol);
569 jsonBuf = json_buf_add_string(jsonBuf, "unit", info->unit);
570 jsonBuf = json_buf_add_uint(jsonBuf, "scalePointCount", info->scalePointCount);
572 const char* const buf = json_buf_end(jsonBuf);
573 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
576 void handle_carla_get_parameter_scalepoint_info(const std::shared_ptr<Session> session)
578 const std::shared_ptr<const Request> request = session->get_request();
580 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
581 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
583 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
584 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
586 const int scalePointId = std::atoi(request->get_query_parameter("scalePointId").c_str());
587 CARLA_SAFE_ASSERT_RETURN(scalePointId >= 0,)
589 const CarlaScalePointInfo* const info = carla_get_parameter_scalepoint_info(pluginId, parameterId, scalePointId);
591 char* jsonBuf;
592 jsonBuf = json_buf_start();
593 jsonBuf = json_buf_add_float(jsonBuf, "value", info->value);
594 jsonBuf = json_buf_add_string(jsonBuf, "label", info->label);
596 const char* const buf = json_buf_end(jsonBuf);
597 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
600 void handle_carla_get_parameter_data(const std::shared_ptr<Session> session)
602 const std::shared_ptr<const Request> request = session->get_request();
604 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
605 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
607 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
608 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
610 const ParameterData* const info = carla_get_parameter_data(pluginId, parameterId);
612 char* jsonBuf;
613 jsonBuf = json_buf_start();
614 jsonBuf = json_buf_add_uint(jsonBuf, "type", info->type);
615 jsonBuf = json_buf_add_uint(jsonBuf, "hints", info->hints);
616 jsonBuf = json_buf_add_int(jsonBuf, "index", info->index);
617 jsonBuf = json_buf_add_int(jsonBuf, "rindex", info->rindex);
618 jsonBuf = json_buf_add_int(jsonBuf, "midiCC", info->midiCC);
619 jsonBuf = json_buf_add_uint(jsonBuf, "midiChannel", info->midiChannel);
621 const char* const buf = json_buf_end(jsonBuf);
622 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
625 void handle_carla_get_parameter_ranges(const std::shared_ptr<Session> session)
627 const std::shared_ptr<const Request> request = session->get_request();
629 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
630 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
632 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
633 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
635 const ParameterRanges* const info = carla_get_parameter_ranges(pluginId, parameterId);
637 char* jsonBuf;
638 jsonBuf = json_buf_start();
639 jsonBuf = json_buf_add_float(jsonBuf, "def", info->def);
640 jsonBuf = json_buf_add_float(jsonBuf, "min", info->min);
641 jsonBuf = json_buf_add_float(jsonBuf, "max", info->max);
642 jsonBuf = json_buf_add_float(jsonBuf, "step", info->step);
643 jsonBuf = json_buf_add_float(jsonBuf, "stepSmall", info->stepSmall);
644 jsonBuf = json_buf_add_float(jsonBuf, "stepLarge", info->stepLarge);
646 const char* const buf = json_buf_end(jsonBuf);
647 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
650 void handle_carla_get_midi_program_data(const std::shared_ptr<Session> session)
652 const std::shared_ptr<const Request> request = session->get_request();
654 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
655 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
657 const int midiProgramId = std::atoi(request->get_query_parameter("midiProgramId").c_str());
658 CARLA_SAFE_ASSERT_RETURN(midiProgramId >= 0,)
660 const MidiProgramData* const info = carla_get_midi_program_data(pluginId, midiProgramId);
662 char* jsonBuf;
663 jsonBuf = json_buf_start();
664 jsonBuf = json_buf_add_uint(jsonBuf, "bank", info->bank);
665 jsonBuf = json_buf_add_uint(jsonBuf, "program", info->program);
666 jsonBuf = json_buf_add_string(jsonBuf, "name", info->name);
668 const char* const buf = json_buf_end(jsonBuf);
669 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
672 void handle_carla_get_custom_data(const std::shared_ptr<Session> session)
674 const std::shared_ptr<const Request> request = session->get_request();
676 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
677 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
679 const int customDataId = std::atoi(request->get_query_parameter("customDataId").c_str());
680 CARLA_SAFE_ASSERT_RETURN(customDataId >= 0,)
682 const CustomData* const info = carla_get_custom_data(pluginId, customDataId);
684 char* jsonBuf;
685 jsonBuf = json_buf_start();
686 jsonBuf = json_buf_add_string(jsonBuf, "type", info->type);
687 jsonBuf = json_buf_add_string(jsonBuf, "key", info->key);
688 jsonBuf = json_buf_add_string(jsonBuf, "value", info->value);
690 const char* const buf = json_buf_end(jsonBuf);
691 puts(buf);
692 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
695 void handle_carla_get_custom_data_value(const std::shared_ptr<Session> session)
697 const std::shared_ptr<const Request> request = session->get_request();
699 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
700 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
702 const std::string type = request->get_query_parameter("type");
703 const std::string key = request->get_query_parameter("key");
705 const char* const buf = carla_get_custom_data_value(pluginId, type.c_str(), key.c_str());
706 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
709 void handle_carla_get_chunk_data(const std::shared_ptr<Session> session)
711 const std::shared_ptr<const Request> request = session->get_request();
713 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
714 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
716 const char* const buf = carla_get_chunk_data(pluginId);
717 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
720 // -------------------------------------------------------------------------------------------------------------------
722 void handle_carla_get_parameter_count(const std::shared_ptr<Session> session)
724 const std::shared_ptr<const Request> request = session->get_request();
726 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
727 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
729 const char* const buf = str_buf_uint(carla_get_parameter_count(pluginId));
730 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
733 void handle_carla_get_program_count(const std::shared_ptr<Session> session)
735 const std::shared_ptr<const Request> request = session->get_request();
737 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
738 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
740 const char* const buf = str_buf_uint(carla_get_program_count(pluginId));
741 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
744 void handle_carla_get_midi_program_count(const std::shared_ptr<Session> session)
746 const std::shared_ptr<const Request> request = session->get_request();
748 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
749 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
751 const char* const buf = str_buf_uint(carla_get_midi_program_count(pluginId));
752 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
755 void handle_carla_get_custom_data_count(const std::shared_ptr<Session> session)
757 const std::shared_ptr<const Request> request = session->get_request();
759 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
760 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
762 const char* const buf = str_buf_uint(carla_get_custom_data_count(pluginId));
763 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
766 void handle_carla_get_parameter_text(const std::shared_ptr<Session> session)
768 const std::shared_ptr<const Request> request = session->get_request();
770 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
771 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
773 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
774 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
776 const char* const buf = carla_get_parameter_text(pluginId, parameterId);
777 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
780 void handle_carla_get_program_name(const std::shared_ptr<Session> session)
782 const std::shared_ptr<const Request> request = session->get_request();
784 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
785 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
787 const int programId = std::atoi(request->get_query_parameter("programId").c_str());
788 CARLA_SAFE_ASSERT_RETURN(programId >= 0,)
790 const char* const buf = carla_get_program_name(pluginId, programId);
791 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
794 void handle_carla_get_midi_program_name(const std::shared_ptr<Session> session)
796 const std::shared_ptr<const Request> request = session->get_request();
798 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
799 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
801 const int midiProgramId = std::atoi(request->get_query_parameter("midiProgramId").c_str());
802 CARLA_SAFE_ASSERT_RETURN(midiProgramId >= 0,)
804 const char* const buf = carla_get_midi_program_name(pluginId, midiProgramId);
805 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
808 void handle_carla_get_real_plugin_name(const std::shared_ptr<Session> session)
810 const std::shared_ptr<const Request> request = session->get_request();
812 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
813 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
815 const char* const buf = carla_get_real_plugin_name(pluginId);
816 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
819 void handle_carla_get_current_program_index(const std::shared_ptr<Session> session)
821 const std::shared_ptr<const Request> request = session->get_request();
823 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
824 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
826 const char* const buf = str_buf_uint(carla_get_current_program_index(pluginId));
827 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
830 void handle_carla_get_current_midi_program_index(const std::shared_ptr<Session> session)
832 const std::shared_ptr<const Request> request = session->get_request();
834 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
835 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
837 const char* const buf = str_buf_uint(carla_get_current_midi_program_index(pluginId));
838 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
841 void handle_carla_get_default_parameter_value(const std::shared_ptr<Session> session)
843 const std::shared_ptr<const Request> request = session->get_request();
845 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
846 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
848 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
849 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
851 const char* const buf = str_buf_float(carla_get_default_parameter_value(pluginId, parameterId));
852 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
855 void handle_carla_get_current_parameter_value(const std::shared_ptr<Session> session)
857 const std::shared_ptr<const Request> request = session->get_request();
859 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
860 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
862 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
863 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
865 const char* const buf = str_buf_float(carla_get_current_parameter_value(pluginId, parameterId));
866 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
869 void handle_carla_get_internal_parameter_value(const std::shared_ptr<Session> session)
871 const std::shared_ptr<const Request> request = session->get_request();
873 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
874 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
876 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
877 CARLA_SAFE_ASSERT_RETURN(parameterId > PARAMETER_MAX,);
879 const char* const buf = str_buf_float(carla_get_internal_parameter_value(pluginId, parameterId));
880 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
883 void handle_carla_get_input_peak_value(const std::shared_ptr<Session> session)
885 const std::shared_ptr<const Request> request = session->get_request();
887 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
888 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
890 const int isLeft = std::atoi(request->get_query_parameter("isLeft").c_str());
891 CARLA_SAFE_ASSERT_RETURN(isLeft == 0 || isLeft == 1,)
893 const char* const buf = str_buf_float(carla_get_input_peak_value(pluginId, isLeft));
894 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
897 void handle_carla_get_output_peak_value(const std::shared_ptr<Session> session)
899 const std::shared_ptr<const Request> request = session->get_request();
901 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
902 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
904 const int isLeft = std::atoi(request->get_query_parameter("isLeft").c_str());
905 CARLA_SAFE_ASSERT_RETURN(isLeft == 0 || isLeft == 1,)
907 const char* const buf = str_buf_float(carla_get_output_peak_value(pluginId, isLeft));
908 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
911 // -------------------------------------------------------------------------------------------------------------------
913 void handle_carla_set_active(const std::shared_ptr<Session> session)
915 const std::shared_ptr<const Request> request = session->get_request();
917 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
918 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
920 const int onOff = std::atoi(request->get_query_parameter("onOff").c_str());
921 CARLA_SAFE_ASSERT_RETURN(onOff == 0 || onOff == 1,)
923 carla_set_active(pluginId, onOff);
924 session->close(OK);
927 void handle_carla_set_drywet(const std::shared_ptr<Session> session)
929 const std::shared_ptr<const Request> request = session->get_request();
931 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
932 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
934 const double value = std::atof(request->get_query_parameter("value").c_str());
935 CARLA_SAFE_ASSERT_RETURN(value >= 0.0 && value <= 1.0,)
937 carla_set_drywet(pluginId, value);
938 session->close(OK);
941 void handle_carla_set_volume(const std::shared_ptr<Session> session)
943 const std::shared_ptr<const Request> request = session->get_request();
945 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
946 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
948 const double value = std::atof(request->get_query_parameter("value").c_str());
949 CARLA_SAFE_ASSERT_RETURN(value >= 0.0 && value <= 1.27,)
951 carla_set_volume(pluginId, value);
952 session->close(OK);
955 void handle_carla_set_balance_left(const std::shared_ptr<Session> session)
957 const std::shared_ptr<const Request> request = session->get_request();
959 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
960 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
962 const double value = std::atof(request->get_query_parameter("value").c_str());
963 CARLA_SAFE_ASSERT_RETURN(value >= -1.0 && value <= 1.0,)
965 carla_set_balance_left(pluginId, value);
966 session->close(OK);
969 void handle_carla_set_balance_right(const std::shared_ptr<Session> session)
971 const std::shared_ptr<const Request> request = session->get_request();
973 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
974 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
976 const double value = std::atof(request->get_query_parameter("value").c_str());
977 CARLA_SAFE_ASSERT_RETURN(value >= -1.0 && value <= 1.0,)
979 carla_set_balance_right(pluginId, value);
980 session->close(OK);
983 void handle_carla_set_panning(const std::shared_ptr<Session> session)
985 const std::shared_ptr<const Request> request = session->get_request();
987 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
988 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
990 const double value = std::atof(request->get_query_parameter("value").c_str());
991 CARLA_SAFE_ASSERT_RETURN(value >= -1.0 && value <= 1.0,)
993 carla_set_panning(pluginId, value);
994 session->close(OK);
997 void handle_carla_set_ctrl_channel(const std::shared_ptr<Session> session)
999 const std::shared_ptr<const Request> request = session->get_request();
1001 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1002 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1004 const int channel = std::atoi(request->get_query_parameter("channel").c_str());
1005 CARLA_SAFE_ASSERT_RETURN(channel < 16,)
1007 carla_set_ctrl_channel(pluginId, channel);
1008 session->close(OK);
1011 void handle_carla_set_option(const std::shared_ptr<Session> session)
1013 const std::shared_ptr<const Request> request = session->get_request();
1015 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1016 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1018 const int option = std::atoi(request->get_query_parameter("option").c_str());
1019 CARLA_SAFE_ASSERT_RETURN(option >= 0,)
1021 const int yesNo = std::atoi(request->get_query_parameter("yesNo").c_str());
1022 CARLA_SAFE_ASSERT_RETURN(yesNo == 0 || yesNo == 1,)
1024 carla_set_option(pluginId, option, yesNo);
1025 session->close(OK);
1028 // -------------------------------------------------------------------------------------------------------------------
1030 void handle_carla_set_parameter_value(const std::shared_ptr<Session> session)
1032 const std::shared_ptr<const Request> request = session->get_request();
1034 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1035 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1037 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
1038 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
1040 const double value = std::atof(request->get_query_parameter("value").c_str());
1042 carla_set_parameter_value(pluginId, parameterId, value);
1043 session->close(OK);
1046 void handle_carla_set_parameter_midi_channel(const std::shared_ptr<Session> session)
1048 const std::shared_ptr<const Request> request = session->get_request();
1050 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1051 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1053 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
1054 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
1056 const int channel = std::atoi(request->get_query_parameter("channel").c_str());
1057 CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < 16,)
1059 carla_set_parameter_midi_channel(pluginId, parameterId, channel);
1060 session->close(OK);
1063 void handle_carla_set_parameter_midi_cc(const std::shared_ptr<Session> session)
1065 const std::shared_ptr<const Request> request = session->get_request();
1067 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1068 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1070 const int parameterId = std::atoi(request->get_query_parameter("parameterId").c_str());
1071 CARLA_SAFE_ASSERT_RETURN(parameterId >= 0,)
1073 const int cc = std::atoi(request->get_query_parameter("channel").c_str());
1074 CARLA_SAFE_ASSERT_RETURN(cc >= -1 && cc < INT16_MAX,);
1076 carla_set_parameter_midi_cc(pluginId, parameterId, cc);
1077 session->close(OK);
1080 void handle_carla_set_program(const std::shared_ptr<Session> session)
1082 const std::shared_ptr<const Request> request = session->get_request();
1084 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1085 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1087 const int programId = std::atoi(request->get_query_parameter("programId").c_str());
1088 CARLA_SAFE_ASSERT_RETURN(programId >= 0,)
1090 carla_set_program(pluginId, programId);
1091 session->close(OK);
1094 void handle_carla_set_midi_program(const std::shared_ptr<Session> session)
1096 const std::shared_ptr<const Request> request = session->get_request();
1098 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1099 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1101 const int midiProgramId = std::atoi(request->get_query_parameter("midiProgramId").c_str());
1102 CARLA_SAFE_ASSERT_RETURN(midiProgramId >= 0,)
1104 carla_set_midi_program(pluginId, midiProgramId);
1105 session->close(OK);
1108 void handle_carla_set_custom_data(const std::shared_ptr<Session> session)
1110 const std::shared_ptr<const Request> request = session->get_request();
1112 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1113 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1115 const std::string type = request->get_query_parameter("type");
1116 const std::string key = request->get_query_parameter("key");
1117 const std::string value = request->get_query_parameter("value");
1119 carla_set_custom_data(pluginId, type.c_str(), key.c_str(), value.c_str());
1120 session->close(OK);
1123 void handle_carla_set_chunk_data(const std::shared_ptr<Session> session)
1125 const std::shared_ptr<const Request> request = session->get_request();
1127 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1128 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1130 const std::string chunkData = request->get_query_parameter("chunkData");
1132 carla_set_chunk_data(pluginId, chunkData.c_str());
1133 session->close(OK);
1136 // -------------------------------------------------------------------------------------------------------------------
1138 void handle_carla_prepare_for_save(const std::shared_ptr<Session> session)
1140 const std::shared_ptr<const Request> request = session->get_request();
1142 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1143 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1145 carla_prepare_for_save(pluginId);
1146 session->close(OK);
1149 void handle_carla_reset_parameters(const std::shared_ptr<Session> session)
1151 const std::shared_ptr<const Request> request = session->get_request();
1153 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1154 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1156 carla_reset_parameters(pluginId);
1157 session->close(OK);
1160 void handle_carla_randomize_parameters(const std::shared_ptr<Session> session)
1162 const std::shared_ptr<const Request> request = session->get_request();
1164 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1165 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1167 carla_randomize_parameters(pluginId);
1168 session->close(OK);
1171 void handle_carla_send_midi_note(const std::shared_ptr<Session> session)
1173 const std::shared_ptr<const Request> request = session->get_request();
1175 const int pluginId = std::atoi(request->get_query_parameter("pluginId").c_str());
1176 CARLA_SAFE_ASSERT_RETURN(pluginId >= 0,)
1178 const int channel = std::atoi(request->get_query_parameter("channel").c_str());
1179 CARLA_SAFE_ASSERT_RETURN(channel >= 0 && channel < 16,)
1181 const int note = std::atoi(request->get_query_parameter("note").c_str());
1182 CARLA_SAFE_ASSERT_RETURN(note >= 0 && note < 128,)
1184 const int velocity = std::atoi(request->get_query_parameter("velocity").c_str());
1185 CARLA_SAFE_ASSERT_RETURN(velocity >= 0 && velocity < 128,)
1187 carla_send_midi_note(pluginId, channel, note, velocity);
1188 session->close(OK);
1191 // -------------------------------------------------------------------------------------------------------------------
1193 void handle_carla_get_buffer_size(const std::shared_ptr<Session> session)
1195 const char* const buf = str_buf_uint(carla_get_buffer_size());
1196 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
1199 void handle_carla_get_sample_rate(const std::shared_ptr<Session> session)
1201 const char* const buf = str_buf_float(carla_get_sample_rate());
1202 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
1205 void handle_carla_get_last_error(const std::shared_ptr<Session> session)
1207 const char* const buf = carla_get_last_error();
1208 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
1211 void handle_carla_get_host_osc_url_tcp(const std::shared_ptr<Session> session)
1213 const char* const buf = carla_get_host_osc_url_tcp();
1214 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
1217 void handle_carla_get_host_osc_url_udp(const std::shared_ptr<Session> session)
1219 const char* const buf = carla_get_host_osc_url_udp();
1220 session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
1223 // -------------------------------------------------------------------------------------------------------------------