Thursday, August 09, 2007

PHP Power Tab Parser


We have just Written and Released a PHP Power Tab Parser. It is in beta, so please leave comments and report any bugs you may have.


This parser is a translation of Brad Larson's "ptparser." You must have PHP v5 or better. This package will only read and write power tab v1.7 files. See the sample script below to get your feet wet. This will load a power tab file and watermark it with a line of text at the top of the guitar score. This script is great if you are serving up power tab file, and you don't want someone stealing your power tabs, and redistributing them.




<?

require_once "powertabdocument.php";


$ptb = new PowerTabDocument ();

$ptb->Load ("powertabfile.ptb"); // Open and Load Power Tab

/* Water Mark File */

$guitarScore = &$ptb->GetGuitarScore(); // get the guitar score

$lastIndex = $guitarScore->GetFloatingTextCount(); // get the position of the last floating text element

$waterMark = &$guitarScore->m_floatingTextArray[$lastIndex];

$waterMark = new FloatingText ();

$rect = array (50,3,230,17); // create a new coordinate element

$waterMark->SetRect($rect);
$waterMark->SetText('File Downloaded @ AllPowerTabs.com');

/* Done Water Marking File */


$ptb->Save ("powertabfile.ptb"); // Save Power Tab File

?>



We have a lot planned for the feature, so keep checking the blog.

2 comments:

Nazgyl said...

Thanks for the parser,
i followed your code and it worked fine, i got the watermark

however im a newbie to php
and im middling in something that is sophisticated like your parser,
could you please post code for reading the header information
like:
GetSongArtist()
GetSongTitle()
GetSongReleaseTitle()
i wannna extract the song title,artist, album and display themthem on a php page

David said...

can I play PT files with this? If not... what I must download to play PT files in the browser?

Music Headlines

Loading...