Example #1
0
<?php

include_once dirname(__FILE__) . '/tools.php';
if (is_null($params = parseParams($argc, $argv))) {
    usage(basename(__FILE__));
}
if ($params['help']) {
    help();
    exit;
}
$config = isset($params['c']) ? $params['c'] : 'test.xml';
include_once dirname(__FILE__) . '/../setup.php';
if (isset($params['t'])) {
    switch ($params['t']) {
        case 'period':
            $qty = count(periods());
            break;
        case 'report':
            $qty = count(groups());
            break;
        case 'basis':
            $qty = count(basis());
            break;
        default:
            usage(basename(__FILE__));
    }
    print $qty;
    exit;
}
if (!isset($params['f'])) {
    print "No input file given\n";
Example #2
0
        $period = $frequency / $baseFreq;
        $base = intval($period);
        $fraction = $period - $base;
        $fractionByte = intval(round($fraction * 256));
        if ($fractionByte == 256) {
            $fractionByte = 0;
            $base++;
        }
        $midiData['periods'][$midiIndex] = array($base, $fractionByte);
    }
    return $midiData;
}
// print_r($sineTable);
$notes = generateNotes($notes);
$midiData = midiNotes($notes);
$midiData = periods($midiData, $fSampleRate, $tableSize);
print_r($midiData);
exit;
if ($PC) {
    $sineTableCode = 'unsigned char sineTable[256] = { ';
} else {
    $sineTableCode = 'const byte sineTable[256] PROGMEM = { ';
}
foreach ($sineTable as $index => $value) {
    if (!($index % 16)) {
        $sineTableCode .= chr(10) . chr(9);
    }
    $sineTableCode .= $value . ', ';
}
$sineTableCode = substr($sineTableCode, 0, -2) . chr(10) . ' };' . chr(10);
echo $sineTableCode;