PhpTabs Documentation Build Status

Parse and write GuitarPro and MIDI files

Home Manual GitHub

API: Music / Track

Table of contents


Parent container

A Track is contained by a Song.


Accessing child nodes

countMeasures()

This method returns the number of measures contained by the track.

Type

integer

Example


$tab = new PhpTabs('mytabs.gp4');

$track = $tab->getTrack(0);

// Count the number of measures
echo $track->countMeasures();

// Will print a number between 0 and n-1

^ Table of contents


getMeasure($index)

This method returns a Measure resource.

Parameters

Type

\PhpTabs\Music\Measure

Example


$tab = new PhpTabs('mytabs.gp4');

// Get first measure
$measure = $tab->getTrack(0)->getMeasure(0);

// Print the measure id
echo $measure->getNumber();

// Will print "1"

^ Table of contents


getMeasures()

This method returns an array of Measure resources.

These are all measures contained in the current track.

Type

[]\PhpTabs\Music\Measure

Example


$tab = new PhpTabs('mytabs.gp4');

// Get all measures
$measures = $tab->getTrack(0)->getMeasures();

// Print all measure ids
foreach ($measures as $index => $measure) {
	echo sprintf(
		"\nMeasure number=%d, index=%d",
		$measure->getNumber(),
		$index
	);
}

will ouput something like:


Measure number=1, index=0
Measure number=2, index=1
Measure number=3, index=2
Measure number=4, index=3

^ Table of contents


countStrings()

This method returns the number of strings.

Type

integer

Example


$tab = new PhpTabs('mytabs.gp4');

$track = $tab->getTrack(0);

// Count the number of strings
echo $track->countStrings();

// Will print something like 6

^ Table of contents


getString($index)

This method returns a TabString resource.

Parameters

Type

\PhpTabs\Music\TabString

Example


$tab = new PhpTabs('mytabs.gp4');

// Get the first string
$string = $tab->getTrack(0)->getString(0);

// Print string value
echo $track->getValue();

// Will print something like "34"

^ Table of contents


getStrings()

This method returns an array of TabString resources.

These are all configured strings for the current track.

Type

[]\PhpTabs\Music\TabString

Example


$tab = new PhpTabs('mytabs.gp4');

// Get all strings
$strings = $tab->getTrack(0)->getStrings();

// Print all strings data
foreach ($strings as $index => $string) {
	echo sprintf(
		"\nString index=%d, number=%d, value=%d",
		$index,
    $string->getNumber(),
    $string->getValue()
	);
}

will ouput something like:


String index=0, number=1, value=64
String index=1, number=2, value=59
String index=2, number=3, value=55
String index=3, number=4, value=50
String index=4, number=5, value=45
String index=5, number=6, value=40

^ Table of contents


setNumber()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


addMeasure()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


removeMeasure()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


addString()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setStrings()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


getColor()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setColor()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setName()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


getOffset()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setOffset()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


isSolo()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setSolo()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


isMute()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setMute()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setChannelId()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setLyrics()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


setSong()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


clear()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


copyFrom()

This method returns.

Parameters

None

Type

integer

Values

Example

^ Table of contents


Accessing properties

getSong()

This method returns the parent Song.

Type

\PhpTabs\Music\Song

Example


$tab = new Phptabs('mytab.gp4');

$track = $tab->getTrack(0);

// Print song name
echo $track->getSong()->getName();

// Will ouput "My song name"

^ Table of contents


getName()

This method returns the name of the track.

Type

string

Example


$tab = new PhpTabs('mytabs.gp4');

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

// Print track name
echo $track->getName();

will ouput something like:

My track name

^ Table of contents


getChannelId()

This method returns the channel identifier for this track.

Type

integer

Example


$tab = new PhpTabs('mytabs.gp4');

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

// Print the channel id
echo $track->getChannelId();

will ouput something like:

1

^ Table of contents


getNumber()

This method returns the number identifier of the track.

Type

integer

Example


$tab = new PhpTabs('mytabs.gp4');

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

// Print the channel id
echo $track->getNumber();

will ouput something like:

1

^ Table of contents


getLyrics()

This method returns a Lyric resource.

Type

\PhpTabs\Music\Lyric

Example

^ Table of contents


Updating children


Updating properties


Examples

None


Edit this document on GitHub