$count)
{
return array($string);
}
else
{
$num = (int)ceil($count/$split_length);
$ret = array();
for($i=0;$i<$num;$i++)
{
$ret[] = substr($string,$i*$split_length,$split_length);
}
return $ret;
}
}
}
$hex_array = str_split($hex_data,$hex_offset);
}
else
{
echo "Error opening/reading file!";
}
}
?>
GT-8 Patch/Sysex reader - DEBUG
$value)
{
if($hex_linecount <= 6) // INFO SPACE (HEADER)
{
switch($hex_linecount)
{
case 0: echo "\n"; break;
}
}
elseif (6 < $hex_linecount && $hex_linecount <= 10) // ADDRESS MSB SPACE
{
switch($hex_linecount)
{
case 7: echo "($value) ".$xml_array['MSB1'][$value][0]." (".$xml_array['MSB1'][$value][2].")
\n"; break;
case 8: echo "($value) ".$xml_array['MSB2'][$value][0]." (".$xml_array['MSB2'][$value][2].")
\n"; break;
case 9: echo "($value) ".$xml_array['LSB'][$value][0]." (".$xml_array['LSB'][$value][2].")
\n"; $LSB_value = strtoupper($value); break;
case 10: echo "($value) ".$xml_array['MSB3'][$value][0]." (".$xml_array['MSB3'][$value][2].")
\n"; break;
}
}
elseif ($value == 'F7') // EOX
{
echo "($value) ".$xml_array['HEADER'][8][1]."
\n";
$hex_linecount=0;
$data_linecount=0;
}
elseif ($hex_array[$index+1] == 'F7') // CHECKSUM SPACE
{
echo "($value) Checksum ";
$checksum = $data_size % hexdec(80);
if($checksum!=0) $checksum = hexdec(80) - $checksum;
$checksum = strtoupper(dechex($checksum));
if(strlen($checksum)<2) $checksum = "0" . $checksum;
echo ($value==$checksum)?"correct":"error!";
echo " ($checksum)
\n";
$data_size=0;
}
else
{
$DATA_value = strtoupper(dechex($data_linecount));
if(strlen($DATA_value)<2) $DATA_value = "0" . $DATA_value;
$DATA_next_value = strtoupper(dechex($data_linecount + 1));
if(strlen($DATA_next_value)<2) $DATA_next_value = "0" . $DATA_next_value;
$DATA_previous_value = strtoupper(dechex($data_linecount - 1));
if(strlen($DATA_previous_value)<2) $DATA_previous_value = "0" . $DATA_previous_value;
echo "($value) ".$xml_array['LSB'][$LSB_value]['DATA'][$DATA_value][2];
if ($xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA']['assign'][2]) // ASSIGN TARGETS
{
if(eregi(":", $assign_target_desc))
{
$assign_target_array = explode(":", $assign_target_desc);
}
else
{
$assign_target_array = explode(" ", $assign_target_desc);
if(eregi("\(", $assign_target_array[1]))
{
$pos = strpos($assign_target_array[1], "(");
$assign_target_array[1] = substr($assign_target_array[1], 0, $pos);
}
}
$assign_target = trim($assign_target_array[0]);
$assign_trigger = trim($assign_target_array[1]);
if(eregi("FX", $assign_target_array[0]))
{
$pos = strpos($assign_target_desc, ":");
$assign_trigger = trim(substr($assign_target_desc, $pos+1, strlen($assign_target_desc)));
}
foreach ($xml_array['LSB'] as $index_assign_target => $value_assign_target)
{
if(eregi($assign_target, $xml_array['LSB'][$index_assign_target][0]) ||
eregi($assign_target, $xml_array['LSB'][$index_assign_target][1]))
{
foreach($xml_array['LSB'][$index_assign_target]['DATA'] as $data_assign_index => $data_assign_value)
{
//if(eregi($assign_trigger, $xml_array['LSB'][$index_assign_target]['DATA'][$data_assign_index]['DATA'][$value][2]))
if($assign_trigger == $xml_array['LSB'][$index_assign_target]['DATA'][$data_assign_index]['DATA'][$value][2])
{
$LSB_value_tmp = $LSB_value;
$LSB_value = $index_assign_target;
$DATA_value_tmp = $DATA_value;
$DATA_value = $data_assign_index;
$value_tmp = $value;
$index_tmp = $index;
}
//elseif(eregi($assign_trigger, $xml_array['LSB'][$index_assign_target]['DATA'][$data_assign_index][2]))
elseif($assign_trigger == $xml_array['LSB'][$index_assign_target]['DATA'][$data_assign_index][2])
{
$LSB_value_tmp = $LSB_value;
$LSB_value = $index_assign_target;
$DATA_value_tmp = $DATA_value;
$DATA_value = $data_assign_index;
$value_tmp = $value;
$value = $hex_array[$index+1];
$index_tmp = $index;
$index = $index+1;
}
}
}
}
}
if( !$xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM'][$value][0] &&
$xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM'][$value][0]!="0" &&
!$xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM'][$hex_array[$index+1]][0] )
{
if ($xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM']['range'][0]) // PARAM RANGE
{
$range_string = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM']['range'][0];
$data_param_desc = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM']['range'][1];
$range_array = explode('/', $range_string);
$data_min = hexdec($range_array[0]);
$data_max = hexdec($range_array[1]);
$data_range = $data_max - $data_min;
$range_min = $range_array[2];
$range_max = $range_array[3];
$range = $range_max - $range_min;
$data_param = ($range_min - $data_min) + (hexdec($value) / ($data_range / $range));
if($data_param == 0) $data_param = "0";
}
elseif ($xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM']['range'][0]) //NESTED PARAM RANGE
{
$range_string = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM']['range'][0];
$data_param_desc = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM']['range'][1];
$range_array = explode('/', $range_string);
$data_min = hexdec($range_array[0]);
$data_max = hexdec($range_array[1]);
$data_range = $data_max - $data_min;
$range_min = $range_array[2];
$range_max = $range_array[3];
$range = $range_max - $range_min;
$data_param = ($range_min - $data_min) + (hexdec($hex_array[$index + 1]) / ($data_range / $range));
if($data_param == 0) $data_param = "0";
}
elseif ($xml_array['LSB'][$LSB_value]['DATA']['range']['PARAM'][$value][0]) // DATA RANGE
{
$data_param = $xml_array['LSB'][$LSB_value]['DATA']['range']['PARAM'][$value][0];
$data_param_desc = $xml_array['LSB'][$LSB_value]['DATA']['range']['PARAM'][$value][1];
}
else
{
$data_param = "";
$data_param_desc = "";
}
}
else // ALL OTHER KNOWN DATA
{
if($xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM'][$hex_array[$index+1]][0])
{
$data_param = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM'][$hex_array[$index+1]][0];
$data_param_desc = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['DATA'][$value]['PARAM'][$hex_array[$index+1]][1];
}
else
{
$data_param = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM'][$value][0];
$data_param_desc = $xml_array['LSB'][$LSB_value]['DATA'][$DATA_value]['PARAM'][$value][1];
}
}
if ($data_param!="" || $data_param_desc!="")
{
if ($data_param!="") echo " [$data_param]";
if ($data_param!="" && $data_param_desc!="") echo " ";
if ($data_param_desc!="") echo "($data_param_desc)";
if ($data_linecount == 2) $assign_target_desc = $data_param; // TO INDETIFIE ASSIGN TARGET && TRIGGER
}
else // UNKNOWN DATA
{
if ($xml_array['LSB'][$LSB_value]['DATA'][$DATA_previous_value]['DATA'][$hex_array[$index-1]][2])
{
echo $xml_array['LSB'][$LSB_value]['DATA'][$DATA_previous_value]['DATA'][$hex_array[$index-1]][2];
}
elseif ($xml_array['LSB'][$LSB_value]['DATA'][$DATA_previous_value]['DATA']['assign'][2])
{
echo $xml_array['LSB'][$LSB_value]['DATA'][$DATA_previous_value]['DATA']['assign'][2];
}
elseif ($xml_array['LSB'][$LSB_value]['DATA'][$DATA_value][2]!="(Reserved)")
{
echo "##EMPTY/UNKNOWN##";
}
}
echo "
\n";
$data_linecount++;
}
if($LSB_value_tmp)
{
$LSB_value = $LSB_value_tmp;
unset($LSB_value_tmp);
$DATA_value = $DATA_value_tmp;
unset($DATA_value_tmp);
$value = $value_tmp;
unset($value_tmp);
$index = $index_tmp;
unset($index_tmp);
}
if(dechex($data_linecount)=='80')
{
$LSB_value = strtoupper(dechex(hexdec($LSB_value) + 1));
if(strlen($LSB_value)<2) $LSB_value = "0" . $LSB_value;
$data_linecount = 0;
}
if($hex_linecount > 6 && $hex_array[$index+1] != 'F7') $data_size = $data_size + hexdec($value);
if ($value != 'F7') $hex_linecount++;
}
}
?>