COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 09-25-2016, 09:13 PM   #1
hermes_2507
Human being with feelings
 
Join Date: Jun 2016
Posts: 3
Default OSC communication in WDL-OL

Hi,

Is it possible to use OSC communication within a plugin to send the value of faders and knobs and conversely receiving values from the outside for altering the parameters?

How?

Thanks!
hermes_2507 is offline   Reply With Quote
Old 09-26-2016, 01:50 AM   #2
leighhunt
Human being with feelings
 
Join Date: Jun 2016
Location: London, UK
Posts: 51
Default

Hi there,

Oscpkt works great for me, very simple... so far.
http://gruntthepeon.free.fr/oscpkt/

Have fun!
leighhunt is offline   Reply With Quote
Old 09-26-2016, 03:06 PM   #3
Mimo
Human being with feelings
 
Join Date: Apr 2015
Posts: 68
Default

Please, you can share an example in WDL?
Mimo is offline   Reply With Quote
Old 09-26-2016, 03:17 PM   #4
leighhunt
Human being with feelings
 
Join Date: Jun 2016
Location: London, UK
Posts: 51
Default

fyi - I am parsing for osc input in ProcessDoubleReplacing.
This might be of note in the case that you are passing audio through your plugin, as there is no separate thread created or any regard on my behalf for audio being interrupted.
The purpose for which I am using it is in a non audio passing vst, and I am by no means 'taxing' osc input, it only comes from physical interaction with midi controllers or iPad.
I do have a routine in ProcessDoubleReplacing that reduces the parse rate, but once again, this is of a 'self-hobbyist-semiskilled programmer' nature, and once again might not work so well in situations other than my plugin.
Having said all that, the project I am working on with this implemented is suffering no hiccups as a result of my efforts!

Given the above considerations let me know if you still would like an example and I'll try to post one before the weekend.

Edit - I can also only offer advice on the mac platform, I haven't plunged into cross platform as of yet.
I'm building in latest Xcode and using ox10.5sdk and I'm not sure which release of wdl-ol.

Last edited by leighhunt; 09-26-2016 at 03:44 PM.
leighhunt is offline   Reply With Quote
Old 09-28-2016, 05:29 AM   #5
leighhunt
Human being with feelings
 
Join Date: Jun 2016
Location: London, UK
Posts: 51
Default

Firstly, credit where credit is due for Julien Pommier making the oscpkt package.
Ok, here's how I have it working for me.....
Add to your project and include oscpkt.hh and udp.hh in your plugin header file, from the oscpkt package - http://gruntthepeon.free.fr/oscpkt/.

In my main plugin.h file i added:

Code:
 oscpkt::UdpSocket       SendSocket;
 oscpkt::UdpSocket       ReceiveSocket;
 oscpkt::PacketReader    pktreceive;
 oscpkt::PacketWriter    pktsend;
 oscpkt::Message         *OscReceiveMessage;
 oscpkt::Message         OscSendMessage;
Next, in my main plugin.cpp constructor I placed -
Code:
  if (!SendSocket.connectTo("localhost", 10001) {
    SendSocket.close();
    OscSendConnectedFlag = false; // flag I have to tell me if connection is made
  }
  else {
    OscSendConnectedFlag = true;
  }
  if (!ReceiveSocket.bindTo(10000)) {
    ReceiveSocket.close();
    OscReceiveConnectedFlag = false; // flag I have to tell me if connection is made
  }
  else {
    OscReceiveConnectedFlag = true;
  }
  OscConnectionFlag = false;
Next, in ProcessDoubleReplacing, a call to ParseOscInput() - defined in main plugin header file
Code:
SampleCounter = ParsingRefreshRate; // a rate for parsing set somewhere else. Easy to invent your own based on samples.
 for (int s = 0; s < nFrames; ++s, ++in1, ++in2)
  {
    if (SampleCounter == ParsingRefreshRate && (GetGUI())) {
      ParseOscInput();
      }
      SampleCounter = 0;
    }
    SampleCounter++;
  }
And the parsing function (excerpt from my code where I am shaking hands with the remote connection software, generally an iPad or maxmsp.
Code:
void MyPlugin::ParseOscInput()
{
  if (ReceiveSocket.receiveNextPacket(0)) {
    pktreceive.init(ReceiveSocket.packetData(), ReceiveSocket.packetSize());
    while (pktreceive.isOk() && (OscReceiveMessage = pktreceive.popMessage()) != 0) {
// match incoming message, in this case with no args. See oscpkt files for receiving int/float/string
      if (OscReceiveMessage->match("/RemoteOscHandshakeConfirmed").isOkNoMoreArgs()) {
// Sample output message
        pktsend.init();
        pktsend.startBundle();
        pktsend.addMessage(OscSendMessage.init("/RemoteOscConnectedFlag").pushBool(true));
        pktsend.endBundle();
        SendSocket.sendPacket(pktsend.packetData(), pktsend.packetSize());
    }
  }
}
Please be warned though, and I remind you, this works for my purposes, there's no thought about potential threading issues, I have only compiled for Mac, using Xcode latest and osx10.5 sdk, and a version of wdl-ol.

I hope this makes sense and I haven't missed something. tbh these code snippets are cut and pasted from rather a more complicated setup,where I have text boxes to set host name and ports.

Anyone with any thoughts, or remarks feel free to chime in ('ding dong, you done it all wrong') !

Have fun,
Leigh

Last edited by leighhunt; 09-28-2016 at 07:00 AM.
leighhunt is offline   Reply With Quote
Old 09-28-2016, 11:19 AM   #6
Mimo
Human being with feelings
 
Join Date: Apr 2015
Posts: 68
Default

Excellent, now I will study it.
wdl need users like you.
Hopefully I can help you in the future.
Mimo is offline   Reply With Quote
Old 09-28-2016, 12:41 PM   #7
leighhunt
Human being with feelings
 
Join Date: Jun 2016
Location: London, UK
Posts: 51
Default

Quote:
Originally Posted by Mimo View Post
Excellent, now I will study it.
wdl need users like you.
Hopefully I can help you in the future.
Thanks mate - relative newbie here. Hopefully it will make sense for you, it took me 3 evenings of trial and error and learning to get it up and running!
To be fair I have read a lot of posts here over the last couple of months in order to figure out many novice questions. Sharing a little knowledge and insight is rather fine for the soul...
leighhunt is offline   Reply With Quote
Old 09-28-2016, 02:15 PM   #8
hermes_2507
Human being with feelings
 
Join Date: Jun 2016
Posts: 3
Default

Quote:
Originally Posted by leighhunt View Post
fyi - I am parsing for osc input in ProcessDoubleReplacing.
This might be of note in the case that you are passing audio through your plugin, as there is no separate thread created or any regard on my behalf for audio being interrupted.
The purpose for which I am using it is in a non audio passing vst, and I am by no means 'taxing' osc input, it only comes from physical interaction with midi controllers or iPad.
I do have a routine in ProcessDoubleReplacing that reduces the parse rate, but once again, this is of a 'self-hobbyist-semiskilled programmer' nature, and once again might not work so well in situations other than my plugin.
Having said all that, the project I am working on with this implemented is suffering no hiccups as a result of my efforts!

Given the above considerations let me know if you still would like an example and I'll try to post one before the weekend.

Edit - I can also only offer advice on the mac platform, I haven't plunged into cross platform as of yet.
I'm building in latest Xcode and using ox10.5sdk and I'm not sure which release of wdl-ol.

Thanks!

I guess we have similar goals for our plugin, I am also programming one that just works as an interface for controlling analogue hardware vía OSC. So there is no DSP inside the plugin. I was looking for this for around a month, tried with JUCE but had some problems with parameter automation.
hermes_2507 is offline   Reply With Quote
Old 09-28-2016, 02:27 PM   #9
leighhunt
Human being with feelings
 
Join Date: Jun 2016
Location: London, UK
Posts: 51
Default

No worries hermes!
I would imagine that my method would work ok for you then, though it is worth bearing in mind that automation is spilling out at sample rate ( I think), so you might want to implement some kind of data flow restriction to avoid overcrowding the osc stream.


Also, (This is not necessarily something you might run into, but...) be aware that if you have a lot of controls in your plugin, the iteration process in IGraphics::SetParameterFromPlug can get a bit cpu intensive when playing back automation.
(If you follow through from IPlugVST::VSTSetParameter, which is called by automation, you will find your way to IGraphics::SetParameterFromPlug).
By default, in the wdl-ol version I am using, SetParameterFromPlug iterates through all controls based on the possibility that you might have more than one control attached to a parameter.
I originally had a few thousand controls in my plugin, using a lot of show/hide commands. Now I have methods for attaching / detaching parameters from controls, saving a huge amount of iteration.
Hope this helps should you stumble there!
Leigh


Quote:
Originally Posted by hermes_2507 View Post
Thanks!

I guess we have similar goals for our plugin, I am also programming one that just works as an interface for controlling analogue hardware vía OSC. So there is no DSP inside the plugin. I was looking for this for around a month, tried with JUCE but had some problems with parameter automation.

Last edited by leighhunt; 09-28-2016 at 02:33 PM.
leighhunt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.