Logiciels divers autour du protocole « Open Sound Control » aka OSC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

  1. #!/usr/bin/perl -w
  2. use Net::OpenSoundControl::Client;
  3. use Data::Dumper qw(Dumper);
  4. use Getopt::Std;
  5. my $client;
  6. my $verbose = 0;
  7. my $dhost = "localhost";
  8. my $dport = 9000;
  9. # ----------------------------------------------------------
  10. sub AskErase($)
  11. {
  12. my $b = shift;
  13. $client->send(['/joystick/b', 'i', $b, 'i', 1]);
  14. $client->send(['/joystick/b', 'i', $b, 'i', 0]);
  15. }
  16. # ----------------------------------------------------------
  17. print "--- Moresinus $$ ---\n";
  18. getopts('d:v', \%options);
  19. if (defined $options{"d"}) {
  20. # print Dumper $options{"d"};
  21. ($dhost, $dport) = split /:/, $options{"d"};
  22. }
  23. $verbose = 1 if (defined $options{"v"});
  24. print "trashing ", $dhost, " on port ", $dport, "\n";
  25. $client = Net::OpenSoundControl::Client->new(
  26. Host => $dhost, Port => $dport)
  27. or die "Could not start client: $@\n";
  28. print Dumper $client if $verbose;
  29. # ----------------------------------------------------------
  30. AskErase(50);
  31. srand($$);
  32. print " ", rand(1000), "\n";
  33. my ($t, $v, $r1, $r2, $phi);
  34. $r1 = rand(100) + 1600;
  35. $r2 = rand(100) + 3200;
  36. $phi = rand(3124) / 1000.0;
  37. print " $r1 $r2 $phi\n" if $verbose;
  38. for ($t = -32000; $t < 32000; $t+=150) {
  39. $v = 15000 * (sin($t / $r1) + cos($phi + ($t / $r2)));
  40. # print $t, " --> ", $v, "\n";
  41. $client->send(['/joystick/xy', 'i', $t, 'i', $v]);
  42. sleep 1 if (($t % 16) == 0);
  43. }