PHP code example of stdtabs / phptabs

1. Go to this page and download the library: Download stdtabs/phptabs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stdtabs / phptabs example snippets


// Use standalone bootstrap



use PhpTabs\PhpTabs;

// Instanciates a tablature
$tablature = new PhpTabs("mytabs.gp3");

// Reads information
echo $tablature->getName();

$tablature->getName();

$tablature->getArtist();

$tablature->getAlbum();

$tablature->getAuthor();

$tablature->getCopyright();

$tablature->getWriter();
_EOL

$tablature->getComments();

$tablature->getTranscriber();

$tablature->getDate();

$tablature->countTracks();

$tablature->getTracks();

// Get the first track
$tablature->getTrack(0);

$tablature->countChannels();

$tablature->getChannels();

// Get the first channel
$tablature->getChannel(0);

$tablature->countInstruments();

array(
  'id' => <integer InstrumentId>,
  'name' => <string InstrumentName>
)

$tablature->getInstruments();

array(
  'id' => <integer InstrumentId>,
  'name' => <string InstrumentName>
)

// Get the first instrument
$tablature->getInstrument(0);

$tablature->countMeasureHeaders();

$tablature->getMeasureHeaders();

// Get the first measure header
$tablature->getMeasureHeader(0);

// Instanciate a GP3 tab
$tab = new PhpTabs('mytab.gp3');

// Save as GP3
$tab->save('newfile.gp3');

// Convert and save as GP5
$tab->save('newfile.gp5');


// Instanciate a GP3 tab
$tab = new PhpTabs('mytab.gp3');

// Convert as GP3
echo $tab->convert('gp3');

// Convert as GP5
echo $tab->convert('gp5');

// Convert as MIDI
echo $tab->convert('mid');

// Render as original format
// Should be equal as file_get_contents('mytab.gp3')
echo $tab->convert();