OSC Receiver and Sender

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

Moderators: valis, garyb

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

Re: OSC Receiver

Post by w_ellis »

faxinadu wrote: Tue Dec 19, 2017 6:59 am ok so this:
http://www.roman10.net/2011/11/22/andro ... h-example/
Yup, Datagram Sockets is what you want!
w_ellis
Posts: 554
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis »

jksuperstar wrote: Tue Dec 19, 2017 7:03 am 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.
Yeah, probably looking to walk before we can run :) I had a look into Copperlan a while back and from an implementation perspective it's a bit of a nightmare. Super complex and a lot of features that I imagine a tiny fraction of people would use.
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

Code: Select all

package c.oceanswift.scope1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

       
        final Button button = findViewById(R.id.Randomizer);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                    String udpMsg = "/0 12";
                    DatagramSocket ds = null;
                    try {
                        ds = new DatagramSocket();
                        InetAddress serverAddr = InetAddress.getByName("192.168.1.13");
                        DatagramPacket dp;
                        dp = new DatagramPacket(udpMsg.getBytes(), udpMsg.length(), serverAddr, 8000);
                        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();
                        }
                    }
            }
        });
    }
    }
any hints why this isnt working? its a button on that is supposed to send on click
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
w_ellis
Posts: 554
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis »

Sometimes there can be issues with firewalls, especially when sending across LAN. You might need to add an exception to a firewall on the listening PC.

I'm assuming you don't have any errors from the app? You could also use something like Wireshark to listen for the messages.
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

i don't have any compile errors but i have some debugger errors when clicking the button. its very much possible i have errors heh. yah im grabbing a sniffer, but imo my code is wrong
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

i think i got better java code now, but checking via the steps outlined in the link, it does not seem like anything is listening on port 8000 on my pc. i got the module open in sdk.

https://stackoverflow.com/questions/481 ... on-windows
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
w_ellis
Posts: 554
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis »

The problem is that all those answers are talking about TCP. Listening on UDP is quite different. Mostly you just want to see if the messages are arriving on your machine now, which is where Wireshark comes in.
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

its showing udp answers too....

yeah im also with wireshark checking
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

aaaaa.png
aaaaa.png (180.33 KiB) Viewed 424671 times

so as far as i can see i am both transiting and receiving but nada on scope
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
w_ellis
Posts: 554
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis »

Sorry, I only skimmed the page and saw all the stuff about TCP. It looks like you're doing the right thing with your app.

I'm actually just working on the OSC Sender, which I'll probably finish tomorrow. That will at least make it easy to check that stuff is working locally.

Btw. how are you checking that you're getting something on Scope? I generally just plug in one of Simon's Pipe modular modules and look at the values there. You have to be a bit careful with the readouts though, as the SDK often doesn't update them without explicitly refreshing.
w_ellis
Posts: 554
Joined: Wed Nov 07, 2001 4:00 pm
Location: London, U.K.

Re: OSC Receiver

Post by w_ellis »

Unfortunately have to go to bed now, as teething baby will be keeping us up all night, but hope to make more progress tomorrow!
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

yeah but once a value is sent, it is held in the array until a new one comes in yeah? its not momentary and reverts... so i should have seen my magic little 12 there by now ehhehe :) tried refreshing, clicking and declicking the module, going into the array with f2 and other wishful things... hmmm not sure what else to try, kinda stoked and shocked i even got the android part to work (lots of copy paste from online codes heeh).
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

ok i just verified your module works using some random android app called QuickOsc! so still something im doing isn't right
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

oscc.png
oscc.png (89.88 KiB) Viewed 424655 times
it seems the QuickOsc is working via OSC protocol while mine is over UDP... those are the differences i spotted
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

EDIT: fixed issue, i didn't notice the module inherits voices and it was getting 0 voices, sorry my bad, but yeah something to make sure when testing!

ok i have done some more testing and it seems the sdk module is not so reliable.

with the app that i confirmed works, and also seeing it transmit every button press over wireshark without problems, the sdk module seems to work only some of the time.

i have also forwarded the port via my router to the target pc as well as activated dmz host for good measure.

on same procedure ie open sdk, open the module and trasnmit to it sometimes it will connect and sometimes not.
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

eheh ok new issue - i can not get it to update anything real time.

osc module is connected to an array viewer that has selcount input and value output. a 0-1 normal scope button is connected to the value output.

quickosc is sending a 0 and a 1. the osc module is getting the info and it is passed to the splitter - but the information is not updating real time, only if and when i physically change the selcount to another sel and back, will it show the change.

i am not sure if its an issue from the osc module or the way to view arrays, but i anticipated this stuff i have been banging my head against the wall with some scope array issues lately, that is why i asked for 16 outputs instead of an array.
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
DragonSF
Posts: 405
Joined: Sun Nov 08, 2015 4:28 pm

Re: OSC Receiver

Post by DragonSF »

Scope arrays are a mess. Having 16 outputs instead of an array is (IMHO) the preferred way. And arrays are not updated automatically. You need to reload/reconnect the module to get an update.
Last edited by DragonSF on Tue Dec 19, 2017 11:23 pm, edited 1 time in total.
DragonSF
Posts: 405
Joined: Sun Nov 08, 2015 4:28 pm

Re: OSC Receiver

Post by DragonSF »

w_ellis wrote: 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
You shouldn't do this:
asyncOut[OUTPAD_PARAMS].itg = (int)malloc(4 * numParameters);
You have a memory leak here. I'd allocate the memory only once and re-use it. In your case, every per second you are allocating 640bytes=>1h about 2.5 MB of data, which you are not releasing. Scope does not free the data.

And I'm confused:
class ScopeOSCServer : private OSCReceiver

Are you trying to create a server or receiver?
Last edited by DragonSF on Tue Dec 19, 2017 11:32 pm, edited 1 time in total.
User avatar
faxinadu
Posts: 1602
Joined: Wed Nov 01, 2006 3:12 am
Location: israel
Contact:

Re: OSC Receiver

Post by faxinadu »

DragonSF wrote: Tue Dec 19, 2017 11:14 pm Scope arrays are a mess. Having 16 outputs instead of an array is (IMHO) the preferred way.
for sure!

and anyways......... why just 16? any chance for 64? :)
Scope, Android, Web, PC Plugins and Sounds:
http://www.oceanswift.net
Music
https://faxinadu.bandcamp.com/
DragonSF
Posts: 405
Joined: Sun Nov 08, 2015 4:28 pm

Re: OSC Receiver

Post by DragonSF »

faxinadu wrote: Tue Dec 19, 2017 11:22 pm
DragonSF wrote: Tue Dec 19, 2017 11:14 pm Scope arrays are a mess. Having 16 outputs instead of an array is (IMHO) the preferred way.
for sure!

and anyways......... why just 16? any chance for 64? :)
What ever you can handle! (Normally you have to write an interface code for each pin, but my dll generator takes care of this stuff).
Post Reply