Results 1 to 7 of 7

Thread: communicating with LSX across network sockets

  1. #1
    swamidog's Avatar
    swamidog is online now Jr. Woodchuckington Janitor III, Esq.
    Join Date
    Nov 2006
    Location
    santa fe, nm
    Posts
    1,545,752

    Default communicating with LSX across network sockets

    one of the things that really hasn't been discussed is LSX's ability to receive
    data from external sources. this opens up some very intresting possibilities.

    LSX has built in functionality to receive OSC data across a network socket.

    because LSX can listen on a network socket,
    the external application does not need to reside on the host that runs LSX.


    osc is a fairly straightforward protocol. wiki says:

    "Open Sound Control (OSC) is a content format for messaging among computers, sound synthesizers, and
    other multimedia devices that are optimized for modern networking technology. Bringing the benefits
    of modern networking technology to the world of electronic musical instruments, OSC's advantages
    include interoperability, accuracy, flexibility, and enhanced organization and documentation."


    osc data can be generated with a number of tools and applications. in this example, i'm going to use perl.
    perl is awesome, easy, and there are tons of third party modules that can be download to handle the heavy lifting.

    i'm setting up my osc environment on a mac laptop. modern mac osx is secretly unix with an excellent gui so
    this process would be reasonably identical for linux or other flavors of unix.

    download the perl osc client module from cpan:

    http://search.cpan.org/~crenz/Net-Op...trol/Client.pm

    cd into the module download directory and expand the module archive:

    cshort:~ cshort$ cd Downloads/

    cshortownloads cshort$ ls -al Net*
    -rw-r--r--@ 1 cshort staff 8193 Apr 24 21:16 Net-OpenSoundControl-0.05.tar.gz

    cshortownloads cshort$ gunzip Net-OpenSoundControl-0.05.tar.gz

    cshortownloads cshort$ tar -xvf Net-OpenSoundControl-0.05.tar
    x Net-OpenSoundControl-0.05/
    x Net-OpenSoundControl-0.05/Changes
    x Net-OpenSoundControl-0.05/examples/
    x Net-OpenSoundControl-0.05/examples/makebundle.pl
    x Net-OpenSoundControl-0.05/examples/oscclient.pl
    x Net-OpenSoundControl-0.05/examples/oscserver.pl
    x Net-OpenSoundControl-0.05/examples/reaktor.pl
    x Net-OpenSoundControl-0.05/examples/reaktor2.pl
    x Net-OpenSoundControl-0.05/lib/
    x Net-OpenSoundControl-0.05/lib/Net/
    x Net-OpenSoundControl-0.05/lib/Net/OpenSoundControl/
    x Net-OpenSoundControl-0.05/lib/Net/OpenSoundControl/Client.pm
    x Net-OpenSoundControl-0.05/lib/Net/OpenSoundControl/Server.pm
    x Net-OpenSoundControl-0.05/lib/Net/OpenSoundControl.pm
    x Net-OpenSoundControl-0.05/Makefile.PL
    x Net-OpenSoundControl-0.05/MANIFEST
    x Net-OpenSoundControl-0.05/META.yml
    x Net-OpenSoundControl-0.05/README
    x Net-OpenSoundControl-0.05/t/
    x Net-OpenSoundControl-0.05/t/1-use.t
    x Net-OpenSoundControl-0.05/t/2-tofrom.t
    x Net-OpenSoundControl-0.05/t/3-encode_decode.t
    x Net-OpenSoundControl-0.05/t/4-bundles_timestamp.t
    x Net-OpenSoundControl-0.05/t/5-spec_msgs.t
    x Net-OpenSoundControl-0.05/t/pod-coverage.t
    x Net-OpenSoundControl-0.05/t/pod.t

    cshortownloads cshort$ cd Net-OpenSoundControl-0.05
    cshort:Net-OpenSoundControl-0.05 cshort$ ls
    Changes MANIFEST META.yml Makefile.PL README examples lib t

    cshort:Net-OpenSoundControl-0.05 cshort$ perl Makefile.PL
    Checking if your kit is complete...
    Looks good
    Writing Makefile for Net::OpenSoundControl
    cshort:Net-OpenSoundControl-0.05 cshort$ make all
    cp lib/Net/OpenSoundControl.pm blib/lib/Net/OpenSoundControl.pm
    cp lib/Net/OpenSoundControl/Client.pm blib/lib/Net/OpenSoundControl/Client.pm
    cp lib/Net/OpenSoundControl/Server.pm blib/lib/Net/OpenSoundControl/Server.pm
    Manifying blib/man3/Net::OpenSoundControl::Server.3pm
    Manifying blib/man3/Net::OpenSoundControl::Client.3pm
    Manifying blib/man3/Net::OpenSoundControl.3pm

    cshort:Net-OpenSoundControl-0.05 cshort$ make test
    PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
    t/1-use.t ................ ok
    t/2-tofrom.t ............. ok
    t/3-encode_decode.t ...... ok
    t/4-bundles_timestamp.t .. ok
    t/5-spec_msgs.t .......... ok
    t/pod-coverage.t ......... skipped: Test::Pod::Coverage 1.04 required for testing POD coverage
    t/pod.t .................. ok
    All tests successful.
    Files=7, Tests=28, 0 wallclock secs ( 0.03 usr 0.02 sys + 0.17 cusr 0.03 csys = 0.25 CPU)
    Result: PASS

    cshort:Net-OpenSoundControl-0.05 cshort$ sudo su -
    Password:

    cshort:~ root# cd /Users/cshort/downloads

    cshort:downloads root# cd Net-OpenSoundControl-0.05
    cshort:Net-OpenSoundControl-0.05 root# make install
    Installing /Library/Perl/5.12/Net/OpenSoundControl.pm
    Installing /Library/Perl/5.12/Net/OpenSoundControl/Client.pm
    Installing /Library/Perl/5.12/Net/OpenSoundControl/Server.pm
    Installing /usr/local/share/man/man3/Net::OpenSoundControl.3pm
    Installing /usr/local/share/man/man3/Net::OpenSoundControl::Client.3pm
    Installing /usr/local/share/man/man3/Net::OpenSoundControl::Server.3pm
    Appending installation info to /Library/Perl/Updates/5.12.4/darwin-thread-multi-2level/perllocal.pod

    the perl module is now compiled, tested, and installed.

    make sure you have connectivity to the host running LSX:

    cshortocuments cshort$ ping 169.254.68.11
    PING 169.254.68.11 (169.254.68.11): 56 data bytes
    64 bytes from 169.254.68.11: icmp_seq=0 ttl=128 time=0.427 ms
    64 bytes from 169.254.68.11: icmp_seq=1 ttl=128 time=0.269 ms
    64 bytes from 169.254.68.11: icmp_seq=2 ttl=128 time=0.340 ms
    64 bytes from 169.254.68.11: icmp_seq=3 ttl=128 time=0.227 ms
    ^C

    --- 169.254.68.11 ping statistics ---
    4 packets transmitted, 4 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 0.227/0.316/0.427/0.076 ms

    run LSX, click on "Edit scanner setting", and then select "Remote Settings->OSC Remote Control".

    Click on the "Start" button under "Server Status".

    Click image for larger version. 

Name:	osc-control.jpg 
Views:	20 
Size:	89.5 KB 
ID:	37940

    time for a little bit of code. open the text editor of your choice and insert this. remember to change the ip address in the source code to that of your LSX host.

    Code:
    #!/usr/bin/perl  
    use Net::OpenSoundControl::Client;
    
     my $client = Net::OpenSoundControl::Client->new(
         Host => "169.254.68.11", Port => 10000)
        or die "Could not start client: $@\n";
    
    $client->send(['/LSX_0/RunTxt', 's',"swamidog is my hero"]);
    save this as "test-osc.pl", and make sure it's executable:

    cshort:LSX cshort$ chmod +x test-osc.pl
    cshort:LSX cshort$ ls -al test-osc.pl
    -rwxr-xr-x 1 cshort staff 255 Apr 24 22:25 test-osc.pl

    now for the fun part!

    from the horizontal menu along the top of LSX, select "Live->Run Text", and then click the "Start" button.

    run the test-osc.pl script:

    cshort:LSX cshort$ ./test-osc.pl

    and the embedded text string from the text-osc.file will appear in the message window. if your laser projector is on, the scrolling message will be projected.

    Click image for larger version. 

Name:	run-text.jpg 
Views:	17 
Size:	108.7 KB 
ID:	37941

    nice and easy!
    Last edited by swamidog; 04-24-2013 at 22:42.
    suppose you're thinkin' about a plate o' shrimp. Suddenly someone'll say, like, plate, or shrimp, or plate o' shrimp out of the blue, no explanation. No point in lookin' for one, either. It's all part of a cosmic unconciousness.

  2. #2
    Join Date
    Sep 2009
    Location
    Brno, CZ / Povazska Bystrica, SK
    Posts
    491

    Default

    how do you get list of control names? for example RunTxt, is there a list somewhere in LSX help?

  3. #3
    Join Date
    Jul 2008
    Location
    My momentum is too precisely determined :S
    Posts
    1,777

    Default

    Yes, if you go to Settings >> Remote settings >> OSC Remote Control, there is a Help button with a list of all commands.

    Thank you swamidog! But...


    Quote Originally Posted by swamidog View Post

    LSX has built in functionality to receive OSC data across a network socket.

    because LSX can listen on a network socket,
    the external application does not need to reside on the host that runs LSX.


    i'm setting up my osc environment on a mac laptop. modern mac osx is secretly unix with an excellent gui so
    this process would be reasonably identical for linux or other flavors of unix.
    How would you set up an external application that generates OSC commands in Windows? Is there a program for that? Something open source? Could you just give in your computer's IP address and then /LSX_0/*command*? Or how does this usually happen?

    I'll have a look and see if I can figure out what you are doing, but I have zero experience with Perl and Unix stuff.

    I'm thinking of creating a standalone program for my BPM stuff in the future, so you don't need to sacrifice a timeline for the GUI anymore. OSC would probably be the best way.
    Would Processing be a good way to create this program in?

    Also, post 1000!
    Last edited by colouredmirrorball; 04-25-2013 at 03:08.

  4. #4
    swamidog's Avatar
    swamidog is online now Jr. Woodchuckington Janitor III, Esq.
    Join Date
    Nov 2006
    Location
    santa fe, nm
    Posts
    1,545,752

    Default

    cygwin (http://www.cygwin.com/) under windows makes a pretty excellent development environment for things like this. there are also very good perl packages available for wintel.

    for more information on OSC: http://opensoundcontrol.org/

    Quote Originally Posted by colouredmirrorball View Post
    Yes, if you go to Settings >> Remote settings >> OSC Remote Control, there is a Help button with a list of all commands.

    Thank you swamidog! But...




    How would you set up an external application that generates OSC commands in Windows? Is there a program for that? Something open source? Could you just give in your computer's IP address and then /LSX_0/*command*? Or how does this usually happen?

    I'll have a look and see if I can figure out what you are doing, but I have zero experience with Perl and Unix stuff.

    I'm thinking of creating a standalone program for my BPM stuff in the future, so you don't need to sacrifice a timeline for the GUI anymore. OSC would probably be the best way.
    Would Processing be a good way to create this program in?

    Also, post 1000!
    Last edited by swamidog; 04-25-2013 at 07:33.
    suppose you're thinkin' about a plate o' shrimp. Suddenly someone'll say, like, plate, or shrimp, or plate o' shrimp out of the blue, no explanation. No point in lookin' for one, either. It's all part of a cosmic unconciousness.

  5. #5
    swamidog's Avatar
    swamidog is online now Jr. Woodchuckington Janitor III, Esq.
    Join Date
    Nov 2006
    Location
    santa fe, nm
    Posts
    1,545,752

    Default

    Quote Originally Posted by colouredmirrorball View Post

    How would you set up an external application that generates OSC commands in Windows? Is there a program for that? Something open source? Could you just give in your computer's IP address and then /LSX_0/*command*? Or how does this usually happen?
    here's a breakdown of the format:

    http://opensoundcontrol.org/spec-1_0...les#OSCstrings

    the "Net::OpenSoundControl::Client" module handles this and all the networking behind the scenes.

    c.
    suppose you're thinkin' about a plate o' shrimp. Suddenly someone'll say, like, plate, or shrimp, or plate o' shrimp out of the blue, no explanation. No point in lookin' for one, either. It's all part of a cosmic unconciousness.

  6. #6
    Join Date
    Jan 2011
    Location
    Santa Cruz, CA
    Posts
    309

    Default

    Here are some libs if you favor Python like I do.

    SimpleOSC

    http://www.ixi-audio.net/content/bod...rd_python.html

    pyOSC

    https://trac.v2.nl/wiki/pyOSC

  7. #7
    swamidog's Avatar
    swamidog is online now Jr. Woodchuckington Janitor III, Esq.
    Join Date
    Nov 2006
    Location
    santa fe, nm
    Posts
    1,545,752

    Default

    cool! thanks for the post.

    btw, etherdream dac also supports OSC for things like output size, placement, geometry correction, scanning speed, and for triggering show playback. j4 even wrote a touchosc template for it:





    Quote Originally Posted by discothefunkyhippo View Post
    Here are some libs if you favor Python like I do.

    SimpleOSC

    http://www.ixi-audio.net/content/bod...rd_python.html

    pyOSC

    https://trac.v2.nl/wiki/pyOSC
    suppose you're thinkin' about a plate o' shrimp. Suddenly someone'll say, like, plate, or shrimp, or plate o' shrimp out of the blue, no explanation. No point in lookin' for one, either. It's all part of a cosmic unconciousness.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •