Beat's parent is :ref:`Measure <api.music.measure>`.
use PhpTabs\PhpTabs;
$song = new PhpTabs('my-song.gp5');
// Get a beat
$beat = $song->getTrack(0)
->getMeasure(0)
->getBeat(0);
echo sprintf("
Beat
----
start: %s
is chord beat: %s
is rest beat: %s
is text beat: %s
",
$beat->getStart(),
$beat->isChordBeat() ? 'true' : 'false',
$beat->isRestBeat() ? 'true' : 'false',
$beat->isTextBeat() ? 'true' : 'false'
);
It will ouput something like:
Beat
----
start: 960
is chord beat: false
is rest beat: true
is text beat: false
$beat->setStart(1920);
You may handle its :ref:`measure <api.music.measure>`.
$measure = $beat->getMeasure();
$beat->setMeasure($measure);
You may handle its :ref:`chord <api.music.chord>`.
$chord = $beat->getChord();
$beat->setChord($chord);
You may handle its :ref:`text <api.music.text>`.
$text = $beat->getText();
$beat->setText($text);
You may handle its :ref:`stroke <api.music.stroke>`.
$stroke = $beat->getStroke();
You may handle :ref:`voices <api.music.voice>`.
// Number of voices
$count = $beat->countVoices();
// Get an array of voices
$voices = $beat->getVoices();
// Get a single voice by its index
// starting from 0 to n-1
$voice = $beat->getVoice(0);
// Set a voice by index (0 or 1)
$beat->setVoice(1, $voice);