From 5e8ce2e84e88694fe0d74e9cb3e0a12f1131028c Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 9 Oct 2020 02:38:03 +0200 Subject: [PATCH] add generators/lissajous.pl --- generators/lissajous.pl | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 generators/lissajous.pl diff --git a/generators/lissajous.pl b/generators/lissajous.pl new file mode 100755 index 0000000..1b2542e --- /dev/null +++ b/generators/lissajous.pl @@ -0,0 +1,75 @@ +#!/usr/bin/perl -w + +# +# Ugly code by tTh +# + + +my $port = 9000; +my $target = "localhost"; + +# ---------------------------------------------------------- + +use Net::OpenSoundControl::Client; +use Data::Dumper qw(Dumper); +use Getopt::Std; + +my $client; +my $verbose = 0; + +# ---------------------------------------------------------- + +sub lissajous($$$) +{ +my $kx = shift; my $ky = shift; +my $phi = shift; + +my ($i, $rads, $x, $y); + +for ($i = 0; $i <= 360; $i++) { + $rads = $i * (3.141592654/180); + $x = int(31250*sin(($rads*$kx)+$phi)); + $y = int(31250*cos($rads*$ky)); + # printf "%5d %9f %6d %6d\n", $i, $rads, $x, $y; + $client->send(['/joystick/xy', 'i', $x, 'i', $y]); + # sleep 0.42; + } +sleep 2+rand(2); +$client->send(['/joystick/b', 'i', 50, 'i', 1]); +$client->send(['/joystick/b', 'i', 50, 'i', 0]); +} + +# ---------------------------------------------------------- +# main proggy + +getopts('d:v', \%options); + +if (defined $options{"d"}) { + # print Dumper $options{"d"}; + ($target, $port) = split /:/, $options{"d"}; + } +$verbose = 1 if (defined $options{"v"}); +print "trashing ", $target, " on port ", $port, "\n"; + + +$client = Net::OpenSoundControl::Client->new( + Host => $target, Port => $port) + or die "Could not start client: $@\n"; + +print Dumper $client if $verbose; + +my ($xk, $yk, $phase); + +for ($xk=1; $xk<4; $xk++) { + for ($yk=1; $yk<4; $yk++) { + print "$$ -> $xk $yk\n"; + for ($phase=0.0; $phase<1.5705; $phase+=0.0911) { + print "phi = ", $phase, "\n" if $verbose; + lissajous($xk, $yk, $phase); + } + } + } + + + +