The score will look funny when you open it. Run the score polisher. This will make it readable.
Hopefully this will inspire someone to make a complete converter.
<?
require_once "powertabdocument.php";
$ptb = new PowerTabDocument ();
$durArr = array('64th'=>64, '32nd'=>32, '16th'=>16,'eighth'=>8, 'quarter'=>4, 'half'=>2, 'whole'=>1);
$ptb->Load ("BlankPowerTabFile.ptb");
$guitarScore = &$ptb->GetGuitarScore();
$sxe = simplexml_load_file("music.xml");
$s = -1;
$measureCt = 3;
foreach ($sxe->part->measure as $measure) {
if ($measureCt > 1) {
$guitarScore->m_systemArray[++$s] = new System;
$measureCt = 1;
$p=0;
}
$firstStaff = &$guitarScore->GetSystem($s)->GetStaff(0);
foreach ($measure->note as $note) {
$string = $note->notations->technical->string;
$fret = $note->notations->technical->fret;
$tied = $note->notations->tied["type"];
$dur = $durArr[(string) $note->type];
if ( isset($string,$fret) ) {
if (!$note->chord) {
$thePosition = &$firstStaff->m_positionArray[0][$p];
$thePosition = new Position ();
$thePosition->SetDurationType($dur);
//$thePosition->SetPreviousBeamDurationType($prevDur);
$prevDur = $dur;
++$p;
}
array_push($thePosition->m_noteArray,new Note($string-1, $fret) );
if ($tied=="stop")
$thePosition->m_noteArray[count($thePosition->m_noteArray) - 1]->SetTied();
}
}
$barLines = &$guitarScore->GetSystem($s)->m_barlineArray;
array_push($barLines,new Barline($p) );
++$measureCt;
}
$ptb->Save ("ConvertedFileName.ptb");
?>
0 comments:
Post a Comment