Home › Forums › BreakawayOne › HTTP move a BA1 slider
- This topic has 15 replies, 3 voices, and was last updated 3 years, 1 month ago by Milky.
-
AuthorPosts
-
September 21, 2021 at 10:35 am #16618locodParticipant
Hi there, I’m a little out of my depth so please bear with me.
I’ve been asked by a BA1 user to send midi from within a dj software into BreakawayOne via http localhost.
I’ve started a plugin for the dj SW and it appears to connect, and am trying further small steps, [if (connected) move a BA1 slider ]I’m just a little lost how move the sliders, it may be obvious, it maybe just string formatting. but I’m a little out of my depth.
here’s a snippet of what I have, thanks in advance for any replies.WSAData wsaData; WORD DllVersion = MAKEWORD(2, 1); if (WSAStartup(DllVersion, &wsaData) != 0) { return S_OK; // Dj software } string getInput = ""; SOCKADDR_IN addr; int addrLen = sizeof(addr); IN_ADDR ipvalue; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_port = htons(8200); addr.sin_family = AF_INET; SOCKET connection = socket(AF_INET, SOCK_STREAM, NULL); if (connect(connection, (SOCKADDR*)&addr, addrLen) == 0) { SendCommand("deck 1 play"); // Dj software connection confirmation // HERE IS WHERE I'M STUCK getInput = "http://127.0.0.1:8282/parameter/hd1/spk/volume?set=0"; send(connection, getInput.c_str(), strlen(getInput.c_str()), 0); } else { return S_OK; // Dj software } return S_OK;
September 21, 2021 at 11:21 am #16619locodParticipantsmall typo in my code snippet
addr.sin_port = htons(8200);
should be 8282
still lostSeptember 21, 2021 at 2:48 pm #16620locodParticipantAs best as I can figure this is the GET request I should send(),
but I don’t know, maybe there’s something here I fundamentally don’t understand.
I can’t even figure if I should be using BARemote or not, slightly frustrated now, but that’s par for the course with c++ [at least for me]string getInput = "GET /parameter/hd1/spk/volume?=0 HTTP/1.1\r\nHOST: http://127.0.0.1:8282\r\n\r\n"; send(connection, getInput.c_str(), strlen(getInput.c_str()), 0);
- This reply was modified 3 years, 2 months ago by locod.
September 21, 2021 at 2:52 pm #16621September 21, 2021 at 3:17 pm #16623locodParticipant@Milky I haven’t, I thought it could be done without 3rd party libs.
embarrassingly I had to look up how to even install a lib, I suppose the day hasn’t been a total waste then.Thanks, I might be back.
September 21, 2021 at 3:50 pm #16624locodParticipantWait is cURL command line? is that going to work with a midi slider?
September 21, 2021 at 5:28 pm #16625locodParticipantI’m even further lost, your examples are command line, I can’t find any simple examples using libcurl, [anywhere]
Seemed too easy getting a client connection in the first 20 minutes, and now I’ve been 20 tabs deep for 8 hours, and I’m still no wiser.
Can’t winsock do it? Or could I get a short libcurl example please. [connect & request]September 21, 2021 at 10:50 pm #16627MilkyKeymasterYes, it is a command line. cURL.exe is bundled with Win10, and downloadable for earlier OSs.
Is there any way that you can shell out to DOS?You could send it to a browser, or possibly directly to the inbuilt web server.
- This reply was modified 3 years, 2 months ago by Milky.
September 22, 2021 at 6:38 am #16629locodParticipantIsn’t cmd or a browser going to make a window appear every time I touch the slider? to drop the slider to zero is a incremental step, the goal is control from a midi device slider.
September 22, 2021 at 11:39 am #16630locodParticipantfinally found a distro for libcurl that avoids all the config,
I have this simple console app, it connects, it returns OK, it doesn’t move the vol slider though#include <stdio.h> #include <curl/curl.h> int main(void) { CURL* curl; CURLcode res; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); /* get a curl handle */ curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "127.0.0.1:8282"); curl_easy_setopt(curl, CURLOPT_HTTPGET, "/parameter/hd1/spk/volume?=0"); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); /* Check for errors */ if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); } curl_global_cleanup(); return 0; }
September 22, 2021 at 2:52 pm #16631MilkyKeymasterAs I read that code, you are GETTING the current value of the volume, but you are not PUTTING a new value to change it.
September 22, 2021 at 3:57 pm #16632locodParticipantI tried that also, my original intel was a AHK script and that used GET
However, I found the solution […a solution] I started trying things that shouldn’t work, and then it worked, no tailoring, real formatting, GET or PUT, just send it all, full path
curl_easy_setopt(curl, CURLOPT_URL, "127.0.0.1:8282/parameter/hd1/spk/volume=0"); // NOT NEEDED APPARENTLY curl_easy_setopt(curl, CURLOPT_HTTPGET, "/parameter/hd1/spk/volume?=0"); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl);
After discovering that, 20 minutes later I’ve have a device talking to a virtualdj plugin, the plugin talks to BA1
September 22, 2021 at 8:26 pm #16633MilkyKeymasterExcellent! I use AHK quite a bit, including to set/unset various things in BA1, but actually Run or RunWait to the curl line similar to the previous examples. That gives me a return code, plus I can specify “Hide” in the options, so you don’t see a box flash up at all. The response isn’t instantaneous, but pretty close to it.
For instance, this line will send a toggle command to turn bypass processing on or off
RunWait, curl --silent --output nul http://otsbox:8282/parameter/hd1/proc/bypass_proxy+=1,,hide
October 4, 2021 at 7:42 pm #16638locodParticipantSmall update, not that anybody cares.
I got it working with winsock, I was sending the wrong way, wrong formatint intSlider2 = slider2 * 100; std::stringstream cmd1; cmd1 << "PUT /parameter/hd1/spk/volume=" << intSlider2 << " HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"; std::string getInput = cmd1.str().c_str(); connection = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (connect(connection, (SOCKADDR*)&addr, addrLen) == 0) { send(connection, getInput.c_str(), strlen(getInput.c_str()), 0); closesocket(connection); }
midi device talks to virtualdj, vdj talks to plugin, plugin talks to BA1, added bonus I have real time metadata update, I notice a few streams the meta is updated too early or late. If anybody is a vdj && BA1 user you can contact me here.
- This reply was modified 3 years, 1 month ago by locod.
October 5, 2021 at 3:24 pm #16640MrKloroxParticipantThank you for documenting your research and experimentation! I’m certain this will come in handy for somebody.
-
AuthorPosts
- You must be logged in to reply to this topic.