Esempio n. 1
0
<?php

// Controller //
header('Content-Type: application/json');
session_start();
require __DIR__ . "/../../vendor/autoload.php";
$SIDV2 = new MIDI\SIDV2();
$f = glob("syx/*.syx");
shuffle($f);
$NFO = $SIDV2->patchInfo($f[0]);
print_r($NFO);
exit;
//patchInfo("syx/patch034.syx");
/*
02/a) F0 00 00 7E 4B <device-number> 02 00 <bank> <patch> <1024 bytes of dump data> <checksum> F7
        Write a dump to <patch> in <bank>
        Checksum is 2s complement over the 1024 bytes dump
        The actual patch size is only 512 bytes - the 8bit values are
        divided into low- and high-nibble (low-nibble is sent first),
        therefore 1024 bytes have to be sent
*/
function patchInfo($filename = '')
{
    //echo __FUNCTION__."($filename)\n";
    $INFO = [];
    //output
    $size = filesize($filename);
    echo "size={$size}\n";
    //$head=[];
    $f = fopen($filename, "r");
    $head = fread($f, 10);
Esempio n. 2
0
<?php

// Controller //
header('Content-Type: application/json');
session_start();
require __DIR__ . "/../../vendor/autoload.php";
$SIDV2 = new MIDI\SIDV2();
$dat = [];
switch ($_POST['do']) {
    case 'browse':
        $f = glob("syx/*.syx");
        foreach ($f as $file) {
            $finfo = [];
            $finfo['patch'] = $SIDV2->patchInfo($file);
            $finfo['basename'] = basename($file);
            $dat['files'][] = $finfo;
        }
        exit(json_encode($dat));
    case 'preview':
        $dat['POST'] = $_POST;
        $filename = "./syx/" . $_POST['file'];
        $dat['patch'] = $SIDV2->patchInfo($filename);
        $dat['bin'] = base64_encode($SIDV2->patchBinary($filename));
        exit(json_encode($dat));
    default:
        exit(json_encode(['error' => 'hello?']));
}