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".
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.
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.