OSC Receiver and Sender

A place for developers to share ideas and assist each other in solving problems.

Moderators: valis, garyb

Post Reply
w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

OSC Receiver and Sender

Post by w_ellis » Mon Dec 18, 2017 12:41 pm

I'll leave the original message here for posterity, but there are now two modules available, an OSC Sender and an OSC Receiver. Pick up the latest release from Github here and have fun! Here's some more detailed documentation on how to use the two modules.

=============

Hi all,

Inspired by the recent buzz of activity, I had a bit of a brain wave and cracked open Visual Studio for the first time in a while to create an OSC Receiver module for the SDK. It's super basic at the moment, but I wanted to get some feedback on what would be the most useful way to evolve it.

You can download it here: ScopeOSCReceiver.dll and at the moment it only has a 16 element output int array as an interface. It's listening on port 8000 and will receive messages with the format /<paramnumber>, e.g. /0 is the address for the first parameter, /1 for the second etc.

My planned next step will be to add a String input array to allow the addresses to be set through the module interface and an integer for the listening port. I'm not sure if it needs much else for now, but let me know what you think. I could add a console view to see messages as they arrive, but that would be quite a bit more work, so I'd do that later.

I'll also build an OSC sender, but that's actually a bit easier, so I thought I'd start with the trickier case.

I'd love to collaborate with others on building either a modular module to encapsulate this, or it could be incorporated into the controller managers I spotted in use by OS and RA. In particular, it would be great to get some help with an interface in the SDK to provide OSC address strings into an array, so I can test that bit. Essentially it would just need 16 string editors connected to an array, but my SDK skillz suck!

Let me know what you think!
Will
Last edited by w_ellis on Tue Apr 10, 2018 11:37 am, edited 3 times in total.

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Mon Dec 18, 2017 12:44 pm

P.S. As a bit of additional background, we had a really tough time trying to get ScopeSync to handle Input + Output well, as the SDK doesn't really have a nice way of incorporating a DLL that is bi-directional. This idea of splitting into 2 modules could be an alternative approach to making some progress on that again.

Also, I'd like to thank DragonSF for a tip in one of the threads that allowed me to work with an output array successfully for the first time. It turns out that as a C noob, I hadn't been correctly allocating my memory, hence lots of access violations. Let's just say that ScopeFX isn't beginner-friendly ;)

jksuperstar
Posts: 1554
Joined: Mon Nov 15, 2010 12:57 pm

Re: OSC Receiver

Post by jksuperstar » Mon Dec 18, 2017 2:38 pm

With an eye on the future, can you

assign midi or CV to OSC input.or.output?
At a top-level, auto detect and roll up all OSC parameters (in or out)?

That might help one day auto-detect all parameters in a synth, or even project, to auto/assisted assignment to controllers (like BCR2000, or Ableton Push via a M4L device, etc.) Or for DAW automation...a possible replacement for XTC mode.

DragonSF
Posts: 389
Joined: Sun Nov 08, 2015 4:28 pm

Re: OSC Receiver

Post by DragonSF » Mon Dec 18, 2017 10:04 pm

I'm willing to cooperate, because I've got some experience from my EXT-MIDI converter. CV output is good, but MIDI out has problems.

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 1:10 am

hey will, is this public domain? am i allowed to use this in a commercial device?

you just turned me on an idea :)
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Tue Dec 19, 2017 4:39 am

faxinadu wrote:
Tue Dec 19, 2017 1:10 am
hey will, is this public domain? am i allowed to use this in a commercial device?
I'm planning to keep everything open source, so there shouldn't be a problem, but let's worry about that if there's any serious money to be made ;)

I'd have to check on the exact details of licensing and how it would work for using an open source dll in a commercial project, but here's an idea of the worst case: https://juce.com/get-juce (i.e. it might need a splash screen)

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Tue Dec 19, 2017 4:44 am

jksuperstar wrote:
Mon Dec 18, 2017 2:38 pm
assign midi or CV to OSC input.or.output?
No plan to do anything about that, but those would be standard things that can be done in Scope SDK.

Compared to (Scope's version of CV), the control resolution would be the same, but CV runs over sync, which is properly real-time, whereas the OSC handling will be at async control rates, which are every 50-100ms. In testing that seems to be good enough for most cases, but not if you wanted to do audio-rate modulation (which isn't really what OSC is designed for).
jksuperstar wrote:
Mon Dec 18, 2017 2:38 pm
At a top-level, auto detect and roll up all OSC parameters (in or out)?
I'd want to understand the use case a bit better. This is mostly about being able to control Scope synths + effects using OSC, which has the advantage of full 32bit resolution and being able to run over a network (wired or wifi).

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Tue Dec 19, 2017 4:49 am

DragonSF wrote:
Mon Dec 18, 2017 10:04 pm
I'm willing to cooperate, because I've got some experience from my EXT-MIDI converter. CV output is good, but MIDI out has problems.
Great, I'll get in touch over PM once I have something that should parse a String Array at input for OSC addresses. Feel free to have a poke around at the code, in case you spot anything I could improve (I'm sure there's plenty!) Most of the relevant stuff is here: https://github.com/bcmodular/scopeosc/t ... ver/Source

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 5:32 am

separate output pads for each element would be cool instead of just the array
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Tue Dec 19, 2017 6:46 am

faxinadu wrote:
Tue Dec 19, 2017 5:32 am
separate output pads for each element would be cool instead of just the array
The idea for now was to make it quite flexible, so we can tweak the number of outputs easily etc. I'm not an expert in SDK, but isn't it easy to hook up an array splitter?

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:47 am

trying this out, gimme a bit, having a hard time on the java side im real noob :)
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:48 am

so to send the value 12 to the first array slot i would need to:

outMsg = "/0 12";

gonna try now
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Tue Dec 19, 2017 6:50 am

Exactly... easy to do using a udpsend module in Max For Live, or Reaper has OSC tools built in too. I'm sure it's easy to do in TouchOSC too, but it hurt my head when I tried to do it in a hurry the other night!

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:54 am

ha yes the thing is i am trying in Android Studio :0
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:56 am

i mean you don't even need osc tools as long as you transmit the message over the right ip to the right port yeah?
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

w_ellis
Posts: 526
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis » Tue Dec 19, 2017 6:57 am

As long as you're using UDP, not TCP, yes.

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:57 am

Code: Select all

 private void runTcpClient() {
        try{
            Socket s = new Socket("192.168.1.13", 5555);
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
            String outMsg = "";
            outMsg = "/0 12";
            out.write(outMsg);
            out.flush();
            out.close();
            s.close();
        }
i think something like this should do it, but im struggling to connect it to a button yet
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:58 am

ahhh this is tcp i think
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

User avatar
faxinadu
Posts: 1403
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu » Tue Dec 19, 2017 6:59 am

ok so this:

http://www.roman10.net/2011/11/22/andro ... h-example/

Code: Select all

private void runUdpClient()  {
    String udpMsg = "hello world from UDP client " + UDP_SERVER_PORT;
    DatagramSocket ds = null;
    try {
        ds = new DatagramSocket();
        InetAddress serverAddr = InetAddress.getByName("127.0.0.1");
        DatagramPacket dp;
        dp = new DatagramPacket(udpMsg.getBytes(), udpMsg.length(), serverAddr, UDP_SERVER_PORT);
        ds.send(dp);
    } catch (SocketException e) {
        e.printStackTrace();
    }catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (ds != null) {
            ds.close();
        }
    }
}
Scope 3rd Party Developer
http://www.oceanswift.net
Scope, Android and PC Developer
https://www.facebook.com/purechordsrecords/
Music
https://faxinadu.bandcamp.com/

jksuperstar
Posts: 1554
Joined: Mon Nov 15, 2010 12:57 pm

Re: OSC Receiver

Post by jksuperstar » Tue Dec 19, 2017 7:03 am

[quote=w_ellis post_id=332668 time=1513687473
I'd want to understand the use case a bit better. This is mostly about being able to control Scope synths + effects using OSC, which has the advantage of full 32bit resolution and being able to run over a network (wired or wifi).
[/quote]

I was thinking of Copperlan, the way a remote end can present a list of available parameters to choose from. But maybe I need to know the limitations of OSC better first.

Post Reply