Exemplo n.º 1
0
function playnotes($mn, $ip)
{
    // this is a total hack way of sending data to max
    //
    // since i couldn't write anything in php which would receive udp data, this uses the nc (netcat) command inside the
    // doalarm command which provides timeout capability - unfortunately, none of the php stream timeout methods worked on nc either
    //
    // error_reporting(E_ALL);
    // timeout is set to 10 seconds
    $fp = popen('./doalarm 10 nc -l -u 7401 2>&1', "r");
    // note that command is opened with redirection of stderr
    if (!$fp) {
        exit("error: unable to run netcat");
    }
    //  now send data to max
    $c = new OSCClient();
    // should check for error here too
    $c->set_destination($ip, 7400);
    // eventually, this data will be sent as JSON
    // This is probably not necessary here - but send a stop message to stop any currently playing sequence
    $maxdata = "/stop";
    $c->send(new OSCMessage($maxdata));
    $maxdata = "/begin";
    // header - begin
    $c->send(new OSCMessage($maxdata));
    for ($i = 0; $i < count($mn); $i++) {
        $maxdata = "/play " . " " . $mn[$i]->eventtime . " " . $mn[$i]->note . " " . $mn[$i]->velocity . " " . $mn[$i]->duration . " " . $mn[$i]->channel . " " . $mn[$i]->delay;
        $c->send(new OSCMessage($maxdata));
    }
    $maxdata = "/end";
    // header - end
    $c->send(new OSCMessage($maxdata));
    // get response from max
    sleep(1);
    $res = fread($fp, 2000);
    pclose($fp);
    // here we could actually check for elapsed time of 4 seconds to confirm timeout error
    if ($res == NULL) {
        echo "error -  no response from max/msp server";
    } else {
        echo "max returned: " . $res;
    }
    echo "<br>";
}
Exemplo n.º 2
0
<?php

include 'OSC.php';
include 'settings.php';
$c = new OSCClient();
$c->set_destination($RFserver, $RFport);
$c->send(new OSCMessage("/rf", array(0, 0, 0)));
echo "\$";
echo $_GET["v"];
Exemplo n.º 3
0
    //list
    $q = (string) $q;
    //$q = preg_split('/ /', $q);
} else {
    if (preg_match('/[a-z]/i', $q)) {
        //string
        $q = (string) $q;
    } else {
        if (preg_match('/[0-9]/i', $q)) {
            //number
            $q = (double) $q;
            $q = floatval($q);
        }
    }
}
$osc_name = $_POST["oscName"];
/* Get osc name to use as the osc message */
$osc_ip = $_POST["oscIp"];
/* If an osc_ip is posted as well, use that ip, otherwise, default to localhost */
if (is_null($osc_ip)) {
    $osc_ip = '127.0.0.1';
}
/* Relay the OSC message */
$c = new OSCClient();
$c->set_destination($osc_ip, 7475);
$queue = array($q);
array_unshift($queue, $_SERVER["REMOTE_ADDR"]);
$c->send(new OSCMessage($osc_name, $queue));
//$c->send(new OSCMessage($osc_name, $q));
echo "Got it";
/* If you want to send something back to the browser that sent the AJAX request. */
Exemplo n.º 4
0
<?php

include 'OSC.php';
include 'settings.php';
$c = new OSCClient();
$c->set_destination($RFserver, $RFport);
$c->send(new OSCMessage("/rf", array((int) $_GET["v"], 0, 0)));
$c->destroy();
echo "\$";
echo $_GET["v"];
Exemplo n.º 5
0
<?php

error_reporting(E_WARNING);
require_once "OSC.php";
echo "hello example\n";
$c = new OSCClient();
$c->set_destination("127.0.0.1", 10000);
$m1 = new OSCMessage("/test", array("aStringParameter"));
$m1->add_arg(31337.31337, "f");
$c->send($m1);
Exemplo n.º 6
0
/** Run some tests to make sure the library behaves in a sane way.
 */
function test_osc_lib()
{
    $c = new OSCClient();
    $c->set_destination("192.168.1.5", 3980);
    $m1 = new OSCMessage("/test", array(new Timetag(3294967295.0, 5), new Infinitum(), new Blob("aoeuaoeu!")));
    $m1->add_arg(28658.93, "d");
    $m2 = new OSCMessage("/bar", array(1, 2, array(1, 2, 3)));
    $b = new OSCBundle();
    $b->add_datagram($m1);
    $b->add_datagram($m2);
    $b2 = new OSCBundle(array($m1, $b));
    echo $b2->get_human_readable();
    //echo $m1->get_human_readable();
    $c->send($m1);
}
Exemplo n.º 7
0
<?php

include 'OSC.php';
include 'settings.php';
$c = new OSCClient();
$c->set_destination($IRserver, $IRport);
$c->send(new OSCMessage("/ir", array(0)));
echo "\$";
echo $_GET["v"];
Exemplo n.º 8
0
 * @author     Lucas S. Bickel <*****@*****.**>
 * @copyright  2011 Lucas S. Bickel 2011 - Alle Rechte vorbehalten
 * @license    http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
 * @link       http://osc.purplehaze.ch
 */
/**
 * load andy schmeders osc client
 */
require_once 'lib/OSC.php';
/**
 * setup OSCClient
 */
$client = new OSCClient();
$client->set_destination("localhost", 10000);
/**
 * send a osc message with nested array data 
 */
$m = new OSCMessage("/container/method", array(1, 12, array(array("channel", 1, "state", false), false, true)));
$client->send($m);
/**
 * send osc bundle with multiple messages
 */
$b = new OSCBundle();
$b->add_datagram(new OSCMessage("/foo", array(100, "like a boss")));
$b->add_datagram(new OSCMessage("/bar", array(new Timetag(), true, 255)));
$client->send($b);
/**
 * send last osc bundle nested in a osc bundle
 */
$b = new OSCBundle(array($b));
$client->send($b);
Exemplo n.º 9
0
<?php

include 'OSC.php';
include 'settings.php';
$c = new OSCClient();
$c->set_destination($RGBserver, $RGBport);
//Original OSCMessage format for old code - now all channels are seperate:
//$c->send(new OSCMessage("/rgb", array((int)$_GET["r"],(int)$_GET["g"],(int)$_GET["b"])));
$c->send(new OSCMessage("/r", array((int) $_GET["r"] / 255)));
$c->send(new OSCMessage("/g", array((int) $_GET["g"] / 255)));
$c->send(new OSCMessage("/b", array((int) $_GET["b"] / 255)));
$c->destroy();
echo "\$";
echo $_GET["r"];
echo "\$";
echo $_GET["g"];
echo "\$";
echo $_GET["b"];
Exemplo n.º 10
0
/* Receive data parameter as a post */
if (preg_match('/ /', $q)) {
    //list
    $q = (string) $q;
    //$q = preg_split('/ /', $q);
} else {
    if (preg_match('/[a-z]/i', $q)) {
        //string
        $q = (string) $q;
    } else {
        if (preg_match('/[0-9]/i', $q)) {
            //number
            $q = (double) $q;
            $q = floatval($q);
        }
    }
}
$osc_name = $_POST["oscName"];
/* Get osc name to use as the osc message */
$osc_ip = $_POST["oscIp"];
/* If an osc_ip is posted as well, use that ip, otherwise, default to localhost */
if (is_null($osc_ip)) {
    $osc_ip = '127.0.0.1';
}
/* Relay the OSC message */
$c = new OSCClient();
$c->set_destination($osc_ip, 7475);
$c->send(new OSCMessage($osc_name, array($q)));
//$c->send(new OSCMessage($osc_name, $q));
echo "Got it";
/* If you want to send something back to the browser that sent the AJAX request. */